java.lang.IllegalArgumentException: port out of range:80001

hc-dev | Oleg Kalnichevski (JIRA) | 8 years ago
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    The HttpClient throws NullPointerException in the main thread when an invalid port (like 80001) is used in the URL. An IllegalArgumentException is thrown in TimeoutGuard thread. Exception in thread "Timeout guard" java.lang.IllegalArgumentException: port out of range:80001 at<init>( at<init>( at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket( at org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$1.doit( at org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$ at Exception in thread "main" java.lang.NullPointerException at at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$ at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry( at org.apache.commons.httpclient.HttpMethodDirector.executeMethod( at org.apache.commons.httpclient.HttpClient.executeMethod( at org.apache.commons.httpclient.HttpClient.executeMethod( at$PoolingHttpConnector.doGet( at It should throw a checked exception in main thread so caller can handle the error condition more gracefully. The test program is attached. This is caused by a race condition and it's not always reproducible. Running in debugger shows a different behavior. package; import; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.params.HttpConnectionManagerParams; public class HttpTest { public static void main(String[] args) { PoolingHttpConnector conn = new PoolingHttpConnector(); try { String response = conn.doGet(""); System.out.println("Response='" + response + "'"); } catch (IOException e) { e.printStackTrace(); } } static class PoolingHttpConnector { public static final int MAX_TOTAL_CONNECTIONS = 16; public static final int MAX_CONNECTIONS_PER_HOST = 8; public static final int CONNECT_TIMEOUT = 5000; public static final int SOCKET_TIMEOUT = 5000; public static final boolean TCP_NO_DELAY = true; private static MultiThreadedHttpConnectionManager poolManager; private static HttpConnectionManagerParams httpParams; private static HttpClient httpClient; private static boolean initialized = false; public PoolingHttpConnector() { initialize(); } public String doGet(String url) throws IOException { GetMethod method = new GetMethod(url); try { int status = httpClient.executeMethod(method); String response = new String(method.getResponseBody()); if (status != HttpStatus.SC_OK) throw new IOException("HTTP error: " + response); return response; } finally { method.releaseConnection(); } } private synchronized void initialize() { if (initialized) return; poolManager = new MultiThreadedHttpConnectionManager(); httpParams = new HttpConnectionManagerParams(); httpParams.setMaxTotalConnections(MAX_TOTAL_CONNECTIONS); httpParams.setDefaultMaxConnectionsPerHost(MAX_CONNECTIONS_PER_HOST); httpParams.setTcpNoDelay(TCP_NO_DELAY); httpParams.setSoTimeout(SOCKET_TIMEOUT); httpParams.setConnectionTimeout(CONNECT_TIMEOUT); poolManager.setParams(httpParams); httpClient = new HttpClient(poolManager); initialized = true; } } }

    Apache's JIRA Issue Tracker | 8 years ago | Zhihong Zhang
    java.lang.IllegalArgumentException: port out of range:80001
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    [jira] Created: (HTTPCLIENT-813) HttpClient throws NPE on Invalid Port when used with MultiThreadedHttpConnectionManager

    hc-dev | 8 years ago | Zhihong Zhang (JIRA)
    java.lang.IllegalArgumentException: port out of range:80001
  4. 0

    [jira] Updated: (HTTPCLIENT-813) HttpClient throws NPE on Invalid Port when used with MultiThreadedHttpConnectionManager

    hc-dev | 8 years ago | Zhihong Zhang (JIRA)
    java.lang.IllegalArgumentException: port out of range:80001

    2 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      port out of range:80001

    2. Java RT
      2 frames
    3. HttpClient
      1. org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(
      2. org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$1.doit(
      3. org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory$
      3 frames
    4. Java RT
      1 frame