opendj-sdk/opendj-copyright-maven-plugin/src/test/java/org/forgerock/maven/UpdateCopyrightTestCase.java
@@ -21,7 +21,7 @@ * CDDL HEADER END * * * Copyright 2015 ForgeRock AS. * Copyright 2015-2016 ForgeRock AS. */ package org.forgerock.maven; @@ -36,7 +36,6 @@ import java.util.List; import org.forgerock.testng.ForgeRockTestCase; import org.forgerock.util.Utils; import org.testng.annotations.AfterTest; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -133,9 +132,7 @@ } private void checkMofidiedFile(String filePath) throws Exception { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(filePath)); try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { String mustBeRemoved = null; String expectedOutput = null; String currentLine; @@ -148,8 +145,6 @@ } } checkIfNewFileIsValid(mustBeRemoved, expectedOutput, filePath + ".tmp"); } finally { Utils.closeSilently(reader); } } @@ -159,10 +154,7 @@ return; } BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(filePath)); try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { boolean expectedOutputFound = false; String currentLine; while ((currentLine = reader.readLine()) != null) { @@ -180,8 +172,6 @@ if (!expectedOutputFound) { throw new Exception("Generated file " + filePath + " should contains " + expectedOutput); } } finally { Utils.closeSilently(reader); } } opendj-sdk/opendj-doc-maven-plugin/src/main/java/org/forgerock/opendj/maven/doc/GenerateMessageFileMojo.java
@@ -157,12 +157,8 @@ configuration = getConfiguration(); // FreeMarker takes the data and a Writer to process the template. Writer writer = null; try { writer = new PrintWriter(file); try (Writer writer = new PrintWriter(file)) { configuration.getTemplate(template).process(map, writer); } finally { closeSilently(writer); } } opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFDiff.java
@@ -21,7 +21,7 @@ * CDDL HEADER END * * * Copyright 2012-2013 ForgeRock AS * Copyright 2012-2016 ForgeRock AS * Portions Copyright 2014-2015 ForgeRock AS. */ package com.forgerock.opendj.ldap.tools; @@ -119,9 +119,6 @@ InputStream sourceInputStream = null; InputStream targetInputStream = null; OutputStream outputStream = null; LDIFEntryReader sourceReader = null; LDIFEntryReader targetReader = null; LDIFChangeRecordWriter outputWriter = null; try { // First source file. @@ -186,10 +183,11 @@ } // Perform the diff. sourceReader = new LDIFEntryReader(sourceInputStream); targetReader = new LDIFEntryReader(targetInputStream); outputWriter = new LDIFChangeRecordWriter(outputStream); LDIF.copyTo(LDIF.diff(sourceReader, targetReader), outputWriter); try (LDIFEntryReader sourceReader = new LDIFEntryReader(sourceInputStream); LDIFEntryReader targetReader = new LDIFEntryReader(targetInputStream); LDIFChangeRecordWriter outputWriter = new LDIFChangeRecordWriter(outputStream)) { LDIF.copyTo(LDIF.diff(sourceReader, targetReader), outputWriter); } } catch (final IOException e) { if (e instanceof LocalizableException) { errPrintln(ERR_LDIFDIFF_DIFF_FAILED.get(((LocalizableException) e).getMessageObject())); @@ -198,7 +196,6 @@ } return ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue(); } finally { closeSilently(sourceReader, targetReader, outputWriter); closeSilently(sourceInputStream, targetInputStream, outputStream); } opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFSearch.java
@@ -21,7 +21,7 @@ * CDDL HEADER END * * * Copyright 2012-2015 ForgeRock AS. * Copyright 2012-2016 ForgeRock AS. */ package com.forgerock.opendj.ldap.tools; @@ -191,11 +191,8 @@ if (filename.isPresent()) { // Read the filter strings. BufferedReader in = null; try { in = new BufferedReader(new FileReader(filename.getValue())); try (BufferedReader in = new BufferedReader(new FileReader(filename.getValue()))) { String line = null; while ((line = in.readLine()) != null) { if ("".equals(line.trim())) { // ignore empty lines. @@ -209,8 +206,6 @@ } catch (final IOException e) { errPrintln(LocalizableMessage.raw(e.toString())); return ResultCode.CLIENT_SIDE_FILTER_ERROR.intValue(); } finally { closeSilently(in); } } @@ -234,8 +229,6 @@ InputStream sourceInputStream = null; OutputStream outputStream = null; LDIFEntryReader sourceReader = null; LDIFEntryWriter outputWriter = null; try { // First source file. @@ -275,9 +268,10 @@ } // Perform the search. sourceReader = new LDIFEntryReader(sourceInputStream); outputWriter = new LDIFEntryWriter(outputStream); LDIF.copyTo(LDIF.search(sourceReader, search), outputWriter); try (LDIFEntryReader sourceReader = new LDIFEntryReader(sourceInputStream); LDIFEntryWriter outputWriter = new LDIFEntryWriter(outputStream)) { LDIF.copyTo(LDIF.search(sourceReader, search), outputWriter); } } catch (final IOException e) { if (e instanceof LocalizableException) { errPrintln(ERR_LDIFSEARCH_FAILED.get(((LocalizableException) e).getMessageObject())); @@ -286,7 +280,6 @@ } return ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue(); } finally { closeSilently(sourceReader, outputWriter); closeSilently(sourceInputStream, outputStream); } opendj-sdk/opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/AddRateITCase.java
@@ -21,7 +21,7 @@ * CDDL HEADER END * * * Copyright 2014-2015 ForgeRock AS. * Copyright 2014-2016 ForgeRock AS. */ package com.forgerock.opendj.ldap.tools; @@ -40,6 +40,7 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @SuppressWarnings("javadoc") public class AddRateITCase extends ToolsITCase { private static final String TEMPLATE_NAME = "addrate.template"; opendj-sdk/opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/AuthRateITCase.java
@@ -21,7 +21,7 @@ * CDDL HEADER END * * * Copyright 2014 ForgeRock AS. * Copyright 2014-2016 ForgeRock AS. */ package com.forgerock.opendj.ldap.tools; @@ -29,7 +29,6 @@ import static com.forgerock.opendj.ldap.tools.ToolsMessages.ERR_ERROR_PARSING_ARGS; import static com.forgerock.opendj.ldap.tools.ToolsMessages.INFO_TOOL_WARMING_UP; import static org.fest.assertions.Assertions.assertThat; import static org.forgerock.util.Utils.closeSilently; import java.io.PrintStream; @@ -38,6 +37,7 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @SuppressWarnings("javadoc") public class AuthRateITCase extends ToolsITCase { private static final String THROUGHPUT_TEXT = "Recent throughput (ops/second)"; @@ -70,10 +70,8 @@ ByteStringBuilder out = new ByteStringBuilder(); ByteStringBuilder err = new ByteStringBuilder(); PrintStream outStream = new PrintStream(out.asOutputStream()); PrintStream errStream = new PrintStream(err.asOutputStream()); try { try (PrintStream outStream = new PrintStream(out.asOutputStream()); PrintStream errStream = new PrintStream(err.asOutputStream())) { AuthRate authRate = new AuthRate(outStream, errStream); authRate.run(arguments); @@ -88,10 +86,7 @@ String[] authRateLineData = authRateResLines[i].split(","); assertThat(authRateLineData[authRateLineData.length - 1].trim()).isEqualTo("0.0"); } } } finally { closeSilently(outStream, errStream); } } } opendj-sdk/opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/LDAPCompareITCase.java
@@ -21,7 +21,7 @@ * CDDL HEADER END * * * Copyright 2014 ForgeRock AS. * Copyright 2014-2016 ForgeRock AS. */ package com.forgerock.opendj.ldap.tools; @@ -29,7 +29,6 @@ import static com.forgerock.opendj.ldap.tools.ToolsMessages.INFO_COMPARE_OPERATION_RESULT_FALSE; import static com.forgerock.opendj.ldap.tools.ToolsMessages.INFO_COMPARE_OPERATION_RESULT_TRUE; import static com.forgerock.opendj.ldap.tools.ToolsMessages.INFO_LDAPCOMPARE_TOOL_DESCRIPTION; import static org.forgerock.util.Utils.closeSilently; import java.io.PrintStream; import java.util.Random; @@ -40,6 +39,7 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @SuppressWarnings("javadoc") public class LDAPCompareITCase extends ToolsITCase { private static final int NB_RAND_SIMPLE_COMPARE = 10; @@ -93,16 +93,12 @@ ByteStringBuilder out = new ByteStringBuilder(); ByteStringBuilder err = new ByteStringBuilder(); PrintStream outStream = new PrintStream(out.asOutputStream()); PrintStream errStream = new PrintStream(err.asOutputStream()); try { try (PrintStream outStream = new PrintStream(out.asOutputStream()); PrintStream errStream = new PrintStream(err.asOutputStream())) { LDAPCompare ldapCompare = new LDAPCompare(outStream, errStream); ldapCompare.run(arguments); checkOuputStreams(out, err, expectedOut, expectedErr); } finally { closeSilently(outStream, errStream); } } }