title: Optional method parameter in Java
body: <p>I have this function <code>httpGet()</code> which calls <code>http()</code>:</p>
  
  <pre><code>public static int httpGet(String url, StringBuilder response) throws IOException {
      return http(url,(http)-&gt;http.setRequestMethod("GET"), response);
  }
  
  private static int http(String url, httpMethod method, StringBuilder response) throws IOException {
      HttpURLConnection http = (HttpURLConnection)new URL(url).openConnection();
      http.setConnectTimeout(5000);
      http.setReadTimeout(5000);
      method.doMethod(http);
      int status = 404;
      ......
      ......
      return status;
  }
  </code></pre>
  
  <p>I want to add an additional parameter for <code>readTimeout</code>, which needs to be optional with a default value that will be used otherwise. </p>
  
  <p>In this case <code>readTimeout</code> is set to 5000 for all the calls, but I want this specific call to be executed for longer timeouts.</p>
  
  <p><strong>I think I need this new parameter to be optional as I don't want to change the implementations where this <code>http()</code> method has been called.</strong></p>
  
  <p>This is how I call it:</p>
  
  <pre><code>Assert.assertEquals(HTTP_OK, httpGet(DEFAULT_BROWSCAP_ENDPOINT, result));
  </code></pre>
  
  <p>How can I implement a new optional parameter for <code>readTimeout</code>?</p>