title: URL set Connection Timeout is not working
body: <p>I am using rss feeds to get latest news
   and i get a XML response back </p>
  
  <p>The issue i am facng is that in case if it takes longer than 5 seconds i just want the program to be stopped 
  this is my code (for testing purpose i have set time to 1 second)</p>
  
  <pre><code>public static void main(String args[]) {
       Connection dbConnection = null;
       PreparedStatement inserpstmt = null;
       try {
        final JSONArray latestnews = new JSONArray();
        builder = getDocumentBuilderInstance();
        final URL url = new URL("http://www.rssmix.com/u/8171434/rss.xml");
        url.openConnection().setConnectTimeout(1000);
        url.openConnection().setReadTimeout(1000);
        final Document doc = builder.parse(url.openStream());
        final NodeList items = doc.getElementsByTagName("item");
        for (int i = 0; i &lt; items.getLength(); i++) {
         final Element item = (Element) items.item(i);
         final String title = getValue(item, "title");
         System.out.println(title);
        }
       } catch (Exception e) {
        e.printStackTrace();
        e.getMessage();
       } catch (Throwable e) {
        e.getMessage();
        e.printStackTrace();
       } finally {
       }
      }
  </code></pre>
  
  <p>But could you please let me know why this isn't being stopped and waiting for more than 1 second</p>
  
  <p><strong>Edited Code</strong></p>
  
  <pre><code>StringBuffer sb = new StringBuffer("http://www.rssmix.com/u/8171434/rss.xml");
              URLConnection conn = new URL(sb.toString()).openConnection();
              conn.setConnectTimeout(7000);
              conn.setReadTimeout(7000);
              final   Document doc = builder.parse(new InputSource(conn.getInputStream()));
  </code></pre>