Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2016-02-22 08:41:27 +0000
committerAlexander Kurtakov2016-02-22 08:41:27 +0000
commite39b66d631026d5041e0f9133ea988e6af2ab07c (patch)
treeb023a342e4e50aa5c1872629b3746ebfeb035ca2 /org.eclipse.ua.tests/help
parent1a625b9f63bd91ca3e813d9877735815ab7cb5fc (diff)
downloadeclipse.platform.ua-e39b66d631026d5041e0f9133ea988e6af2ab07c.tar.gz
eclipse.platform.ua-e39b66d631026d5041e0f9133ea988e6af2ab07c.tar.xz
eclipse.platform.ua-e39b66d631026d5041e0f9133ea988e6af2ab07c.zip
Bug 488193 - Use try-with-resources in o.e.help.base
Ensuring all resources are freed when no longer used is always good practice. This warning is enabled and after the move to Java 1.7 codebase has to be cleaned. Change-Id: I38103ad47605a48c9491f44d0bb492303324dae6 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.ua.tests/help')
-rw-r--r--org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/HelpServerBinding.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/HelpServerBinding.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/HelpServerBinding.java
index 8772ca3f9..8a5867bf9 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/HelpServerBinding.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/HelpServerBinding.java
@@ -93,16 +93,15 @@ public class HelpServerBinding {
}
private boolean canAccessServer(String host) throws Exception {
- InputStream input;
try {
int port = WebappManager.getPort();
URL url = new URL("http", host, port, "/help/index.jsp");
URLConnection connection = url.openConnection();
setTimeout(connection, 5000);
- input = connection.getInputStream();
- int firstbyte = input.read();
- input.close();
- return firstbyte > 0;
+ try (InputStream input = connection.getInputStream()) {
+ int firstbyte = input.read();
+ return firstbyte > 0;
+ }
} catch (Exception e) {
return false;
}

Back to the top