From 7214f64b2c04f10c04684ea84473bf2371342dd7 Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Wed, 31 Aug 2011 01:20:43 +0000 Subject: [PATCH] svn merge -c 1163465 from trunk for HADOOP-7593. Contributed by Uma Maheswara Rao G git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1163466 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../src/main/java/org/apache/hadoop/http/HttpServer.java | 2 +- .../test/java/org/apache/hadoop/http/TestHttpServer.java | 9 +++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index eb8398cc992..4863f81875d 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -534,6 +534,9 @@ Release 0.23.0 - Unreleased HADOOP-7576. Fix findbugs warnings and javac warnings in hadoop-auth. (szetszwo) + HADOOP-7593. Fix AssertionError in TestHttpServer.testMaxThreads(). + (Uma Maheswara Rao G via szetszwo) + Release 0.22.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java index d5deb7df921..0aaa964313b 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer.java @@ -178,7 +178,7 @@ public class HttpServer implements FilterContainer { int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1); // If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the - // default value (currently 254). + // default value (currently 250). QueuedThreadPool threadPool = maxThreads == -1 ? new QueuedThreadPool() : new QueuedThreadPool(maxThreads); webServer.setThreadPool(threadPool); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java index 50de7fc2cbf..38c70b910c8 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/http/TestHttpServer.java @@ -18,9 +18,7 @@ package org.apache.hadoop.http; import java.io.IOException; -import java.io.PrintStream; import java.io.PrintWriter; -import java.net.URLConnection; import java.net.HttpURLConnection; import java.net.URL; import java.util.Arrays; @@ -131,7 +129,9 @@ public class TestHttpServer extends HttpServerFunctionalTest { } @BeforeClass public static void setup() throws Exception { - server = createTestServer(); + Configuration conf = new Configuration(); + conf.setInt(HttpServer.HTTP_MAX_THREADS, 10); + server = createTestServer(conf); server.addServlet("echo", "/echo", EchoServlet.class); server.addServlet("echomap", "/echomap", EchoMapServlet.class); server.addServlet("htmlcontent", "/htmlcontent", HtmlContentServlet.class); @@ -161,7 +161,8 @@ public class TestHttpServer extends HttpServerFunctionalTest { assertEquals("a:b\nc:d\n", readOutput(new URL(baseUrl, "/echo?a=b&c=d"))); int serverThreads = server.webServer.getThreadPool().getThreads(); - assertTrue(serverThreads <= MAX_THREADS); + assertTrue("More threads are started than expected, Server Threads count: " + + serverThreads, serverThreads <= MAX_THREADS); System.out.println("Number of threads = " + serverThreads + " which is less or equal than the max = " + MAX_THREADS); } catch (Exception e) {