You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2022/09/15 02:50:49 UTC
[directory-server] branch master updated: Removed some printStackTrace calls (DIRSERVER-1589)
This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git
The following commit(s) were added to refs/heads/master by this push:
new e9baba3a22 Removed some printStackTrace calls (DIRSERVER-1589)
e9baba3a22 is described below
commit e9baba3a220f965ac38ecf713d89644988b8b915
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Thu Sep 15 04:50:23 2022 +0200
Removed some printStackTrace calls (DIRSERVER-1589)
---
.../apache/directory/server/core/avltree/ArrayMarshaller.java | 11 +++++++++--
i18n/src/main/java/org/apache/directory/server/i18n/I18n.java | 4 +++-
.../org/apache/directory/server/i18n/errors.properties | 1 +
.../directory/server/dhcp/protocol/DhcpProtocolHandler.java | 1 -
4 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java b/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
index 6dffa4d2b2..9913eef517 100644
--- a/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
+++ b/core-avl/src/main/java/org/apache/directory/server/core/avltree/ArrayMarshaller.java
@@ -27,8 +27,11 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Comparator;
+import org.apache.directory.api.ldap.model.constants.Loggers;
import org.apache.directory.api.util.Strings;
import org.apache.directory.server.i18n.I18n;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -39,6 +42,9 @@ import org.apache.directory.server.i18n.I18n;
@SuppressWarnings("unchecked")
public class ArrayMarshaller<E> implements Marshaller<ArrayTree<E>>
{
+ /** A dedicated log for cursors */
+ private static final Logger LOG_CURSOR = LoggerFactory.getLogger( Loggers.CURSOR_LOG.getName() );
+
/** used for serialized form of an empty AvlTree */
private static final byte[] EMPTY_TREE = new byte[1];
@@ -118,7 +124,7 @@ public class ArrayMarshaller<E> implements Marshaller<ArrayTree<E>>
}
catch ( IOException e )
{
- e.printStackTrace();
+ LOG_CURSOR.error( I18n.err( I18n.ERR_752_CANNOT_SERIALIZE_TREE, e.getMessage() ) );
}
return data;
@@ -153,6 +159,7 @@ public class ArrayMarshaller<E> implements Marshaller<ArrayTree<E>>
if ( startByte != 0 )
{
+ LOG_CURSOR.error( I18n.err( I18n.ERR_440 ) );
throw new IOException( I18n.err( I18n.ERR_440 ) );
}
@@ -178,7 +185,7 @@ public class ArrayMarshaller<E> implements Marshaller<ArrayTree<E>>
}
catch ( NullPointerException npe )
{
- System.out.println( I18n.err( I18n.ERR_441, Strings.dumpBytes( data ) ) );
+ LOG_CURSOR.error( I18n.err( I18n.ERR_441, Strings.dumpBytes( data ) ) );
throw npe;
}
}
diff --git a/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java b/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java
index 8cf3b4df33..49ccb0749d 100644
--- a/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java
+++ b/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java
@@ -785,7 +785,9 @@ public enum I18n
ERR_748("ERR_748"),
ERR_749("ERR_749"),
ERR_750("ERR_750"),
- ERR_751("ERR_751");
+ ERR_751("ERR_751"),
+ ERR_752_CANNOT_SERIALIZE_TREE("ERR_752_CANNOT_SERIALIZE_TREE");
+
private static final ResourceBundle ERR_BUNDLE = ResourceBundle
.getBundle( "org.apache.directory.server.i18n.errors", Locale.ROOT );
diff --git a/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties b/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
index 70959b29d8..2a56945dd1 100644
--- a/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
+++ b/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties
@@ -773,3 +773,4 @@ ERR_748=Invalid log file bufferSize/ max size is sepcified bufferSize {0} logFil
ERR_749=Log Scanner is already closed
ERR_750=Log content is invalid
ERR_751=Invalid TrustManager Class {0}
+ERR_752_CANNOT_SERIALIZE_TREE=Error while serializing the tree: {0}
diff --git a/protocol-dhcp/src/main/java/org/apache/directory/server/dhcp/protocol/DhcpProtocolHandler.java b/protocol-dhcp/src/main/java/org/apache/directory/server/dhcp/protocol/DhcpProtocolHandler.java
index a90c61e356..3ce37583be 100644
--- a/protocol-dhcp/src/main/java/org/apache/directory/server/dhcp/protocol/DhcpProtocolHandler.java
+++ b/protocol-dhcp/src/main/java/org/apache/directory/server/dhcp/protocol/DhcpProtocolHandler.java
@@ -108,7 +108,6 @@ public class DhcpProtocolHandler extends IoHandlerAdapter
public void exceptionCaught( IoSession session, Throwable cause )
{
LOG.error( "EXCEPTION CAUGHT ", cause );
- cause.printStackTrace( System.out );
session.closeNow();
}