### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/JavaElement.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaElement.java,v retrieving revision 1.140 diff -u -r1.140 JavaElement.java --- model/org/eclipse/jdt/internal/core/JavaElement.java 18 Jan 2011 09:36:56 -0000 1.140 +++ model/org/eclipse/jdt/internal/core/JavaElement.java 19 Jan 2011 06:42:35 -0000 @@ -14,6 +14,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Method; import java.net.JarURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; @@ -733,9 +734,21 @@ try { URL docUrl = new URL(docUrlValue); URLConnection connection = docUrl.openConnection(); - String timeoutVal = "10000"; //$NON-NLS-1$ - System.setProperty("sun.net.client.defaultConnectTimeout", timeoutVal); //$NON-NLS-1$ - System.setProperty("sun.net.client.defaultReadTimeout", timeoutVal); //$NON-NLS-1$ + Class[] parameterTypes = new Class[]{int.class}; + Integer timeoutVal = new Integer(10000); + try { + // set the connect and read timeouts using reflection since these methods are not available in java 1.4 + Class URLClass = Class.forName("java.net.URLConnection"); //$NON-NLS-1$ + Method connectTimeoutMethod = URLClass.getDeclaredMethod("setConnectTimeout", parameterTypes); //$NON-NLS-1$ + Method readTimeoutMethod = URLClass.getDeclaredMethod("setReadTimeout", parameterTypes); //$NON-NLS-1$ + connectTimeoutMethod.invoke(connection, new Object[]{timeoutVal}); + readTimeoutMethod.invoke(connection, new Object[]{timeoutVal}); + } catch (Exception e) { + // setConnectTimeout() or setReadTimeout() not found. Set system wide timeout property + System.setProperty("sun.net.client.defaultConnectTimeout", timeoutVal.toString()); //$NON-NLS-1$ + System.setProperty("sun.net.client.defaultReadTimeout", timeoutVal.toString()); //$NON-NLS-1$ + } + if (connection instanceof JarURLConnection) { connection2 = (JarURLConnection) connection; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=156307