mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
12.21.2016 6685d9b8c8a17cfadc82faf414ee1019e9ee8f68
OPENDJ-2772 Fix bug in ldapmodify

Arguments --preReadAttributes and --postReadAttributes were ignored
because the outputstream was not closed (and so flushed) before the end
of ldapmodify execution.
2 files modified
25 ■■■■■ changed files
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java 24 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties 1 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -19,6 +19,7 @@
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.CliMessages.INFO_FILE_PLACEHOLDER;
import static com.forgerock.opendj.cli.ToolVersionHandler.newSdkVersionHandler;
import static com.forgerock.opendj.ldap.tools.LDAPToolException.newToolException;
import static com.forgerock.opendj.ldap.tools.LDAPToolException.newToolParamException;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
@@ -39,7 +40,6 @@
import java.util.List;
import java.util.StringTokenizer;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.DecodeOptions;
@@ -364,17 +364,21 @@
            reader = createLDIFChangeRecordReader(filename, argParser.getTrailingArguments());
            final VisitorImpl visitor = new VisitorImpl(connection);
            try {
                while (reader.hasNext()) {
                    final ChangeRecord cr = reader.readChangeRecord();
                    final int result = cr.accept(visitor, null);
                    if (result != 0 && !continueOnError.isPresent()) {
                        return result;
            try (final EntryWriter w = writer) {
                try {
                    while (reader.hasNext()) {
                        final ChangeRecord cr = reader.readChangeRecord();
                        final int result = cr.accept(visitor, null);
                        if (result != 0 && !continueOnError.isPresent()) {
                            return result;
                        }
                    }
                } catch (final IOException ioe) {
                    throw newToolParamException(
                            ioe, ERR_LDIF_FILE_READ_ERROR.get(filename.getValue(), ioe.getLocalizedMessage()));
                }
            } catch (final IOException ioe) {
                throw newToolParamException(
                        ioe, ERR_LDIF_FILE_READ_ERROR.get(filename.getValue(), ioe.getLocalizedMessage()));
            } catch (final IOException e) {
                throw newToolException(e, ResultCode.UNDEFINED, ERR_LDAP_MODIFY_WRITTING_ENTRIES.get(e.getMessage()));
            }
        } finally {
            closeSilently(reader);
opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties
@@ -290,6 +290,7 @@
as an exit code for the LDAP compare operations
INFO_LDIFDIFF_NO_DIFFERENCES=No differences were detected between the \
 source and target LDIF files
ERR_LDAP_MODIFY_WRITTING_ENTRIES=Unable to write entries on the output because '%s'
 #
 # MakeLDIF tool
 #