Repository: cxf Updated Branches: refs/heads/3.1.x-fixes 3b45e6080 -> 30ad57d55
More stream work Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/bca5ead5 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/bca5ead5 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/bca5ead5 Branch: refs/heads/3.1.x-fixes Commit: bca5ead51899b3aa4864d8b4a675c829096bcd3b Parents: 3b45e60 Author: Colm O hEigeartaigh <cohei...@apache.org> Authored: Wed Apr 27 11:40:37 2016 +0100 Committer: Colm O hEigeartaigh <cohei...@apache.org> Committed: Wed Apr 27 14:31:06 2016 +0100 ---------------------------------------------------------------------- .../org/apache/cxf/staxutils/StaxUtilsTest.java | 2 ++ .../org/apache/cxf/tools/util/PropertyUtil.java | 30 ++++++++++---------- .../tools/validator/internal/Stax2DOMTest.java | 6 ++-- 3 files changed, 20 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/bca5ead5/core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java b/core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java index 818d262..eda6049 100644 --- a/core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java +++ b/core/src/test/java/org/apache/cxf/staxutils/StaxUtilsTest.java @@ -111,6 +111,7 @@ public class StaxUtilsTest extends Assert { // write output to a string String output = baos.toString(); + baos.close(); // re-read the input xml doc to a string InputStreamReader inputStreamReader = new InputStreamReader(getTestStream(soapMessage)); @@ -123,6 +124,7 @@ public class StaxUtilsTest extends Assert { n = inputStreamReader.read(buffer); } String input = stringWriter.toString(); + stringWriter.close(); // seach for the first begin of "<soap:Envelope" to escape the apache licenses header int beginIndex = input.indexOf("<soap:Envelope"); input = input.substring(beginIndex); http://git-wip-us.apache.org/repos/asf/cxf/blob/bca5ead5/tools/common/src/main/java/org/apache/cxf/tools/util/PropertyUtil.java ---------------------------------------------------------------------- diff --git a/tools/common/src/main/java/org/apache/cxf/tools/util/PropertyUtil.java b/tools/common/src/main/java/org/apache/cxf/tools/util/PropertyUtil.java index e1e7a0a..02061cb 100644 --- a/tools/common/src/main/java/org/apache/cxf/tools/util/PropertyUtil.java +++ b/tools/common/src/main/java/org/apache/cxf/tools/util/PropertyUtil.java @@ -34,24 +34,24 @@ public class PropertyUtil { private Map<String, String> maps = new HashMap<String, String>(); public void load(InputStream is, String delim) throws IOException { - BufferedReader br = new BufferedReader(new InputStreamReader(is)); - String line = br.readLine(); - while (!StringUtils.isEmpty(line)) { - StringTokenizer st = new StringTokenizer(line, delim); - String key = null; - String value = null; - if (st.hasMoreTokens()) { - key = st.nextToken().trim(); - } - if (st.hasMoreTokens()) { - value = st.nextToken().trim(); - } + try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) { + String line = br.readLine(); + while (!StringUtils.isEmpty(line)) { + StringTokenizer st = new StringTokenizer(line, delim); + String key = null; + String value = null; + if (st.hasMoreTokens()) { + key = st.nextToken().trim(); + } + if (st.hasMoreTokens()) { + value = st.nextToken().trim(); + } - maps.put(key, value); + maps.put(key, value); - line = br.readLine(); + line = br.readLine(); + } } - br.close(); } public void load(InputStream is) throws IOException { http://git-wip-us.apache.org/repos/asf/cxf/blob/bca5ead5/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/Stax2DOMTest.java ---------------------------------------------------------------------- diff --git a/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/Stax2DOMTest.java b/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/Stax2DOMTest.java index c0b4141..7340fcc 100644 --- a/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/Stax2DOMTest.java +++ b/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/Stax2DOMTest.java @@ -83,9 +83,9 @@ public class Stax2DOMTest extends Assert { File wsdlFile = new File(getClass().getResource( "/validator_wsdl/jms_test.wsdl").toURI()); File tempFile = File.createTempFile("Stax2DOMTest", ".wsdl"); - FileOutputStream output = new FileOutputStream(tempFile); - IOUtils.copyAndCloseInput(new FileInputStream(wsdlFile), output); - output.close(); + try (FileOutputStream output = new FileOutputStream(tempFile)) { + IOUtils.copyAndCloseInput(new FileInputStream(wsdlFile), output); + } return tempFile; }