diff options
author | Alexander Kurtakov | 2020-01-13 10:33:31 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2020-01-13 10:33:31 +0000 |
commit | 3ee6b6b032dcf9bdd5380d6469f8874368ddb44a (patch) | |
tree | b0c82e25e95b6799f856d1b18b425f9ff7baee75 | |
parent | 890f62e121fbde1b3f7c6f17b3d42c4b72c0ce92 (diff) | |
download | eclipse.platform.ua-3ee6b6b032dcf9bdd5380d6469f8874368ddb44a.tar.gz eclipse.platform.ua-3ee6b6b032dcf9bdd5380d6469f8874368ddb44a.tar.xz eclipse.platform.ua-3ee6b6b032dcf9bdd5380d6469f8874368ddb44a.zip |
Bug 559097 - Compile warnings in I20200113-0130
Fix platform.ua. Warnings in places where dealing with
ServletResponse.getWriter are just suppressed as writer shouldn't be
closed in this places.
Change-Id: I2d18b200ec008f05aa67fa07cd22da18c6360d2e
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
3 files changed, 10 insertions, 7 deletions
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ControlServlet.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ControlServlet.java index 5ee40aa7b..d9cd13d3d 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ControlServlet.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/ControlServlet.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -134,6 +134,7 @@ public class ControlServlet extends HttpServlet { processRequest(req, resp); } + @SuppressWarnings("resource") private void processRequest(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/Utils.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/Utils.java index 2229c3e63..d8d693045 100644 --- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/Utils.java +++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/utils/Utils.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2017 IBM Corporation and others. + * Copyright (c) 2011, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -46,9 +46,9 @@ public class Utils { if (is != null) { Writer writer = new StringWriter(); char[] buffer = new char[1024]; - try { - Reader reader = new BufferedReader( - new InputStreamReader(is, StandardCharsets.UTF_8)); + try (Reader reader = new BufferedReader( + new InputStreamReader(is, StandardCharsets.UTF_8))){ + int n; while ((n = reader.read(buffer)) != -1) { writer.write(buffer, 0, n); diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java index 154b1021e..5c7dc1d32 100644 --- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java +++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 IBM Corporation and others. + * Copyright (c) 2005, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -34,7 +34,9 @@ public class FileUtil { public static String getContents(Bundle bundle, String relativePath) throws IOException { URL url = bundle.getEntry(relativePath); if (url != null) { - return readString(url.openStream()); + try (InputStream is = url.openStream()) { + return readString(is); + } } return null; } |