This closes #896

This commit is contained in:
Clebert Suconic 2016-11-23 11:16:09 -05:00
commit 5f7f0785c9
17 changed files with 46 additions and 36 deletions

View File

@ -26,6 +26,8 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* <p> * <p>
@ -35,6 +37,8 @@ import java.util.List;
*/ */
public class Artemis { public class Artemis {
private static final Logger logger = Logger.getLogger(Artemis.class.getName());
public static void main(String[] args) throws Throwable { public static void main(String[] args) throws Throwable {
String home = System.getProperty("artemis.home"); String home = System.getProperty("artemis.home");
@ -143,7 +147,7 @@ public class Artemis {
try { try {
urls.add(file.toURI().toURL()); urls.add(file.toURI().toURL());
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); logger.log(Level.WARNING, e.getMessage(), e);
} }
} }

View File

@ -10,6 +10,8 @@
*/ */
package org.apache.activemq.artemis.utils; package org.apache.activemq.artemis.utils;
import org.jboss.logging.Logger;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -149,6 +151,8 @@ public class Base64 {
*/ */
private static final byte NEW_LINE = (byte) '\n'; private static final byte NEW_LINE = (byte) '\n';
private static final Logger logger = Logger.getLogger(Base64.class);
/** /**
* Preferred encoding. * Preferred encoding.
*/ */
@ -539,7 +543,7 @@ public class Base64 {
oos.writeObject(serializableObject); oos.writeObject(serializableObject);
} catch (java.io.IOException e) { } catch (java.io.IOException e) {
e.printStackTrace(); logger.warn("Object cannot be serialized", e.getMessage(), e);
return null; return null;
} finally { } finally {
try { try {
@ -657,7 +661,7 @@ public class Base64 {
gzos.write(source, off, len); gzos.write(source, off, len);
gzos.close(); gzos.close();
} catch (java.io.IOException e) { } catch (java.io.IOException e) {
e.printStackTrace(); logger.warn("Unable to encode byte array into Base64 notation", e.getMessage(), e);
return null; return null;
} finally { } finally {
try { try {
@ -945,11 +949,8 @@ public class Base64 {
ois = new java.io.ObjectInputStream(bais); ois = new java.io.ObjectInputStream(bais);
obj = ois.readObject(); obj = ois.readObject();
} catch (java.io.IOException e) { } catch (java.io.IOException | java.lang.ClassNotFoundException e) {
e.printStackTrace(); logger.warn("Unable to deserialize object", e.getMessage(), e);
obj = null;
} catch (java.lang.ClassNotFoundException e) {
e.printStackTrace();
obj = null; obj = null;
} finally { } finally {
try { try {

View File

@ -155,7 +155,7 @@ public class JDBCSequentialFile implements SequentialFile {
return noBytes; return noBytes;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.warn("Failed to write to file", e.getMessage(), e);
if (callback != null) if (callback != null)
callback.onError(-1, e.getMessage()); callback.onError(-1, e.getMessage());
} }
@ -251,7 +251,7 @@ public class JDBCSequentialFile implements SequentialFile {
} catch (Exception e) { } catch (Exception e) {
if (callback != null) if (callback != null)
callback.onError(-1, e.getMessage()); callback.onError(-1, e.getMessage());
e.printStackTrace(); logger.warn("Failed to read from file", e.getMessage(), e);
return 0; return 0;
} }
} }

View File

@ -223,7 +223,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
if (success) if (success)
cleanupTxRecords(deletedRecords, committedTransactions); cleanupTxRecords(deletedRecords, committedTransactions);
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); logger.warn("Failed to remove the Tx Records", e.getMessage(), e);
} }
executeCallbacks(recordRef, success); executeCallbacks(recordRef, success);

View File

@ -39,6 +39,7 @@ import org.apache.activemq.artemis.jms.client.ActiveMQMessage;
import org.apache.activemq.artemis.jms.server.JMSServerManager; import org.apache.activemq.artemis.jms.server.JMSServerManager;
import org.apache.activemq.artemis.utils.JsonLoader; import org.apache.activemq.artemis.utils.JsonLoader;
import org.apache.activemq.artemis.utils.SelectorTranslator; import org.apache.activemq.artemis.utils.SelectorTranslator;
import org.jboss.logging.Logger;
import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe; import static org.apache.activemq.artemis.api.core.JsonUtil.nullSafe;
@ -52,6 +53,8 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl {
private final JMSServerManager jmsServerManager; private final JMSServerManager jmsServerManager;
private static final Logger logger = Logger.getLogger(JMSTopicControlImpl.class);
// Static -------------------------------------------------------- // Static --------------------------------------------------------
public static String createFilterFromJMSSelector(final String selectorStr) throws ActiveMQException { public static String createFilterFromJMSSelector(final String selectorStr) throws ActiveMQException {
@ -318,7 +321,7 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl {
return array.build().toString(); return array.build().toString();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.warn("Unable to list subscribers as JSON", e.getMessage(), e);
return e.toString(); return e.toString();
} }
} }

View File

@ -100,6 +100,7 @@ import org.apache.activemq.artemis.utils.SelectorTranslator;
import org.apache.activemq.artemis.utils.TimeAndCounterIDGenerator; import org.apache.activemq.artemis.utils.TimeAndCounterIDGenerator;
import org.apache.activemq.artemis.utils.TypedProperties; import org.apache.activemq.artemis.utils.TypedProperties;
import org.apache.activemq.artemis.utils.XMLUtil; import org.apache.activemq.artemis.utils.XMLUtil;
import org.jboss.logging.Logger;
import org.w3c.dom.Element; import org.w3c.dom.Element;
/** /**
@ -151,6 +152,8 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
private final Map<String, List<String>> unRecoveredBindings = new HashMap<>(); private final Map<String, List<String>> unRecoveredBindings = new HashMap<>();
private static final Logger logger = Logger.getLogger(JMSServerManagerImpl.class);
public JMSServerManagerImpl(final ActiveMQServer server) throws Exception { public JMSServerManagerImpl(final ActiveMQServer server) throws Exception {
this.server = server; this.server = server;
@ -265,7 +268,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
active = false; active = false;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.warn("Unable to deactivate server", e.getMessage(), e);
} }
} }

View File

@ -22,6 +22,7 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.apache.activemq.artemis.core.io.SequentialFile; import org.apache.activemq.artemis.core.io.SequentialFile;
import org.jboss.logging.Logger;
public class JournalFileImpl implements JournalFile { public class JournalFileImpl implements JournalFile {
@ -47,6 +48,8 @@ public class JournalFileImpl implements JournalFile {
private final ConcurrentMap<JournalFile, AtomicInteger> negCounts = new ConcurrentHashMap<>(); private final ConcurrentMap<JournalFile, AtomicInteger> negCounts = new ConcurrentHashMap<>();
private static final Logger logger = Logger.getLogger(JournalFileImpl.class);
public JournalFileImpl(final SequentialFile file, final long fileID, final int version) { public JournalFileImpl(final SequentialFile file, final long fileID, final int version) {
this.file = file; this.file = file;
@ -152,7 +155,7 @@ public class JournalFileImpl implements JournalFile {
try { try {
return "JournalFileImpl: (" + file.getFileName() + " id = " + fileID + ", recordID = " + recordID + ")"; return "JournalFileImpl: (" + file.getFileName() + " id = " + fileID + ", recordID = " + recordID + ")";
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.warn("Error during method invocation", e.getMessage(), e);
return "Error:" + e.toString(); return "Error:" + e.toString();
} }
} }

View File

@ -1351,7 +1351,6 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
} catch (Throwable e) { } catch (Throwable e) {
errors.incrementAndGet(); errors.incrementAndGet();
ActiveMQJournalLogger.LOGGER.errorCompacting(e); ActiveMQJournalLogger.LOGGER.errorCompacting(e);
e.printStackTrace();
} finally { } finally {
latch.countDown(); latch.countDown();
} }
@ -2911,7 +2910,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
try { try {
scheduleCompactAndBlock(60); scheduleCompactAndBlock(60);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.warn("Error during compact", e.getMessage(), e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }

View File

@ -33,6 +33,7 @@ import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
import org.apache.activemq.artemis.core.remoting.CloseListener; import org.apache.activemq.artemis.core.remoting.CloseListener;
import org.apache.activemq.artemis.core.remoting.FailureListener; import org.apache.activemq.artemis.core.remoting.FailureListener;
import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.core.transaction.Transaction;
import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl; import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
import org.apache.activemq.artemis.core.transaction.impl.XidImpl; import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
@ -168,8 +169,8 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener {
if (amqpConnection.isSyncOnFlush()) { if (amqpConnection.isSyncOnFlush()) {
try { try {
latch.await(5, TimeUnit.SECONDS); latch.await(5, TimeUnit.SECONDS);
} catch (Exception e) { } catch (InterruptedException e) {
e.printStackTrace(); ActiveMQServerLogger.LOGGER.warn("Error during await invocation", e);
} }
} }

View File

@ -221,8 +221,7 @@ public class MQTTPublishManager {
payload.writeBytes(stringPayload); payload.writeBytes(stringPayload);
break; break;
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); log.warn("Unable to send message: " + message.getMessageID() + " Cause: " + e.getMessage());
// Do nothing default to sending raw bytes.
} }
default: default:
payload = message.getBodyBufferDuplicate().byteBuf(); payload = message.getBodyBufferDuplicate().byteBuf();

View File

@ -49,7 +49,6 @@ public class MQTTSessionCallback implements SessionCallback {
try { try {
session.getMqttPublishManager().sendMessage(message, consumer, deliveryCount); session.getMqttPublishManager().sendMessage(message, consumer, deliveryCount);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
log.warn("Unable to send message: " + message.getMessageID() + " Cause: " + e.getMessage()); log.warn("Unable to send message: " + message.getMessageID() + " Cause: " + e.getMessage());
} }
return 1; return 1;

View File

@ -262,8 +262,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
setLastCommand(command); setLastCommand(command);
response = command.visit(commandProcessorInstance); response = command.visit(commandProcessorInstance);
} catch (Exception e) { } catch (Exception e) {
// TODO: logging ActiveMQServerLogger.LOGGER.warn("Errors occurred during the buffering operation ", e);
e.printStackTrace();
if (responseRequired) { if (responseRequired) {
response = convertException(e); response = convertException(e);
} }
@ -821,8 +820,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, amqConsumer.getId().toString()); advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, amqConsumer.getId().toString());
protocolManager.fireAdvisory(context, topic, advisoryMessage, amqConsumer.getId()); protocolManager.fireAdvisory(context, topic, advisoryMessage, amqConsumer.getId());
} catch (Exception e) { } catch (Exception e) {
// TODO-NOW: LOGGING ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
e.printStackTrace();
} }
} }
} }
@ -1184,7 +1182,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
Xid xid = OpenWireUtil.toXID(info.getTransactionId()); Xid xid = OpenWireUtil.toXID(info.getTransactionId());
internalSession.xaForget(xid); internalSession.xaForget(xid);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
throw e; throw e;
} }
} else { } else {
@ -1204,7 +1202,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
Xid xid = OpenWireUtil.toXID(info.getTransactionId()); Xid xid = OpenWireUtil.toXID(info.getTransactionId());
internalSession.xaPrepare(xid); internalSession.xaPrepare(xid);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
throw e; throw e;
} }
} else { } else {
@ -1233,7 +1231,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
internalSession.resetTX(null); internalSession.resetTX(null);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
throw e; throw e;
} }
} else { } else {

View File

@ -29,6 +29,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl; import org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl;
import org.apache.activemq.artemis.core.protocol.openwire.OpenWireMessageConverter; import org.apache.activemq.artemis.core.protocol.openwire.OpenWireMessageConverter;
import org.apache.activemq.artemis.core.protocol.openwire.util.OpenWireUtil; import org.apache.activemq.artemis.core.protocol.openwire.util.OpenWireUtil;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.MessageReference; import org.apache.activemq.artemis.core.server.MessageReference;
import org.apache.activemq.artemis.core.server.QueueQueryResult; import org.apache.activemq.artemis.core.server.QueueQueryResult;
import org.apache.activemq.artemis.core.server.ServerConsumer; import org.apache.activemq.artemis.core.server.ServerConsumer;
@ -198,10 +199,10 @@ public class AMQConsumer {
currentWindow.decrementAndGet(); currentWindow.decrementAndGet();
return size; return size;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); ActiveMQServerLogger.LOGGER.warn("Error during message dispatch", e);
return 0; return 0;
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); ActiveMQServerLogger.LOGGER.warn("Error during message dispatch", t);
return 0; return 0;
} }
} }

View File

@ -175,8 +175,7 @@ public class UriStrategy implements PushStrategy {
} }
} }
} catch (Exception e) { } catch (Exception e) {
ActiveMQRestLogger.LOGGER.debug("failed to push message to " + uri, e); ActiveMQRestLogger.LOGGER.warn("failed to push message to " + uri, e);
e.printStackTrace();
return false; return false;
} finally { } finally {
if (res != null) if (res != null)

View File

@ -83,7 +83,7 @@ public class HttpMessageHelper {
ActiveMQRestLogger.LOGGER.debug("**** Building Message from object: " + obj.toString()); ActiveMQRestLogger.LOGGER.debug("**** Building Message from object: " + obj.toString());
request.body(contentType, obj); request.body(contentType, obj);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); ActiveMQRestLogger.LOGGER.warn("Building Message from object", e.getMessage(), e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }

View File

@ -412,7 +412,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin {
} }
} }
} catch (NamingException e) { } catch (NamingException e) {
e.printStackTrace(); logger.warn("Failed to process an event", e.getMessage(), e);
} }
} }
@ -464,7 +464,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin {
} }
} }
} catch (NamingException e) { } catch (NamingException e) {
e.printStackTrace(); logger.warn("Failed to process an event", e.getMessage(), e);
} }
} }

View File

@ -302,7 +302,7 @@ public class ManagementServiceImpl implements ManagementService {
try { try {
unregisterAcceptor(name); unregisterAcceptor(name);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); logger.warn("Failed to unregister acceptors", e.getMessage(), e);
} }
} }
} }