From 2170acc41795b0d87c92edfd5ce99ebbcc6f7cc3 Mon Sep 17 00:00:00 2001 From: Dmitrii Tikhomirov Date: Tue, 28 Jun 2016 13:29:54 +0200 Subject: [PATCH] [ARTEMIS-603] Remove e.printStackTrace() from code --- .../org/apache/activemq/artemis/ra/ActiveMQRALogger.java | 4 ++++ .../activemq/artemis/ra/inflow/ActiveMQActivationSpec.java | 2 +- .../artemis/core/remoting/impl/invm/InVMAcceptor.java | 7 +++++-- .../artemis/core/remoting/impl/netty/NettyAcceptor.java | 7 +++++-- .../artemis/core/server/cluster/ClusterManager.java | 4 ++-- .../artemis/core/server/cluster/ha/ColocatedHAManager.java | 3 +-- .../core/server/cluster/impl/ClusterConnectionImpl.java | 4 ++-- .../artemis/core/server/impl/ActiveMQServerImpl.java | 2 +- .../artemis/core/server/impl/ColocatedActivation.java | 6 +++--- .../artemis/core/server/impl/FileLockNodeManager.java | 2 +- .../activemq/artemis/core/server/impl/InVMNodeManager.java | 3 ++- .../activemq/artemis/core/server/impl/RefsOperation.java | 2 +- .../artemis/core/server/impl/ServerSessionImpl.java | 3 +-- .../core/server/impl/SharedNothingBackupActivation.java | 1 - .../core/server/impl/SharedStoreBackupActivation.java | 2 +- 15 files changed, 30 insertions(+), 22 deletions(-) diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALogger.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALogger.java index 93a7b97c58..32316f0df6 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALogger.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALogger.java @@ -109,6 +109,10 @@ public interface ActiveMQRALogger extends BasicLogger { @Message(id = 152008, value = "Error interrupting handler on endpoint {0} handler = {1}", format = Message.Format.MESSAGE_FORMAT) void errorInterruptingHandler(String endpoint, String handler, @Cause Throwable cause); + @LogMessage(level = Logger.Level.WARN) + @Message(id = 152009, value = "Unable to validate properties", format = Message.Format.MESSAGE_FORMAT) + void unableToValidateProperties(@Cause Exception e); + @LogMessage(level = Logger.Level.ERROR) @Message(id = 154000, value = "Error while creating object Reference.", format = Message.Format.MESSAGE_FORMAT) void errorCreatingReference(@Cause Exception e); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java index 3f24300737..d9b6954222 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivationSpec.java @@ -716,7 +716,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen } } catch (IntrospectionException e) { - e.printStackTrace(); + ActiveMQRALogger.LOGGER.unableToValidateProperties(e); } if (propsNotSet.size() > 0) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java index 190a5d1718..d30b564dab 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/invm/InVMAcceptor.java @@ -40,6 +40,7 @@ import org.apache.activemq.artemis.utils.ConfigurationHelper; import org.apache.activemq.artemis.utils.ExecutorFactory; import org.apache.activemq.artemis.utils.OrderedExecutorFactory; import org.apache.activemq.artemis.utils.TypedProperties; +import org.jboss.logging.Logger; public final class InVMAcceptor extends AbstractAcceptor { @@ -69,6 +70,9 @@ public final class InVMAcceptor extends AbstractAcceptor { private final String name; + private static final Logger logger = Logger.getLogger(InVMAcceptor.class); + + public InVMAcceptor(final String name, final ClusterConnection clusterConnection, final Map configuration, @@ -164,8 +168,7 @@ public final class InVMAcceptor extends AbstractAcceptor { notificationService.sendNotification(notification); } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.warn("failed to send notification",e.getMessage(),e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java index f9484f57cb..5e04c4af03 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java @@ -77,6 +77,7 @@ import org.apache.activemq.artemis.spi.core.remoting.ServerConnectionLifeCycleLi import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.ConfigurationHelper; import org.apache.activemq.artemis.utils.TypedProperties; +import org.jboss.logging.Logger; /** * A Netty TCP Acceptor that is embedding Netty. @@ -171,6 +172,9 @@ public class NettyAcceptor extends AbstractAcceptor { private Map extraConfigs; + private static final Logger logger = Logger.getLogger(NettyAcceptor.class); + + public NettyAcceptor(final String name, final ClusterConnection clusterConnection, final Map configuration, @@ -520,8 +524,7 @@ public class NettyAcceptor extends AbstractAcceptor { notificationService.sendNotification(notification); } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + logger.warn("failed to send notification",e.getMessage(),e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java index ef39ba2fd7..17eaae091e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterManager.java @@ -520,7 +520,7 @@ public final class ClusterManager implements ActiveMQComponent { manager.stop(); } catch (Exception e) { - e.printStackTrace(); + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } @@ -562,7 +562,7 @@ public final class ClusterManager implements ActiveMQComponent { clusterConnection.stop(); } catch (Exception e) { - e.printStackTrace(); + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } clearClusterConnections(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java index 0959f728c7..c38e186519 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ha/ColocatedHAManager.java @@ -70,8 +70,7 @@ public class ColocatedHAManager implements HAManager { activeMQServer.stop(); } catch (Exception e) { - e.printStackTrace(); - //todo + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } backupServers.clear(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java index d009e79f83..800ed5ab5c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionImpl.java @@ -1478,7 +1478,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } } catch (Exception e) { - e.printStackTrace(); + ActiveMQServerLogger.LOGGER.warn(e); } } @@ -1492,7 +1492,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } } catch (Exception e) { - e.printStackTrace(); + ActiveMQServerLogger.LOGGER.warn(e.getMessage(),e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index a5886d54ae..d2d77831a0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -933,7 +933,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { serverSession.close(true); } catch (Exception e) { - e.printStackTrace(); + ActiveMQServerLogger.LOGGER.errorClosingSession(e); } } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java index b81abb7272..be2011f810 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ColocatedActivation.java @@ -29,6 +29,7 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupRequ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.BackupResponseMessage; import org.apache.activemq.artemis.core.remoting.server.RemotingService; import org.apache.activemq.artemis.core.replication.ReplicationManager; +import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.cluster.ha.ColocatedHAManager; import org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy; import org.apache.activemq.artemis.core.server.cluster.ha.HAManager; @@ -126,7 +127,7 @@ public class ColocatedActivation extends LiveActivation { started = colocatedHAManager.activateBackup(backupRequestMessage.getBackupSize(), backupRequestMessage.getJournalDirectory(), backupRequestMessage.getBindingsDirectory(), backupRequestMessage.getLargeMessagesDirectory(), backupRequestMessage.getPagingDirectory(), backupRequestMessage.getNodeID()); } catch (Exception e) { - e.printStackTrace(); + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } channel.send(new BackupResponseMessage(started)); } @@ -222,8 +223,7 @@ public class ColocatedActivation extends LiveActivation { } } catch (Exception e) { - e.printStackTrace(); - //todo + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } else { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java index 1992e8109c..1ebf82c986 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/FileLockNodeManager.java @@ -187,7 +187,7 @@ public class FileLockNodeManager extends NodeManager { setLive(); } catch (Exception e) { - e.printStackTrace(); + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } }; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java index 48f16270af..d735852cb3 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java @@ -23,6 +23,7 @@ import java.util.concurrent.Semaphore; import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException; import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.core.server.ActivateCallback; +import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.NodeManager; import org.apache.activemq.artemis.utils.UUIDGenerator; @@ -126,7 +127,7 @@ public final class InVMNodeManager extends NodeManager { state = LIVE; } catch (Exception e) { - e.printStackTrace(); + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } }; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java index 1f5c74c8ee..b90a30efa5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RefsOperation.java @@ -142,7 +142,7 @@ public class RefsOperation extends TransactionOperationAbstract { ackedTX.commit(true); } catch (Exception e) { - e.printStackTrace(); + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); } } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java index 16cf238cca..50ccb50d1f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java @@ -874,8 +874,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { storageManager.deleteHeuristicCompletion(id); } catch (Exception e) { - e.printStackTrace(); - + ActiveMQServerLogger.LOGGER.warn(e.getMessage(), e); throw new ActiveMQXAException(XAException.XAER_RMFAIL); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java index 4ae63ea4e7..e2adc1fd73 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingBackupActivation.java @@ -353,7 +353,6 @@ public final class SharedNothingBackupActivation extends Activation { // do not log these errors if the server is being stopped. return; ActiveMQServerLogger.LOGGER.initializationError(e); - e.printStackTrace(); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreBackupActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreBackupActivation.java index 18a2105234..3822fff3c4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreBackupActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreBackupActivation.java @@ -238,8 +238,8 @@ public final class SharedStoreBackupActivation extends Activation { } } catch (Exception e) { + ActiveMQServerLogger.LOGGER.warn(e.getMessage(),e); ActiveMQServerLogger.LOGGER.serverRestartWarning(); - e.printStackTrace(); } } });