Bug 527352 - Use URLConnection.setConnectTimeout method directly
Bundle requires Java 1.8 so no need for reflection to use it.
Change-Id: Idd70b25e97f9c435f30cd2bb538d41d159773c43
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/org.eclipse.ui.intro/src/org/eclipse/ui/intro/contentproviders/EclipseRSSViewer.java b/org.eclipse.ui.intro/src/org/eclipse/ui/intro/contentproviders/EclipseRSSViewer.java
index fa50f2b..23cbc72 100644
--- a/org.eclipse.ui.intro/src/org/eclipse/ui/intro/contentproviders/EclipseRSSViewer.java
+++ b/org.eclipse.ui.intro/src/org/eclipse/ui/intro/contentproviders/EclipseRSSViewer.java
@@ -15,7 +15,6 @@
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@@ -498,7 +497,7 @@
URLConnection conn = url.openConnection();
// set connection timeout to 6 seconds
- setTimeout(conn, SOCKET_TIMEOUT); // Connection timeout to 6 seconds
+ conn.setConnectTimeout(SOCKET_TIMEOUT); // Connection timeout to 6 seconds
conn.connect();
try (InputStream in = url.openStream()) {
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
@@ -517,17 +516,6 @@
}
}
-
- private void setTimeout(URLConnection conn, int milliseconds) {
- Class<? extends URLConnection> conClass = conn.getClass();
- try {
- Method timeoutMethod = conClass.getMethod(
- "setConnectTimeout", new Class[]{ int.class } ); //$NON-NLS-1$
- timeoutMethod.invoke(conn, new Object[] { Integer.valueOf(milliseconds)} );
- } catch (Exception e) {
- // If running on a 1.4 JRE an exception is expected, fall through
- }
- }
}
private class TimeoutThread extends Thread