# HG changeset patch # User chegar # Date 1298552279 0 # Node ID 5a1f8762116588ba00df2f0c2b22ff6fae408891 # Parent ded72ac070ec4c53c9cd57340c5e651dfb95861e 7020136: java/net/URLConnection/RedirectLimit.java fails intermittently Summary: Increase the socket timeout and clean up the test Reviewed-by: alanb diff -r ded72ac070ec -r 5a1f87621165 jdk/test/java/net/URLConnection/RedirectLimit.java --- a/jdk/test/java/net/URLConnection/RedirectLimit.java Wed Feb 23 22:54:47 2011 -0800 +++ b/jdk/test/java/net/URLConnection/RedirectLimit.java Thu Feb 24 12:57:59 2011 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,105 +36,81 @@ import java.net.*; class RedirLimitServer extends Thread { + static final int TIMEOUT = 10 * 1000; + static final int NUM_REDIRECTS = 9; - ServerSocket s; - Socket s1; - InputStream is; - OutputStream os; - int port; - int nredirects = 9; - - String reply1 = "HTTP/1.1 307 Temporary Redirect\r\n" + + static final String reply1 = "HTTP/1.1 307 Temporary Redirect\r\n" + "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" + "Server: Apache/1.3.14 (Unix)\r\n" + "Location: http://localhost:"; - String reply2 = ".html\r\n" + + static final String reply2 = ".html\r\n" + "Connection: close\r\n" + "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" + "Hello"; - - RedirLimitServer (ServerSocket y) { - s = y; - port = s.getLocalPort(); - } - - String reply3 = "HTTP/1.1 200 Ok\r\n" + + static final String reply3 = "HTTP/1.1 200 Ok\r\n" + "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" + "Server: Apache/1.3.14 (Unix)\r\n" + "Connection: close\r\n" + "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" + "World"; - public void run () { + final ServerSocket ss; + final int port; + + RedirLimitServer(ServerSocket ss) { + this.ss = ss; + port = ss.getLocalPort(); + } + + public void run() { try { - s.setSoTimeout (2000); - for (int i=0; i