### 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 13:56:22 -0000 @@ -14,6 +14,8 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.net.JarURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; @@ -733,9 +735,27 @@ 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); + // set the connect and read timeouts using reflection since these methods are not available in java 1.4 + Class URLClass = connection.getClass(); + try { + 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 (SecurityException e) { + // ignore + } catch (IllegalArgumentException e) { + // ignore + } catch (NoSuchMethodException e) { + // ignore + } catch (IllegalAccessException e) { + // ignore + } catch (InvocationTargetException e) { + // ignore + } + if (connection instanceof JarURLConnection) { connection2 = (JarURLConnection) connection; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=156307