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/LDAPSearch.java | 30 ++++++------------------------
1 files changed, 6 insertions(+), 24 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/LDAPSearch.java b/opends/src/server/org/opends/server/tools/LDAPSearch.java
index 575c0dc..c558034 100644
--- a/opends/src/server/org/opends/server/tools/LDAPSearch.java
+++ b/opends/src/server/org/opends/server/tools/LDAPSearch.java
@@ -23,11 +23,9 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2012 ForgeRock AS.
+ * Portions Copyright 2012-2013 ForgeRock AS
*/
package org.opends.server.tools;
-import org.opends.admin.ads.util.ConnectionUtils;
-import org.opends.messages.Message;
import java.io.BufferedReader;
import java.io.FileReader;
@@ -37,7 +35,10 @@
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
+import org.opends.admin.ads.util.ConnectionUtils;
+import org.opends.messages.Message;
import org.opends.server.controls.*;
+import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.ldap.*;
import org.opends.server.util.Base64;
import org.opends.server.util.EmbeddedUtils;
@@ -53,7 +54,6 @@
import org.opends.server.types.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
-import org.opends.server.loggers.debug.DebugTracer;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
@@ -61,7 +61,6 @@
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.tools.ToolConstants.*;
-
/**
* This class provides a tool that can be used to issue search requests to the
* Directory Server.
@@ -645,25 +644,8 @@
boolean returnMatchingEntries, OutputStream outStream,
OutputStream errStream)
{
- PrintStream out;
- if (outStream == null)
- {
- out = NullOutputStream.printStream();
- }
- else
- {
- out = new PrintStream(outStream);
- }
-
- PrintStream err;
- if (errStream == null)
- {
- err = NullOutputStream.printStream();
- }
- else
- {
- err = new PrintStream(errStream);
- }
+ PrintStream out = NullOutputStream.wrapOrNullStream(outStream);
+ PrintStream err = NullOutputStream.wrapOrNullStream(errStream);
LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions();
LDAPSearchOptions searchOptions = new LDAPSearchOptions();
--
Gitblit v1.10.0