opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Controls.java
@@ -94,6 +94,7 @@ * specific credentials to connect, and ensure that your application has access * to use the LDAP controls needed. */ @SuppressWarnings("resource") public final class Controls { /** opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java
@@ -38,6 +38,7 @@ /** * Demonstrates accessing server information about capabilities and schema. */ @SuppressWarnings("resource") public final class GetInfo { // Connection information private static String host; opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java
@@ -50,6 +50,7 @@ * <baseDN> <scope> <filter> [<attibute> <attribute> ...] * </pre> */ @SuppressWarnings("resource") public final class Search { /** * Main method. opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/StaticUtils.java
@@ -30,6 +30,8 @@ import static org.forgerock.opendj.ldap.CoreMessages.ERR_HEX_DECODE_INVALID_CHARACTER; import static org.forgerock.opendj.ldap.CoreMessages.ERR_HEX_DECODE_INVALID_LENGTH; import java.io.Closeable; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -1144,6 +1146,24 @@ } /** * Closes the provided resources ignoring any errors which occurred. * * @param resources * The resources to be closed, which may be {@code null}. */ public static void closeSilently(Closeable... resources) { for (Closeable r : resources) { try { if (r != null) { r.close(); } } catch (IOException ignored) { // Ignore. } } } /** * Attempts to compress the data in the provided source array into the given * destination array. If the compressed data will fit into the destination * array, then this method will return the number of bytes of compressed opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Matcher.java
@@ -22,6 +22,7 @@ * * * Copyright 2009 Sun Microsystems, Inc. * Portions copyright 2012 ForgeRock AS. */ package org.forgerock.opendj.ldap; @@ -559,6 +560,8 @@ switch (matches(v, rule, assertion)) { case TRUE: return ConditionResult.TRUE; case FALSE: continue; case UNDEFINED: r = ConditionResult.UNDEFINED; } opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIFChangeRecordReader.java
@@ -107,6 +107,7 @@ */ public static ChangeRecord valueOfLDIFChangeRecord(final String... ldifLines) { // LDIF change record reader is tolerant to missing change types. @SuppressWarnings("resource") final LDIFChangeRecordReader reader = new LDIFChangeRecordReader(ldifLines); try { if (!reader.hasNext()) { opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/LDIFEntryReader.java
@@ -74,6 +74,7 @@ * If {@code ldifLines} was {@code null}. */ public static Entry valueOfLDIFEntry(final String... ldifLines) { @SuppressWarnings("resource") final LDIFEntryReader reader = new LDIFEntryReader(ldifLines); try { if (!reader.hasNext()) { opendj3/opendj-ldap-sdk/src/test/java/com/forgerock/opendj/ldap/DefaultTCPNIOTransportTestCase.java
@@ -22,6 +22,7 @@ * * * Copyright 2010 Sun Microsystems, Inc. * Portions copyright 2012 ForgeRock AS. */ package com.forgerock.opendj.ldap; @@ -57,10 +58,14 @@ // Establish a socket connection to see if the transport factory works. final Socket socket = new Socket(); socket.connect(socketAddress); try { socket.connect(socketAddress); // Successfully connected if there is no exception. assertTrue(socket.isConnected()); // Don't stop the transport because it is shared with the ldap server. // Successfully connected if there is no exception. assertTrue(socket.isConnected()); // Don't stop the transport because it is shared with the ldap server. } finally { socket.close(); } } } opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/AbstractAsynchronousConnectionTestCase.java
@@ -60,7 +60,7 @@ * Unit test for AbstractAsynchronousConnection. The tests verify that all * synchronous operation methods delegate to the equivalent asynchronous method. */ @SuppressWarnings("javadoc") @SuppressWarnings({ "javadoc", "resource" }) public class AbstractAsynchronousConnectionTestCase extends SdkTestCase { private final class MockConnection extends AbstractAsynchronousConnection { opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/EntryTestCase.java
@@ -43,7 +43,7 @@ /** * Test {@code Entry}. */ @SuppressWarnings("javadoc") @SuppressWarnings({ "javadoc", "resource" }) public final class EntryTestCase extends SdkTestCase { private static interface EntryFactory { opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentGroup.java
@@ -37,7 +37,7 @@ /** * Class for organizing options into logical groups when arguement usage is * printed. To use an argument group, create an instance and use * {@link ArgumentParser#addArgument(Argument, ArgumentGroup)} * {@code ArgumentParser#addArgument(Argument, ArgumentGroup)} * when adding arguments for to the parser. */ final class ArgumentGroup implements Comparable<ArgumentGroup> { opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -30,6 +30,7 @@ import static com.forgerock.opendj.ldap.tools.ToolConstants.*; import static com.forgerock.opendj.ldap.tools.ToolsMessages.*; import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode; import static com.forgerock.opendj.util.StaticUtils.closeSilently; import java.io.FileInputStream; import java.io.IOException; @@ -231,6 +232,7 @@ return verbose.isPresent(); } @SuppressWarnings("resource") private int run(final String[] args) { // Create the command-line argument parser for use with this // program. @@ -471,8 +473,8 @@ writer = new LDIFEntryWriter(getOutputStream()); final VisitorImpl visitor = new VisitorImpl(); ChangeRecordReader reader = null; try { ChangeRecordReader reader; if (filename.isPresent()) { try { reader = new LDIFChangeRecordReader(new FileInputStream(filename.getValue())); @@ -503,9 +505,7 @@ return ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue(); } } finally { if (connection != null) { connection.close(); } closeSilently(reader, connection); } return ResultCode.SUCCESS.intValue(); opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
@@ -30,6 +30,7 @@ import static com.forgerock.opendj.ldap.tools.ToolConstants.*; import static com.forgerock.opendj.ldap.tools.ToolsMessages.*; import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode; import static com.forgerock.opendj.util.StaticUtils.closeSilently; import java.io.BufferedReader; import java.io.FileReader; @@ -220,6 +221,7 @@ return verbose.isPresent(); } @SuppressWarnings("resource") private int run(final String[] args, final boolean returnMatchingEntries) { // Create the command-line argument parser for use with this // program. @@ -833,10 +835,8 @@ // We don't actually need to open a connection or perform the // search, so we're done. We should return 0 to either mean that the // processing was successful or that there were no matching entries, // based // on countEntries.isPresent() (but in either case the return value // should // be zero). // based on countEntries.isPresent() (but in either case the return value // should be zero). return 0; } @@ -946,7 +946,7 @@ } catch (final ErrorResultException ere) { return Utils.printErrorMessage(this, ere); } finally { connection.close(); closeSilently(ldifWriter, connection); } return 0;