diff options
Diffstat (limited to 'server')
3 files changed, 28 insertions, 27 deletions
diff --git a/server/src/main/java/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java b/server/src/main/java/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java index a087a1ed31..79d87f960a 100644 --- a/server/src/main/java/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java +++ b/server/src/main/java/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java @@ -85,9 +85,8 @@ public class SASSAddonImportFileCreator { LocationInfo info = ClassPathExplorer .getAvailableWidgetSetsAndStylesheets(); - try { - PrintStream printStream = new PrintStream( - new FileOutputStream(addonImports)); + try (PrintStream printStream = new PrintStream( + new FileOutputStream(addonImports))) { printStream.println("/* " + ADDON_IMPORTS_FILE_TEXT + " */"); diff --git a/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java b/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java index a3375585c7..5659ec7c56 100644 --- a/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java +++ b/server/src/test/java/com/vaadin/tests/server/ClassesSerializableTest.java @@ -352,15 +352,16 @@ public class ClassesSerializableTest { private Collection<String> findClassesInJar(File file) throws IOException { Collection<String> classes = new ArrayList<>(); - JarFile jar = new JarFile(file); - Enumeration<JarEntry> e = jar.entries(); - while (e.hasMoreElements()) { - JarEntry entry = e.nextElement(); - if (entry.getName().endsWith(".class")) { - String nameWithoutExtension = entry.getName() - .replaceAll("\\.class", ""); - String className = nameWithoutExtension.replace('/', '.'); - classes.add(className); + try (JarFile jar = new JarFile(file)) { + Enumeration<JarEntry> e = jar.entries(); + while (e.hasMoreElements()) { + JarEntry entry = e.nextElement(); + if (entry.getName().endsWith(".class")) { + String nameWithoutExtension = entry.getName() + .replaceAll("\\.class", ""); + String className = nameWithoutExtension.replace('/', '.'); + classes.add(className); + } } } return classes; diff --git a/server/src/test/java/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java b/server/src/test/java/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java index 14b839be6a..06ae1570b2 100644 --- a/server/src/test/java/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java +++ b/server/src/test/java/com/vaadin/tests/server/SimpleMultiPartInputStreamTest.java @@ -22,22 +22,23 @@ public class SimpleMultiPartInputStreamTest { protected void checkBoundaryDetection(byte[] input, String boundary, byte[] expected) throws Exception { ByteArrayInputStream bais = new ByteArrayInputStream(input); - SimpleMultiPartInputStream smpis = new SimpleMultiPartInputStream(bais, - boundary); - ByteArrayOutputStream resultStream = new ByteArrayOutputStream(); - int outbyte; - try { - while ((outbyte = smpis.read()) != -1) { - resultStream.write(outbyte); + try (SimpleMultiPartInputStream smpis = new SimpleMultiPartInputStream(bais, + boundary)) { + ByteArrayOutputStream resultStream = new ByteArrayOutputStream(); + int outbyte; + try { + while ((outbyte = smpis.read()) != -1) { + resultStream.write(outbyte); + } + } catch (IOException e) { + throw new IOException( + e.getMessage() + "; expected " + new String(expected) + + " but got " + resultStream.toString()); + } + if (!Arrays.equals(expected, resultStream.toByteArray())) { + throw new Exception("Mismatch: expected " + new String(expected) + + " but got " + resultStream.toString()); } - } catch (IOException e) { - throw new IOException( - e.getMessage() + "; expected " + new String(expected) - + " but got " + resultStream.toString()); - } - if (!Arrays.equals(expected, resultStream.toByteArray())) { - throw new Exception("Mismatch: expected " + new String(expected) - + " but got " + resultStream.toString()); } } |