From 750f4ef44dea9b12c41fedc326a6cf6e71bb56a4 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 15 Jul 2013 08:40:31 +0000
Subject: [PATCH] Created NullOutputStream.wrapOrNullStream() and used it in all tools instead of duplicating the null checks everywhere.
---
opends/src/server/org/opends/server/tools/ConfigureDS.java | 22 ++++------------------
1 files changed, 4 insertions(+), 18 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/ConfigureDS.java b/opends/src/server/org/opends/server/tools/ConfigureDS.java
index 611cb95..2bbc4e0 100644
--- a/opends/src/server/org/opends/server/tools/ConfigureDS.java
+++ b/opends/src/server/org/opends/server/tools/ConfigureDS.java
@@ -23,12 +23,9 @@
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
- * Portions copyright 2012 ForgeRock AS.
+ * Portions copyright 2012-2013 ForgeRock AS.
*/
package org.opends.server.tools;
-import org.opends.messages.Message;
-
-
import java.net.InetAddress;
import java.security.GeneralSecurityException;
@@ -43,6 +40,7 @@
import javax.crypto.Cipher;
+import org.opends.messages.Message;
import org.opends.server.admin.DefaultBehaviorProvider;
import org.opends.server.admin.DefinedDefaultBehaviorProvider;
import org.opends.server.admin.StringPropertyDefinition;
@@ -83,8 +81,6 @@
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.tools.ToolConstants.*;
-
-
/**
* This class provides a very basic tool that can be used to configure some of
* the most important settings in the Directory Server. This configuration is
@@ -211,19 +207,9 @@
StringArgument certNickName;
StringArgument keyManagerPath;
StringArgument serverRoot;
- PrintStream out, err;
+ PrintStream out = NullOutputStream.wrapOrNullStream(outStream);
+ PrintStream err = NullOutputStream.wrapOrNullStream(errStream);
- if (outStream != null) {
- out = new PrintStream(outStream);
- } else {
- out = NullOutputStream.printStream();
- }
-
- if (errStream != null) {
- err = new PrintStream(errStream);
- } else {
- err = NullOutputStream.printStream();
- }
Message toolDescription = INFO_CONFIGDS_TOOL_DESCRIPTION.get();
ArgumentParser argParser = new ArgumentParser(CLASS_NAME, toolDescription,
false);
--
Gitblit v1.10.0