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

View File

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

View File

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

View File

@ -223,7 +223,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal {
if (success)
cleanupTxRecords(deletedRecords, committedTransactions);
} catch (SQLException e) {
e.printStackTrace();
logger.warn("Failed to remove the Tx Records", e.getMessage(), e);
}
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.utils.JsonLoader;
import org.apache.activemq.artemis.utils.SelectorTranslator;
import org.jboss.logging.Logger;
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 static final Logger logger = Logger.getLogger(JMSTopicControlImpl.class);
// Static --------------------------------------------------------
public static String createFilterFromJMSSelector(final String selectorStr) throws ActiveMQException {
@ -318,7 +321,7 @@ public class JMSTopicControlImpl extends StandardMBean implements TopicControl {
return array.build().toString();
} catch (Exception e) {
e.printStackTrace();
logger.warn("Unable to list subscribers as JSON", e.getMessage(), e);
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.TypedProperties;
import org.apache.activemq.artemis.utils.XMLUtil;
import org.jboss.logging.Logger;
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 static final Logger logger = Logger.getLogger(JMSServerManagerImpl.class);
public JMSServerManagerImpl(final ActiveMQServer server) throws Exception {
this.server = server;
@ -265,7 +268,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
active = false;
}
} 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 org.apache.activemq.artemis.core.io.SequentialFile;
import org.jboss.logging.Logger;
public class JournalFileImpl implements JournalFile {
@ -47,6 +48,8 @@ public class JournalFileImpl implements JournalFile {
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) {
this.file = file;
@ -152,7 +155,7 @@ public class JournalFileImpl implements JournalFile {
try {
return "JournalFileImpl: (" + file.getFileName() + " id = " + fileID + ", recordID = " + recordID + ")";
} catch (Exception e) {
e.printStackTrace();
logger.warn("Error during method invocation", e.getMessage(), e);
return "Error:" + e.toString();
}
}

View File

@ -1351,7 +1351,6 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
} catch (Throwable e) {
errors.incrementAndGet();
ActiveMQJournalLogger.LOGGER.errorCompacting(e);
e.printStackTrace();
} finally {
latch.countDown();
}
@ -2911,7 +2910,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
try {
scheduleCompactAndBlock(60);
} catch (Exception e) {
e.printStackTrace();
logger.warn("Error during compact", e.getMessage(), 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.FailureListener;
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.impl.TransactionImpl;
import org.apache.activemq.artemis.core.transaction.impl.XidImpl;
@ -168,8 +169,8 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener {
if (amqpConnection.isSyncOnFlush()) {
try {
latch.await(5, TimeUnit.SECONDS);
} catch (Exception e) {
e.printStackTrace();
} catch (InterruptedException e) {
ActiveMQServerLogger.LOGGER.warn("Error during await invocation", e);
}
}

View File

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

View File

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

View File

@ -262,8 +262,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
setLastCommand(command);
response = command.visit(commandProcessorInstance);
} catch (Exception e) {
// TODO: logging
e.printStackTrace();
ActiveMQServerLogger.LOGGER.warn("Errors occurred during the buffering operation ", e);
if (responseRequired) {
response = convertException(e);
}
@ -821,8 +820,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, amqConsumer.getId().toString());
protocolManager.fireAdvisory(context, topic, advisoryMessage, amqConsumer.getId());
} catch (Exception e) {
// TODO-NOW: LOGGING
e.printStackTrace();
ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
}
}
}
@ -1184,7 +1182,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
Xid xid = OpenWireUtil.toXID(info.getTransactionId());
internalSession.xaForget(xid);
} catch (Exception e) {
e.printStackTrace();
ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
throw e;
}
} else {
@ -1204,7 +1202,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
Xid xid = OpenWireUtil.toXID(info.getTransactionId());
internalSession.xaPrepare(xid);
} catch (Exception e) {
e.printStackTrace();
ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
throw e;
}
} else {
@ -1233,7 +1231,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se
internalSession.resetTX(null);
}
} catch (Exception e) {
e.printStackTrace();
ActiveMQServerLogger.LOGGER.warn("Error during method invocation", e);
throw e;
}
} 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.protocol.openwire.OpenWireMessageConverter;
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.QueueQueryResult;
import org.apache.activemq.artemis.core.server.ServerConsumer;
@ -198,10 +199,10 @@ public class AMQConsumer {
currentWindow.decrementAndGet();
return size;
} catch (IOException e) {
e.printStackTrace();
ActiveMQServerLogger.LOGGER.warn("Error during message dispatch", e);
return 0;
} catch (Throwable t) {
t.printStackTrace();
ActiveMQServerLogger.LOGGER.warn("Error during message dispatch", t);
return 0;
}
}

View File

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

View File

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

View File

@ -412,7 +412,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin {
}
}
} 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) {
e.printStackTrace();
logger.warn("Failed to process an event", e.getMessage(), e);
}
}

View File

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