diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XMLMessageImporter.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XMLMessageImporter.java index f7e250ca34..132915378b 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XMLMessageImporter.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XMLMessageImporter.java @@ -250,14 +250,11 @@ public class XMLMessageImporter { } } reader.next(); - if (logger.isDebugEnabled()) { - logger.debug("XMLStreamReader impl: " + reader); - } + logger.debug("XMLStreamReader impl: {}", reader); + if (isLarge) { tempFileName = File.createTempFile("largeMessage", ".tmp"); - if (logger.isDebugEnabled()) { - logger.debug("Creating temp file " + tempFileName + " for large message."); - } + logger.debug("Creating temp file {} for large message.", tempFileName); try (OutputStream out = new BufferedOutputStream(new FileOutputStream(tempFileName))) { getMessageBodyBytes(bytes -> out.write(bytes), (message.toCore().getType() == Message.TEXT_TYPE) && decodeTextMessage); } diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XmlDataImporter.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XmlDataImporter.java index 8abf94be39..34768977f1 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XmlDataImporter.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/xml/XmlDataImporter.java @@ -248,9 +248,7 @@ public final class XmlDataImporter extends ActionAbstract { } try { while (reader.hasNext()) { - if (logger.isDebugEnabled()) { - logger.debug("EVENT:[" + reader.getLocation().getLineNumber() + "][" + reader.getLocation().getColumnNumber() + "] "); - } + logger.debug("EVENT:[{}][{}] ", reader.getLocation().getLineNumber(), reader.getLocation().getColumnNumber()); if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) { if (XmlDataConstants.OLD_BINDING.equals(reader.getLocalName())) { oldBinding(); // export from 1.x @@ -315,17 +313,13 @@ public final class XmlDataImporter extends ActionAbstract { ClientMessage managementMessage = managementSession.createMessage(false); ManagementHelper.putAttribute(managementMessage, ResourceNames.QUEUE + queue, "ID"); managementSession.start(); - if (debugLog) { - logger.debug("Requesting ID for: " + queue); - } + logger.debug("Requesting ID for: {}", queue); ClientMessage reply = requestor.request(managementMessage); Number idObject = (Number) ManagementHelper.getResult(reply); queueID = idObject.longValue(); } - if (debugLog) { - logger.debug("ID for " + queue + " is: " + queueID); - } + logger.debug("ID for {} is: {}", queue, queueID); queueIDs.put(queue, queueID); // store it so we don't have to look it up every time } @@ -425,13 +419,9 @@ public final class XmlDataImporter extends ActionAbstract { if (!queueQuery.isExists()) { session.createQueue(new QueueConfiguration(queueName).setAddress(address).setRoutingType(routingType).setFilterString(filter)); - if (logger.isDebugEnabled()) { - logger.debug("Binding queue(name=" + queueName + ", address=" + address + ", filter=" + filter + ")"); - } + logger.debug("Binding queue(name={}, address={}, filter={})", queueName, address, filter); } else { - if (logger.isDebugEnabled()) { - logger.debug("Binding " + queueName + " already exists so won't re-bind."); - } + logger.debug("Binding {} already exists so won't re-bind.", queueName); } } @@ -467,13 +457,9 @@ public final class XmlDataImporter extends ActionAbstract { if (!queueQuery.isExists()) { session.createQueue(new QueueConfiguration(queueName).setAddress(address).setRoutingType(RoutingType.valueOf(routingType)).setFilterString(filter)); - if (logger.isDebugEnabled()) { - logger.debug("Binding queue(name=" + queueName + ", address=" + address + ", filter=" + filter + ")"); - } + logger.debug("Binding queue(name={}, address={}, filter={})", queueName, address, filter); } else { - if (logger.isDebugEnabled()) { - logger.debug("Binding " + queueName + " already exists so won't re-bind."); - } + logger.debug("Binding {} already exists so won't re-bind.", queueName); } addressMap.put(queueName, address); @@ -503,13 +489,9 @@ public final class XmlDataImporter extends ActionAbstract { set.add(RoutingType.valueOf(routingType)); } session.createAddress(SimpleString.toSimpleString(addressName), set, false); - if (logger.isDebugEnabled()) { - logger.debug("Binding address(name=" + addressName + ", routingTypes=" + routingTypes + ")"); - } + logger.debug("Binding address(name={}, routingTypes={})", addressName, routingTypes); } else { - if (logger.isDebugEnabled()) { - logger.debug("Binding " + addressName + " already exists so won't re-bind."); - } + logger.debug("Binding {} already exists so won't re-bind.", addressName); } } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java index 4cfe11636f..b21ebeba06 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/NetworkHealthCheck.java @@ -359,9 +359,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent { public boolean check(InetAddress address) throws IOException, InterruptedException { if (!hasCustomPingCommand() && isReachable(address)) { - if (logger.isTraceEnabled()) { - logger.trace(address + " OK"); - } + logger.trace("{} OK", address); return true; } else { return purePing(address); @@ -376,9 +374,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent { long timeout = Math.max(1, TimeUnit.MILLISECONDS.toSeconds(networkTimeout)); // it did not work with a simple isReachable, it could be because there's no root access, so we will try ping executable - if (logger.isTraceEnabled()) { - logger.trace("purePing on canonical address " + address.getCanonicalHostName()); - } + logger.trace("purePing on canonical address {}", address.getCanonicalHostName()); ProcessBuilder processBuilder; if (address instanceof Inet6Address) { processBuilder = buildProcess(ipv6Command, timeout, address.getCanonicalHostName()); @@ -398,10 +394,7 @@ public class NetworkHealthCheck extends ActiveMQScheduledComponent { private ProcessBuilder buildProcess(String expressionCommand, long timeout, String host) { String command = String.format(expressionCommand, timeout, host); - if (logger.isDebugEnabled()) { - logger.debug("executing ping:: " + command); - } - + logger.debug("executing ping:: {}", command); ProcessBuilder builder = new ProcessBuilder(command.split(" ")); return builder; diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java index 10a301699f..b9e7741258 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java @@ -65,9 +65,9 @@ public class ByteUtil { try { if (info) { - logger.info(message + "\n" + ByteUtil.formatGroup(ByteUtil.bytesToHex(frame), 8, 16)); + logger.info("{}\n{}", message, ByteUtil.formatGroup(ByteUtil.bytesToHex(frame), 8, 16)); } else { - logger.trace(message + "\n" + ByteUtil.formatGroup(ByteUtil.bytesToHex(frame), 8, 16)); + logger.trace("{}\n{}", message, ByteUtil.formatGroup(ByteUtil.bytesToHex(frame), 8, 16)); } } catch (Exception e) { logger.warn(e.getMessage(), e); diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java index 8b7d106765..a135e14337 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodec.java @@ -143,7 +143,7 @@ public class DefaultSensitiveStringCodec implements SensitiveDataCodec { } else { key = System.getProperty(KEY_SYSTEM_PROPERTY); if (key != null && key.trim().length() > 0) { - logger.trace("Set key from system property " + KEY_SYSTEM_PROPERTY); + logger.trace("Set key from system property {}", KEY_SYSTEM_PROPERTY); updateKey(key); } } @@ -199,7 +199,7 @@ public class DefaultSensitiveStringCodec implements SensitiveDataCodec { try { return Objects.equals(storedValue, encode(String.valueOf(inputValue))); } catch (Exception e) { - logger.debug("Exception on verifying: " + e); + logger.debug("Exception on verifying:", e); return false; } } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java index 2a3feb380b..87a929c277 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UTF8Util.java @@ -91,7 +91,7 @@ public final class UTF8Util { if (logger.isTraceEnabled()) { // This message is too verbose for debug, that's why we are using trace here - logger.trace("Saving string with utfSize=" + len + " stringSize=" + stringLength); + logger.trace("Saving string with utfSize={} stringSize={}", len, stringLength); } if (out.hasArray()) { @@ -189,7 +189,7 @@ public final class UTF8Util { if (logger.isTraceEnabled()) { // This message is too verbose for debug, that's why we are using trace here - logger.trace("Reading string with utfSize=" + size); + logger.trace("Reading string with utfSize={}", size); } if (PlatformDependent.hasUnsafe() && input.byteBuf() != null && input.byteBuf().hasMemoryAddress()) { final ByteBuf byteBuf = input.byteBuf(); diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java index 951253921e..767abb65c0 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/UUIDGenerator.java @@ -127,7 +127,7 @@ public final class UUIDGenerator { dummy[0] |= (byte) 0x01; if (logger.isDebugEnabled()) { - logger.debug("using dummy address " + UUIDGenerator.asString(dummy)); + logger.debug("using dummy address {}", UUIDGenerator.asString(dummy)); } return dummy; } @@ -158,7 +158,7 @@ public final class UUIDGenerator { byte[] address = findFirstMatchingHardwareAddress(ifaces); if (address != null) { if (logger.isDebugEnabled()) { - logger.debug("using hardware address " + UUIDGenerator.asString(address)); + logger.debug("using hardware address {}", UUIDGenerator.asString(address)); } return address; } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/actors/ProcessorBase.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/actors/ProcessorBase.java index d4772ba56b..2699064097 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/actors/ProcessorBase.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/actors/ProcessorBase.java @@ -203,7 +203,7 @@ public abstract class ProcessorBase extends HandlerBase { private static void logAddOnShutdown() { if (logger.isDebugEnabled()) { - logger.debug("Ordered executor has been gently shutdown at", new Exception("debug")); + logger.debug("Ordered executor has been gently shutdown at {}", new Exception("debug")); } } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/actors/ThresholdActor.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/actors/ThresholdActor.java index 84b2026e5d..09fc24cbd9 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/actors/ThresholdActor.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/actors/ThresholdActor.java @@ -70,8 +70,8 @@ public class ThresholdActor extends ProcessorBase { } finally { if (estimateSize > 0) { SIZE_UPDATER.getAndAdd(this, -estimateSize); - } else if (logger.isDebugEnabled()) { - logger.debug("element " + theTask + " returned an invalid size over the Actor during release"); + } else { + logger.debug("element {} returned an invalid size over the Actor during release", theTask); } } } @@ -83,8 +83,8 @@ public class ThresholdActor extends ProcessorBase { if (size > maxSize) { flush(); } - } else if (logger.isDebugEnabled()) { - logger.debug("element " + message + " returned an invalid size over the Actor"); + } else { + logger.debug("element {} returned an invalid size over the Actor", message); } task(message); } diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashSet.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashSet.java index ec26b7437b..f81f154a93 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashSet.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/ConcurrentLongHashSet.java @@ -437,7 +437,7 @@ public class ConcurrentLongHashSet { static boolean moreThanZero(long n) { if (n < 0L) { - logger.warn("Keys and values must be >= 0, while it was " + n + ", entry will be ignored", new Exception("invalid record " + n)); + logger.warn("Keys and values must be >= 0, while it was {}, entry will be ignored", n, new Exception("invalid record " + n)); return false; } else { return true; diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalMeasure.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalMeasure.java index 209f1d9d9f..d289eac4a3 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalMeasure.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalMeasure.java @@ -110,8 +110,8 @@ public class CriticalMeasure { if (analyzer != null) { long nanoTimeout = analyzer.getTimeoutNanoSeconds(); if (checkExpiration(nanoTimeout, false)) { - logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, leaving at", new Exception("left")); - logger.trace("Path " + id + " on component " + getComponentName() + " is taking too long, entered at", traceEnter); + logger.trace("Path {} on component {} is taking too long, leaving at {}", id, getComponentName(), new Exception("left")); + logger.trace("Path {} on component {} is taking too long, entered at", id, getComponentName(), traceEnter); } } traceEnter = null; @@ -137,9 +137,9 @@ public class CriticalMeasure { Exception lastTraceEnter = this.traceEnter; if (lastTraceEnter != null) { - logger.warn("Component " + getComponentName() + " is expired on path " + id, lastTraceEnter); + logger.warn("Component {} is expired on path {}", getComponentName(), id, lastTraceEnter); } else { - logger.warn("Component " + getComponentName() + " is expired on path " + id); + logger.warn("Component {} is expired on path {}", getComponentName(), id); } if (reset) { diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java index 105bfff1b4..ca0b99b0a9 100644 --- a/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java +++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/uri/FluentPropertyBeanIntrospectorWithIgnores.java @@ -37,7 +37,7 @@ public class FluentPropertyBeanIntrospectorWithIgnores extends FluentPropertyBea private static ConcurrentHashSet> ignores = new ConcurrentHashSet<>(); public static void addIgnore(String className, String propertyName) { - logger.trace("Adding ignore on " + className + "/" + propertyName); + logger.trace("Adding ignore on {}/{}", className, propertyName); ignores.add(new Pair<>(className, propertyName)); } @@ -53,7 +53,7 @@ public class FluentPropertyBeanIntrospectorWithIgnores extends FluentPropertyBea PropertyDescriptor pd = icontext.getPropertyDescriptor(propertyName); if (isIgnored(icontext.getTargetClass().getName(), m.getName())) { - logger.trace(m.getName() + " Ignored for " + icontext.getTargetClass().getName()); + logger.trace("{} Ignored for {}", m.getName(), icontext.getTargetClass().getName()); continue; } try { diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodecTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodecTest.java index 6eadadd9cb..a9ba3e6089 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodecTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/DefaultSensitiveStringCodecTest.java @@ -54,7 +54,7 @@ public class DefaultSensitiveStringCodecTest { String plainText = "some_password"; String maskedText = codec.encode(plainText); - log.debug("encoded value: " + maskedText); + log.debug("encoded value: {}", maskedText); if (algorithm.equals(DefaultSensitiveStringCodec.ONE_WAY)) { //one way can't decode @@ -65,7 +65,7 @@ public class DefaultSensitiveStringCodecTest { } } else { String decoded = codec.decode(maskedText); - log.debug("encoded value: " + maskedText); + log.debug("encoded value: {}", maskedText); assertEquals("decoded result not match: " + decoded, decoded, plainText); } @@ -91,7 +91,7 @@ public class DefaultSensitiveStringCodecTest { String plainText = "some_password"; String maskedText = codec.encode(plainText); - log.debug("encoded value: " + maskedText); + log.debug("encoded value: {}", maskedText); assertTrue(codec.verify(plainText.toCharArray(), maskedText)); diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/OrderedExecutorSanityTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/OrderedExecutorSanityTest.java index c269298426..5efb8e0581 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/OrderedExecutorSanityTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/actors/OrderedExecutorSanityTest.java @@ -179,7 +179,7 @@ public class OrderedExecutorSanityTest { long elapsed = (end - start); - log.info("execution " + i + " in " + TimeUnit.NANOSECONDS.toMillis(elapsed) + " milliseconds"); + log.info("execution {} in {} milliseconds", i, TimeUnit.NANOSECONDS.toMillis(elapsed)); } } finally { executorService.shutdown(); diff --git a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/critical/MultiThreadCriticalMeasureTest.java b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/critical/MultiThreadCriticalMeasureTest.java index 6603f581e7..63f664c429 100644 --- a/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/critical/MultiThreadCriticalMeasureTest.java +++ b/artemis-commons/src/test/java/org/apache/activemq/artemis/utils/critical/MultiThreadCriticalMeasureTest.java @@ -52,9 +52,9 @@ public class MultiThreadCriticalMeasureTest { Runnable runnable = () -> { try { - logger.debug("Thread " + Thread.currentThread().getName() + " waiting to Start"); + logger.debug("Thread {} waiting to Start", Thread.currentThread().getName()); barrier.await(); - logger.debug("Thread " + Thread.currentThread().getName() + " Started"); + logger.debug("Thread {} Started", Thread.currentThread().getName()); while (running.get()) { if (!load.get()) { // 1st barrier will let the unit test do its job diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/ChannelBroadcastEndpointFactory.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/ChannelBroadcastEndpointFactory.java index 56e3ddfe6f..175bacfa6c 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/ChannelBroadcastEndpointFactory.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/ChannelBroadcastEndpointFactory.java @@ -45,7 +45,7 @@ public class ChannelBroadcastEndpointFactory implements BroadcastEndpointFactory private ChannelBroadcastEndpointFactory(JChannelManager manager, JChannel channel, String channelName) { if (logger.isTraceEnabled()) { - logger.trace("new ChannelBroadcastEndpointFactory(" + manager + ", " + channel + ", " + channelName, new Exception("trace")); + logger.trace("new ChannelBroadcastEndpointFactory({}, {}, {})", manager, channel, channelName, new Exception("trace")); } this.manager = manager; this.channel = channel; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java index af9c9747de..75ce007240 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/JGroupsBroadcastEndpoint.java @@ -52,8 +52,10 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint { @Override public void broadcast(final byte[] data) throws Exception { - if (logger.isTraceEnabled()) - logger.trace("Broadcasting: BroadCastOpened=" + broadcastOpened + ", channelOPen=" + channel.getChannel().isOpen()); + if (logger.isTraceEnabled()) { + logger.trace("Broadcasting: BroadCastOpened={}, channelOPen={}", broadcastOpened, channel.getChannel().isOpen()); + } + if (broadcastOpened) { org.jgroups.Message msg = new org.jgroups.BytesMessage(); @@ -65,8 +67,10 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint { @Override public byte[] receiveBroadcast() throws Exception { - if (logger.isTraceEnabled()) - logger.trace("Receiving Broadcast: clientOpened=" + clientOpened + ", channelOPen=" + channel.getChannel().isOpen()); + if (logger.isTraceEnabled()) { + logger.trace("Receiving Broadcast: clientOpened={}, channelOPen={}", clientOpened, channel.getChannel().isOpen()); + } + if (clientOpened) { return receiver.receiveBroadcast(); } else { @@ -76,8 +80,10 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint { @Override public byte[] receiveBroadcast(long time, TimeUnit unit) throws Exception { - if (logger.isTraceEnabled()) - logger.trace("Receiving Broadcast2: clientOpened=" + clientOpened + ", channelOPen=" + channel.getChannel().isOpen()); + if (logger.isTraceEnabled()) { + logger.trace("Receiving Broadcast2: clientOpened={}, channelOPen={}", clientOpened, channel.getChannel().isOpen()); + } + if (clientOpened) { return receiver.receiveBroadcast(time, unit); } else { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelManager.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelManager.java index 9d4195fb1b..fe2c4e043b 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelManager.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelManager.java @@ -75,12 +75,11 @@ public class JChannelManager { if (wrapper == null) { wrapper = new JChannelWrapper(this, channelName, endpoint.createChannel()); channels.put(channelName, wrapper); - if (logger.isTraceEnabled()) - logger.trace("Put Channel " + channelName); + logger.trace("Put Channel {}", channelName); return wrapper; } - if (logger.isTraceEnabled()) - logger.trace("Add Ref Count " + channelName); + logger.trace("Add Ref Count {}", channelName); + return wrapper.addRef(); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelWrapper.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelWrapper.java index e93dbe7da0..c8e151255d 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelWrapper.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JChannelWrapper.java @@ -50,7 +50,7 @@ public class JChannelWrapper { this.manager = manager; if (logger.isTraceEnabled() && channel.getReceiver() != null) { - logger.trace(this + "The channel already had a receiver previously!!!! == " + channel.getReceiver(), new Exception("trace")); + logger.trace("{} The channel already had a receiver previously!!!! == {}", this, channel.getReceiver(), new Exception("trace")); } //we always add this for the first ref count @@ -64,7 +64,7 @@ public class JChannelWrapper { @Override public void receive(org.jgroups.Message msg) { if (logger.isTraceEnabled()) { - logger.trace(this + ":: Wrapper received " + msg + " on channel " + channelName); + logger.trace("{}:: Wrapper received {} on channel {}", this, msg, channelName); } synchronized (receivers) { for (JGroupsReceiver r : receivers) { @@ -86,7 +86,7 @@ public class JChannelWrapper { public synchronized void close(boolean closeWrappedChannel) { refCount--; if (logger.isTraceEnabled()) - logger.trace(this + "::RefCount-- " + refCount + " on channel " + channelName, new Exception("Trace")); + logger.trace("{}::RefCount-- {} on channel {}", this, refCount, channelName, new Exception("Trace")); if (refCount == 0) { if (closeWrappedChannel) { closeChannel(); @@ -99,14 +99,14 @@ public class JChannelWrapper { connected = false; channel.setReceiver(null); if (logger.isTraceEnabled()) { - logger.trace(this + "::Closing Channel: " + channelName, new Exception("Trace")); + logger.trace("{}::Closing Channel: {}", this, channelName, new Exception("Trace")); } channel.close(); } public void removeReceiver(JGroupsReceiver receiver) { if (logger.isTraceEnabled()) - logger.trace(this + "::removeReceiver: " + receiver + " on " + channelName, new Exception("Trace")); + logger.trace("{}::removeReceiver: {} on {}", this, receiver, channelName, new Exception("Trace")); synchronized (receivers) { receivers.remove(receiver); } @@ -114,7 +114,7 @@ public class JChannelWrapper { public synchronized void connect() throws Exception { if (logger.isTraceEnabled()) { - logger.trace(this + ":: Connecting " + channelName, new Exception("Trace")); + logger.trace("{}:: Connecting {}", this, channelName, new Exception("Trace")); } // It is important to check this otherwise we could reconnect an already connected channel @@ -131,15 +131,17 @@ public class JChannelWrapper { public void addReceiver(JGroupsReceiver jGroupsReceiver) { synchronized (receivers) { - if (logger.isTraceEnabled()) - logger.trace(this + "::Add Receiver: " + jGroupsReceiver + " on " + channelName); + if (logger.isTraceEnabled()) { + logger.trace("{}::Add Receiver: {} on {}", this, jGroupsReceiver, channelName); + } receivers.add(jGroupsReceiver); } } public void send(org.jgroups.Message msg) throws Exception { - if (logger.isTraceEnabled()) - logger.trace(this + "::Sending JGroups Message: Open=" + channel.isOpen() + " on channel " + channelName + " msg=" + msg); + if (logger.isTraceEnabled()) { + logger.trace("{}::Sending JGroups Message: Open={} on channel {} msg={}", this, channel.isOpen(), channelName, msg); + } if (!manager.isLoopbackMessages()) { msg.setFlag(Message.TransientFlag.DONT_LOOPBACK); } @@ -148,8 +150,9 @@ public class JChannelWrapper { public JChannelWrapper addRef() { this.refCount++; - if (logger.isTraceEnabled()) - logger.trace(this + "::RefCount++ = " + refCount + " on channel " + channelName); + if (logger.isTraceEnabled()) { + logger.trace("{}::RefCount++ = {} on channel {}", this, refCount, channelName); + } return this; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JGroupsReceiver.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JGroupsReceiver.java index 3c1a22a0b3..f31acfa82e 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JGroupsReceiver.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/jgroups/JGroupsReceiver.java @@ -38,8 +38,7 @@ public class JGroupsReceiver implements Receiver { @Override public void receive(org.jgroups.Message msg) { - if (logger.isTraceEnabled()) - logger.trace("sending message " + msg); + logger.trace("sending message {}", msg); dequeue.add(msg.getArray()); } @@ -54,9 +53,9 @@ public class JGroupsReceiver implements Receiver { private void logBytes(String methodName, byte[] bytes) { if (bytes != null) { - logger.trace(methodName + "::" + bytes.length + " bytes"); + logger.trace("{}::{} bytes", methodName, bytes.length); } else { - logger.trace(methodName + ":: no bytes"); + logger.trace("{}:: no bytes", methodName); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/AbstractProducerCreditsImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/AbstractProducerCreditsImpl.java index 12d3e3ebdc..2e341fa9b3 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/AbstractProducerCreditsImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/AbstractProducerCreditsImpl.java @@ -89,6 +89,7 @@ public abstract class AbstractProducerCreditsImpl implements ClientProducerCredi if (logger.isDebugEnabled()) { logger.debug("AfterAcquire {} credits on address {}", credits, address); } + synchronized (this) { pendingCredits -= credits; } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java index f27ce80390..87b26f24c1 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientConsumerImpl.java @@ -180,7 +180,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { this.flowControlExecutor = flowControlExecutor; if (logger.isTraceEnabled()) { - logger.trace(this + ":: being created at", new Exception("trace")); + logger.trace("{}:: being created at", this, new Exception("trace")); } } @@ -194,14 +194,14 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { private ClientMessage receive(final long timeout, final boolean forcingDelivery) throws ActiveMQException { if (logger.isTraceEnabled()) { - logger.trace(this + "::receive(" + timeout + ", " + forcingDelivery + ")"); + logger.trace("{}::receive({}, {})", this, timeout, forcingDelivery); } checkClosed(); if (largeMessageReceived != null) { if (logger.isTraceEnabled()) { - logger.trace(this + "::receive(" + timeout + ", " + forcingDelivery + ") -> discard LargeMessage body for " + largeMessageReceived); + logger.trace("{}::receive({}, {}) -> discard LargeMessage body for {}", this, timeout, forcingDelivery, largeMessageReceived); } // Check if there are pending packets to be received largeMessageReceived.discardBody(); @@ -214,14 +214,14 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (handler != null) { if (logger.isTraceEnabled()) { - logger.trace(this + "::receive(" + timeout + ", " + forcingDelivery + ") -> throwing messageHandlerSet"); + logger.trace("{}::receive({}, {}) -> throwing messageHandlerSet", this, timeout, forcingDelivery); } throw ActiveMQClientMessageBundle.BUNDLE.messageHandlerSet(); } if (clientWindowSize == 0) { if (logger.isTraceEnabled()) { - logger.trace(this + "::receive(" + timeout + ", " + forcingDelivery + ") -> start slowConsumer"); + logger.trace("{}::receive({}, {}) -> start slowConsumer", this, timeout, forcingDelivery); } startSlowConsumer(); } @@ -280,7 +280,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (failedOver) { if (m == null) { if (logger.isTraceEnabled()) { - logger.trace(this + "::receive(" + timeout + ", " + forcingDelivery + ") -> m == null and failover"); + logger.trace("{}::receive({}, {}) -> m == null and failover", this, timeout, forcingDelivery); } // if failed over and the buffer is null, we reset the state and try it again @@ -290,16 +290,14 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { continue; } else { if (logger.isTraceEnabled()) { - logger.trace(this + "::receive(" + timeout + ", " + forcingDelivery + ") -> failedOver, but m != null, being " + m); + logger.trace("{}::receive({}, {}) -> failedOver, but m != null, being {}", this, timeout, forcingDelivery, m); } failedOver = false; } } if (callForceDelivery) { - if (logger.isTraceEnabled()) { - logger.trace(this + "::Forcing delivery"); - } + logger.trace("{}::Forcing delivery", this); // JBPAPP-6030 - Calling forceDelivery outside of the lock to avoid distributed dead locks sessionContext.forceDelivery(this, forceDeliveryCount.getAndIncrement()); callForceDelivery = false; @@ -318,16 +316,11 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (forcingDelivery && deliveryForced && seq == forceDeliveryCount.get() - 1) { // forced delivery messages are discarded, nothing has been delivered by the queue resetIfSlowConsumer(); - - if (logger.isTraceEnabled()) { - logger.trace(this + "::There was nothing on the queue, leaving it now:: returning null"); - } + logger.trace("{}::There was nothing on the queue, leaving it now:: returning null", this); return null; } else { - if (logger.isTraceEnabled()) { - logger.trace(this + "::Ignored force delivery answer as it belonged to another call"); - } + logger.trace("{}::Ignored force delivery answer as it belonged to another call", this); // Ignore the message continue; } @@ -357,15 +350,11 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { largeMessageReceived = m; } - if (logger.isTraceEnabled()) { - logger.trace(this + "::Returning " + m); - } + logger.trace("{}::Returning {}", this, m); return m; } else { - if (logger.isTraceEnabled()) { - logger.trace(this + "::Returning null"); - } + logger.trace("{}::Returning null", this); resetIfSlowConsumer(); return null; } @@ -377,22 +366,17 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { @Override public ClientMessage receive(final long timeout) throws ActiveMQException { - - if (logger.isTraceEnabled()) { - logger.trace(this + ":: receive(" + timeout + ")"); - } + logger.trace("{}:: receive({})", this, timeout); ClientMessage msg = receive(timeout, false); if (msg == null && !closed) { if (logger.isTraceEnabled()) { - logger.trace(this + ":: receive(" + timeout + ") -> null, trying again with receive(0)"); + logger.trace("{}:: receive({}) -> null, trying again with receive(0)", this, timeout); } msg = receive(0, true); } - if (logger.isTraceEnabled()) { - logger.trace(this + ":: returning " + msg); - } + logger.trace("{}:: returning {}", this, msg); return msg; } @@ -513,9 +497,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { @Override public void clearAtFailover() { - if (logger.isTraceEnabled()) { - logger.trace(this + "::ClearAtFailover"); - } + logger.trace("{}::ClearAtFailover", this); clearBuffer(); // failover will issue a start later @@ -699,7 +681,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { } if (currentLargeMessageController == null) { if (logger.isTraceEnabled()) { - logger.trace(this + "::Sending back credits for largeController = null " + flowControlSize); + logger.trace("{}::Sending back credits for largeController = null {}", this, flowControlSize); } flowControl(flowControlSize, false); } else { @@ -777,18 +759,14 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { ackBytes += message.getEncodeSize(); if (logger.isTraceEnabled()) { - logger.trace(this + "::acknowledge ackBytes=" + ackBytes + " and ackBatchSize=" + ackBatchSize + ", encodeSize=" + message.getEncodeSize()); + logger.trace("{}::acknowledge ackBytes={} and ackBatchSize={}, encodeSize={}", this, ackBytes, ackBatchSize, message.getEncodeSize()); } if (ackBytes >= ackBatchSize) { - if (logger.isTraceEnabled()) { - logger.trace(this + ":: acknowledge acking " + cmi); - } + logger.trace("{}:: acknowledge acking {}", this, cmi); doAck(cmi); } else { - if (logger.isTraceEnabled()) { - logger.trace(this + ":: acknowledge setting lastAckedMessage = " + cmi); - } + logger.trace("{}:: acknowledge setting lastAckedMessage = {}", this, cmi); lastAckedMessage = cmi; } } @@ -806,9 +784,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { @Override public void flushAcks() throws ActiveMQException { if (lastAckedMessage != null) { - if (logger.isTraceEnabled()) { - logger.trace(this + "::FlushACK acking lastMessage::" + lastAckedMessage); - } + logger.trace("{}::FlushACK acking lastMessage::{}", this, lastAckedMessage); doAck(lastAckedMessage); } } @@ -827,7 +803,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { if (creditsToSend >= clientWindowSize) { if (clientWindowSize == 0 && discountSlowConsumer) { if (logger.isTraceEnabled()) { - logger.trace(this + "::FlowControl::Sending " + creditsToSend + " -1, for slow consumer"); + logger.trace("{}::FlowControl::Sending {}-1, for slow consumer", this, creditsToSend); } // sending the credits - 1 initially send to fire the slow consumer, or the slow consumer would be @@ -841,7 +817,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { } } else { if (logger.isDebugEnabled()) { - logger.debug("Sending " + messageBytes + " from flow-control"); + logger.debug("Sending {} from flow-control", messageBytes); } final int credits = creditsToSend; @@ -860,9 +836,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { * Sending an initial credit for slow consumers */ private void startSlowConsumer() { - if (logger.isTraceEnabled()) { - logger.trace(this + "::Sending 1 credit to start delivering of one message to slow consumer"); - } + logger.trace("{}::Sending 1 credit to start delivering of one message to slow consumer", this); sendCredits(1); try { // We use an executor here to guarantee the messages will arrive in order. @@ -903,10 +877,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { } private void queueExecutor() { - if (logger.isTraceEnabled()) { - logger.trace(this + "::Adding Runner on Executor for delivery"); - } - + logger.trace("{}::Adding Runner on Executor for delivery", this); sessionExecutor.execute(runner); } @@ -993,9 +964,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { flowControlBeforeConsumption(message); if (!expired) { - if (logger.isTraceEnabled()) { - logger.trace(this + "::Calling handler.onMessage"); - } + logger.trace("{}::Calling handler.onMessage", this); final ClassLoader originalLoader = safeInstallContextClassLoader(); onMessageThread = Thread.currentThread(); @@ -1011,9 +980,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { onMessageThread = null; } - if (logger.isTraceEnabled()) { - logger.trace(this + "::Handler.onMessage done"); - } + logger.trace("{}::Handler.onMessage done", this); if (message.isLargeMessage()) { message.discardBody(); @@ -1133,9 +1100,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal { lastAckedMessage = null; - if (logger.isTraceEnabled()) { - logger.trace(this + "::Acking message " + message); - } + logger.trace("{}::Acking message {}", this, message); session.acknowledge(this, message); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java index d18c0916e8..a4e4a7eb99 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientProducerImpl.java @@ -142,9 +142,7 @@ public class ClientProducerImpl implements ClientProducerInternal { doSend(address1, message, handler); if (handler != null && !session.isConfirmationWindowEnabled()) { - if (logger.isDebugEnabled()) { - logger.debug("Handler was used on producing messages towards address " + address1 + " however there is no confirmationWindowEnabled"); - } + logger.debug("Handler was used on producing messages towards address {} however there is no confirmationWindowEnabled", address1); // if there is no confirmation enabled, we will at least call the handler after the sent is done session.scheduleConfirmation(handler, message); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java index 35484b7bb5..2a5c5d4030 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java @@ -287,17 +287,12 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if (localConnector.isEquivalent(live.getParams()) && backUp != null && !localConnector.isEquivalent(backUp.getParams()) // check if a server is trying to set its cluster connector config as backup connector config && !(serverLocator.getClusterTransportConfiguration() != null && serverLocator.getClusterTransportConfiguration().isSameParams(backUp))) { - if (logger.isDebugEnabled()) { - logger.debug("Setting up backup config = " + backUp + " for live = " + live); - } + logger.debug("Setting up backup config = {} for live = {}", backUp, live); backupConnectorConfig = backUp; } else { if (logger.isDebugEnabled()) { - logger.debug("ClientSessionFactoryImpl received backup update for live/backup pair = " + live + - " / " + - backUp + - " but it didn't belong to " + - currentConnectorConfig); + logger.debug("ClientSessionFactoryImpl received backup update for live/backup pair = {} / {} but it didn't belong to {}", + live, backUp, currentConnectorConfig); } } } @@ -583,8 +578,8 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C return; } - if (ClientSessionFactoryImpl.logger.isTraceEnabled()) { - logger.trace("Client Connection failed, calling failure listeners and trying to reconnect, reconnectAttempts=" + reconnectAttempts); + if (logger.isTraceEnabled()) { + logger.trace("Client Connection failed, calling failure listeners and trying to reconnect, reconnectAttempts={}", reconnectAttempts); } callFailoverListeners(FailoverEventType.FAILURE_DETECTED); @@ -847,11 +842,8 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if (!clientProtocolManager.isAlive()) return; if (logger.isTraceEnabled()) { - logger.trace("getConnectionWithRetry::" + reconnectAttempts + - " with retryInterval = " + - retryInterval + - " multiplier = " + - retryIntervalMultiplier, new Exception("trace")); + logger.trace("getConnectionWithRetry::{} with retryInterval = {} multiplier = {}", + reconnectAttempts, retryInterval, retryIntervalMultiplier, new Exception("trace")); } long interval = retryInterval; @@ -860,7 +852,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C while (clientProtocolManager.isAlive()) { if (logger.isDebugEnabled()) { - logger.debug("Trying reconnection attempt " + count + "/" + reconnectAttempts); + logger.debug("Trying reconnection attempt {}/{}", count, reconnectAttempts); } if (getConnection() != null) { @@ -868,9 +860,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C // transferring old connection version into the new connection ((CoreRemotingConnection)connection).setChannelVersion(((CoreRemotingConnection)oldConnection).getChannelVersion()); } - if (logger.isDebugEnabled()) { - logger.debug("Reconnection successful"); - } + logger.debug("Reconnection successful"); return; } else { // Failed to get connection @@ -886,8 +876,8 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C return; } - if (ClientSessionFactoryImpl.logger.isTraceEnabled()) { - ClientSessionFactoryImpl.logger.trace("Waiting " + interval + " milliseconds before next retry. RetryInterval=" + retryInterval + " and multiplier=" + retryIntervalMultiplier); + if (logger.isTraceEnabled()) { + logger.trace("Waiting {} milliseconds before next retry. RetryInterval={} and multiplier={}", interval, retryInterval, retryIntervalMultiplier); } if (waitForRetry(interval)) @@ -1001,13 +991,13 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if (serverLocator.getTopology() != null) { if (connection != null) { - if (ClientSessionFactoryImpl.logger.isTraceEnabled()) { - logger.trace(this + "::Subscribing Topology"); - } + logger.trace("{}::Subscribing Topology", this); clientProtocolManager.sendSubscribeTopology(serverLocator.isClusterConnection()); } } else { - logger.debug("serverLocator@" + System.identityHashCode(serverLocator + " had no topology")); + if (logger.isDebugEnabled()) { + logger.debug("serverLocator@{} had no topology", System.identityHashCode(serverLocator)); + } } return connection; @@ -1115,9 +1105,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C Connection transportConnection = connector.createConnection(); if (transportConnection == null) { - if (logger.isDebugEnabled()) { - logger.debug("Connector towards " + connector + " failed"); - } + logger.debug("Connector towards {} failed", connector); try { connector.close(); @@ -1216,8 +1204,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C transportConnectorConfig.getFactoryClassName()); if (logger.isDebugEnabled()) { - logger.debug("Trying to connect with connectorFactory=" + transportConnectorFactory - + " and " + name + "ConnectorConfig: " + transportConnectorConfig); + logger.debug("Trying to connect with connectorFactory={} and {}ConnectorConfig: {}", transportConnectorFactory, name, transportConnectorConfig); } Connector transportConnector = createConnector(transportConnectorFactory, transportConnectorConfig); @@ -1225,9 +1212,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C Connection transportConnection = openTransportConnection(transportConnector); if (transportConnection != null) { - if (logger.isDebugEnabled()) { - logger.debug("Connected with the " + name + "ConnectorConfig=" + transportConnectorConfig); - } + logger.debug("Connected with the {}ConnectorConfig={}", name, transportConnectorConfig); connector = transportConnector; connectorFactory = transportConnectorFactory; @@ -1390,9 +1375,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C Connection transportConnection = createTransportConnection(); if (transportConnection == null) { - if (ClientSessionFactoryImpl.logger.isTraceEnabled()) { - logger.trace("Neither backup or live were active, will just give up now"); - } + logger.trace("Neither backup or live were active, will just give up now"); return null; } @@ -1402,9 +1385,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C schedulePing(); - if (logger.isTraceEnabled()) { - logger.trace("returning " + newConnection); - } + logger.trace("returning {}", newConnection); return newConnection; } @@ -1433,13 +1414,8 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C public void nodeDisconnected(RemotingConnection conn, String nodeID, DisconnectReason reason, String targetNodeID, TransportConfiguration tagetConnector) { if (logger.isTraceEnabled()) { - logger.trace("Disconnect being called on client:" + - " server locator = " + - serverLocator + - " notifying node " + - nodeID + - " as down with reason " + - reason, new Exception("trace")); + logger.trace("Disconnect being called on client: server locator = {} notifying node {} as down with reason {}", + serverLocator, nodeID, reason, new Exception("trace")); } serverLocator.notifyNodeDown(System.currentTimeMillis(), nodeID); @@ -1451,11 +1427,11 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C if (topologyMember != null) { if (topologyMember.getConnector().getB() != null) { backupConnectorConfig = topologyMember.getConnector().getB(); - } else if (logger.isDebugEnabled()) { - logger.debug("The topology member " + nodeID + " with connector " + tagetConnector + " has no backup"); + } else { + logger.debug("The topology member {} with connector {} has no backup", nodeID, tagetConnector); } - } else if (logger.isDebugEnabled()) { - logger.debug("The topology member " + nodeID + " with connector " + tagetConnector + " not found"); + } else { + logger.debug("The topology member {} with connector {} not found", nodeID, tagetConnector); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java index 09c0fa75dc..dbafef1e03 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java @@ -946,9 +946,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi public void commit(boolean block) throws ActiveMQException { checkClosed(); - if (logger.isTraceEnabled()) { - logger.trace("Sending commit"); - } + logger.trace("Sending commit"); /* * we have failed over since any work was done so we should rollback @@ -1004,8 +1002,9 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi public void rollback(final boolean isLastMessageAsDelivered, final boolean waitConsumers) throws ActiveMQException { if (logger.isTraceEnabled()) { - logger.trace("calling rollback(isLastMessageAsDelivered=" + isLastMessageAsDelivered + ")"); + logger.trace("calling rollback(isLastMessageAsDelivered={})", isLastMessageAsDelivered); } + checkClosed(); // We do a "JMS style" rollback where the session is stopped, and the buffer is cancelled back @@ -1204,8 +1203,9 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi } checkClosed(); + if (logger.isDebugEnabled()) { - logger.debug("client ack messageID = " + message.getMessageID()); + logger.debug("client ack messageID = {}", message.getMessageID()); } startCall(); @@ -1326,13 +1326,11 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi @Override public void close() throws ActiveMQException { if (closed) { - logger.debug("Session was already closed, giving up now, this=" + this); + logger.debug("Session was already closed, giving up now, this={}", this); return; } - if (logger.isDebugEnabled()) { - logger.debug("Calling close on session " + this); - } + logger.debug("Calling close on session {}", this); try { closeChildren(); @@ -1605,7 +1603,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi @Override public void commit(final Xid xid, final boolean onePhase) throws XAException { if (logger.isTraceEnabled()) { - logger.trace("call commit(xid=" + convert(xid)); + logger.trace("call commit(xid={}", convert(xid)); } checkXA(); @@ -1632,11 +1630,11 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi XAException xaException; if (onePhase) { - logger.debug("Throwing oneFase RMFAIL on xid=" + xid, t); + logger.debug("Throwing oneFase RMFAIL on xid={}", xid, t); //we must return XA_RMFAIL xaException = new XAException(XAException.XAER_RMFAIL); } else { - logger.debug("Throwing twoFase Retry on xid=" + xid, t); + logger.debug("Throwing twoFase Retry on xid={}", xid, t); // Any error on commit -> RETRY // We can't rollback a Prepared TX for definition xaException = new XAException(XAException.XA_RETRY); @@ -1652,7 +1650,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi @Override public void end(final Xid xid, final int flags) throws XAException { if (logger.isTraceEnabled()) { - logger.trace("Calling end:: " + convert(xid) + ", flags=" + convertTXFlag(flags)); + logger.trace("Calling end:: {}, flags={}", convert(xid), convertTXFlag(flags)); } checkXA(); @@ -1778,7 +1776,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi public int prepare(final Xid xid) throws XAException { checkXA(); if (logger.isTraceEnabled()) { - logger.trace("Calling prepare:: " + convert(xid)); + logger.trace("Calling prepare:: {}", convert(xid)); } if (rollbackOnly) { @@ -1858,7 +1856,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi checkXA(); if (logger.isTraceEnabled()) { - logger.trace("Calling rollback:: " + convert(xid)); + logger.trace("Calling rollback:: {}", convert(xid)); } try { @@ -1907,7 +1905,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi @Override public void start(final Xid xid, final int flags) throws XAException { if (logger.isTraceEnabled()) { - logger.trace("Calling start:: " + convert(xid) + " clientXID=" + xid + " flags = " + convertTXFlag(flags)); + logger.trace("Calling start:: {} clientXID={} flags = {}", convert(xid), xid, convertTXFlag(flags)); } checkXA(); @@ -2079,9 +2077,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi } private void doCleanup(boolean failingOver) { - if (logger.isDebugEnabled()) { - logger.debug("calling cleanup on " + this); - } + logger.debug("calling cleanup on {}", this); synchronized (this) { closed = true; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java index 03e6b533fe..127a3ea0f4 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java @@ -438,17 +438,13 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery synchronized (this) { if (usedTopology != null && config.useTopologyForLoadBalancing && !useInitConnector) { - if (logger.isTraceEnabled()) { - logger.trace("Selecting connector from topology."); - } + logger.trace("Selecting connector from topology."); int pos = loadBalancingPolicy.select(usedTopology.length); Pair pair = usedTopology[pos]; return pair; } else { - if (logger.isTraceEnabled()) { - logger.trace("Selecting connector from initial connectors."); - } + logger.trace("Selecting connector from initial connectors."); int pos = loadBalancingPolicy.select(initialConnectors.length); @@ -573,7 +569,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery TopologyMember topologyMember = topology.getMember(nodeID); if (logger.isTraceEnabled()) { - logger.trace("Creating connection factory towards " + nodeID + " = " + topologyMember + ", topology=" + topology.describe()); + logger.trace("Creating connection factory towards {} = {}, topology={}", nodeID, topologyMember, topology.describe()); } if (topologyMember == null) { @@ -1320,9 +1316,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery private void doClose(final boolean sendClose) { synchronized (stateGuard) { if (state == STATE.CLOSED) { - if (logger.isDebugEnabled()) { - logger.debug(this + " is already closed when calling closed"); - } + logger.debug("{} is already closed when calling closed", this); return; } @@ -1427,7 +1421,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery } if (logger.isTraceEnabled()) { - logger.trace("nodeDown " + this + " nodeID=" + nodeID + " as being down", new Exception("trace")); + logger.trace("nodeDown {} nodeID={} as being down", this, nodeID, new Exception("trace")); } topology.removeMember(eventTime, nodeID); @@ -1458,7 +1452,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery final Pair connectorPair, final boolean last) { if (logger.isTraceEnabled()) { - logger.trace("NodeUp " + this + "::nodeID=" + nodeID + ", connectorPair=" + connectorPair, new Exception("trace")); + logger.trace("NodeUp {}::nodeID={}, connectorPair={}", this, nodeID, connectorPair, new Exception("trace")); } TopologyMemberImpl member = new TopologyMemberImpl(nodeID, backupGroupName, scaleDownGroupName, connectorPair.getA(), connectorPair.getB()); @@ -1674,9 +1668,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery while (!isClosed()) { retryNumber++; for (Connector conn : connectors) { - if (logger.isTraceEnabled()) { - logger.trace(this + "::Submitting connect towards " + conn); - } + logger.trace("{}::Submitting connect towards {}", this, conn); ClientSessionFactory csf = conn.tryConnect(); @@ -1710,11 +1702,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery }); if (logger.isTraceEnabled()) { - logger.trace("Returning " + csf + - " after " + - retryNumber + - " retries on StaticConnector " + - ServerLocatorImpl.this); + logger.trace("Returning {} after {} retries on StaticConnector {}", csf, retryNumber, ServerLocatorImpl.this); } return csf; @@ -1787,9 +1775,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery } public ClientSessionFactory tryConnect() throws ActiveMQException { - if (logger.isDebugEnabled()) { - logger.trace(this + "::Trying to connect to " + factory); - } + logger.trace("{}::Trying to connect to {}", this, factory); try { ClientSessionFactoryInternal factoryToUse = factory; if (factoryToUse != null) { @@ -1803,7 +1789,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery } return factoryToUse; } catch (ActiveMQException e) { - logger.trace(this + "::Exception on establish connector initial connection", e); + logger.trace("{}::Exception on establish connector initial connection", this, e); return null; } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java index 032704db9d..d53439f577 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java @@ -90,7 +90,7 @@ public final class Topology { manager = null; } if (logger.isTraceEnabled()) { - logger.trace("Topology@" + Integer.toHexString(System.identityHashCode(this)) + " CREATE", new Exception("trace")); + logger.trace("Topology@{} CREATE", Integer.toHexString(System.identityHashCode(this)), new Exception("trace")); } } @@ -108,7 +108,7 @@ public final class Topology { public void addClusterTopologyListener(final ClusterTopologyListener listener) { if (logger.isTraceEnabled()) { - logger.trace(this + "::Adding topology listener " + listener, new Exception("Trace")); + logger.trace("{}::Adding topology listener {}", this, listener, new Exception("Trace")); } synchronized (topologyListeners) { topologyListeners.add(listener); @@ -118,7 +118,7 @@ public final class Topology { public void removeClusterTopologyListener(final ClusterTopologyListener listener) { if (logger.isTraceEnabled()) { - logger.trace(this + "::Removing topology listener " + listener, new Exception("Trace")); + logger.trace("{}::Removing topology listener {}", this, listener, new Exception("Trace")); } synchronized (topologyListeners) { topologyListeners.remove(listener); @@ -131,7 +131,7 @@ public final class Topology { public void updateAsLive(final String nodeId, final TopologyMemberImpl memberInput) { synchronized (this) { if (logger.isDebugEnabled()) { - logger.debug(this + "::node " + nodeId + "=" + memberInput); + logger.debug("{}::node {}={}", this, nodeId, memberInput); } memberInput.setUniqueEventID(System.currentTimeMillis()); topology.remove(nodeId); @@ -161,14 +161,14 @@ public final class Topology { public TopologyMemberImpl updateBackup(final TopologyMemberImpl memberInput) { final String nodeId = memberInput.getNodeId(); if (logger.isTraceEnabled()) { - logger.trace(this + "::updateBackup::" + nodeId + ", memberInput=" + memberInput); + logger.trace("{}::updateBackup::{}, memberInput={}", this, nodeId, memberInput); } synchronized (this) { TopologyMemberImpl currentMember = getMember(nodeId); if (currentMember == null) { if (logger.isTraceEnabled()) { - logger.trace("There's no live to be updated on backup update, node=" + nodeId + " memberInput=" + memberInput, new Exception("trace")); + logger.trace("There's no live to be updated on backup update, node={} memberInput={}", nodeId, memberInput, new Exception("trace")); } currentMember = memberInput; @@ -196,12 +196,10 @@ public final class Topology { Long deleteTme = getMapDelete().get(nodeId); if (deleteTme != null && uniqueEventID != 0 && uniqueEventID < deleteTme) { - logger.debug("Update uniqueEvent=" + uniqueEventID + - ", nodeId=" + - nodeId + - ", memberInput=" + - memberInput + - " being rejected as there was a delete done after that"); + if (logger.isDebugEnabled()) { + logger.debug("Update uniqueEvent={}, nodeId={}, memberInput={} being rejected as there was a delete done after that", + uniqueEventID, nodeId, memberInput); + } return false; } @@ -215,7 +213,7 @@ public final class Topology { if (currentMember == null) { if (logger.isTraceEnabled()) { - logger.trace(this + "::NewMemberAdd nodeId=" + nodeId + " member = " + memberInput, new Exception("trace")); + logger.trace("{}::NewMemberAdd nodeId={} member = {}", this, nodeId, memberInput, new Exception("trace")); } memberInput.setUniqueEventID(uniqueEventID); topology.put(nodeId, memberInput); @@ -234,9 +232,8 @@ public final class Topology { } if (logger.isTraceEnabled()) { - logger.trace(this + "::updated currentMember=nodeID=" + nodeId + ", currentMember=" + - currentMember + ", memberInput=" + memberInput + "newMember=" + - newMember, new Exception("trace")); + logger.trace("{}::updated currentMember=nodeID={}, currentMember={}, memberInput={} newMember={}", + this, nodeId, currentMember, memberInput, newMember, new Exception("trace")); } if (uniqueEventID > currentMember.getUniqueEventID()) { @@ -270,7 +267,7 @@ public final class Topology { final ArrayList copy = copyListeners(); if (logger.isTraceEnabled()) { - logger.trace(this + "::prepare to send " + nodeId + " to " + copy.size() + " elements"); + logger.trace("{}::prepare to send {} to {} elements", this, nodeId, copy.size()); } if (copy.size() > 0) { @@ -279,12 +276,8 @@ public final class Topology { public void run() { for (ClusterTopologyListener listener : copy) { if (logger.isTraceEnabled()) { - logger.trace(Topology.this + " informing " + - listener + - " about node up = " + - nodeId + - " connector = " + - memberToSend.getConnector()); + logger.trace("{} informing {} about node up = {} connector = {}", + Topology.this, listener, nodeId, memberToSend.getConnector()); } try { @@ -322,7 +315,7 @@ public final class Topology { member = topology.get(nodeId); if (member != null) { if (member.getUniqueEventID() > uniqueEventID) { - logger.debug("The removeMember was issued before the node " + nodeId + " was started, ignoring call"); + logger.debug("The removeMember was issued before the node {} was started, ignoring call", nodeId); member = null; } else { getMapDelete().put(nodeId, uniqueEventID); @@ -332,13 +325,8 @@ public final class Topology { } if (logger.isTraceEnabled()) { - logger.trace("removeMember " + this + - " removing nodeID=" + - nodeId + - ", result=" + - member + - ", size = " + - topology.size(), new Exception("trace")); + logger.trace("removeMember {} removing nodeID={}, result={}, size = {}", + this, nodeId, member, topology.size(), new Exception("trace")); } if (member != null) { @@ -349,7 +337,7 @@ public final class Topology { public void run() { for (ClusterTopologyListener listener : copy) { if (logger.isTraceEnabled()) { - logger.trace(this + " informing " + listener + " about node down = " + nodeId); + logger.trace("{} informing {} about node down = {}", this, listener, nodeId); } try { listener.nodeDown(uniqueEventID, nodeId); @@ -364,9 +352,7 @@ public final class Topology { } public synchronized void sendTopology(final ClusterTopologyListener listener) { - if (logger.isDebugEnabled()) { - logger.debug(this + " is sending topology to " + listener); - } + logger.debug("{} is sending topology to {}", this, listener); executor.execute(new Runnable() { @Override @@ -381,12 +367,7 @@ public final class Topology { for (Map.Entry entry : copy.entrySet()) { if (logger.isDebugEnabled()) { - logger.debug(Topology.this + " sending " + - entry.getKey() + - " / " + - entry.getValue().getConnector() + - " to " + - listener); + logger.debug("{} sending {} / {} to {}", Topology.this, entry.getKey(), entry.getValue().getConnector(), listener); } listener.nodeUP(entry.getValue(), ++count == copy.size()); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java index e0342a4b4b..b7bb3d133d 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/cluster/DiscoveryGroup.java @@ -108,7 +108,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { return; } - if (logger.isDebugEnabled()) logger.debug("Starting Discovery Group for " + name); + logger.debug("Starting Discovery Group for {}", name); endpoint.openClient(); @@ -123,7 +123,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { thread = tfactory.newThread(new DiscoveryRunnable()); - if (logger.isDebugEnabled()) logger.debug("Starting daemon thread"); + logger.debug("Starting daemon thread"); thread.start(); @@ -169,9 +169,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { try { endpoint.close(false); - if (logger.isDebugEnabled()) { - logger.debug("endpoing closed"); - } + logger.debug("endpoing closed"); } catch (Exception e1) { ActiveMQClientLogger.LOGGER.errorStoppingDiscoveryBroadcastEndpoint(endpoint, e1); } @@ -279,14 +277,12 @@ public final class DiscoveryGroup implements ActiveMQComponent { ActiveMQClientLogger.LOGGER.unexpectedNullDataReceived(); } - if (logger.isDebugEnabled()) { - logger.debug("Received broadcast data as null"); - } + logger.debug("Received broadcast data as null"); break; } if (logger.isDebugEnabled()) { - logger.debug("receiving " + data.length); + logger.debug("receiving {}", data.length); } } catch (Exception e) { if (!started) { @@ -306,9 +302,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { if (nodeID.equals(originatingNodeID)) { - if (logger.isDebugEnabled()) { - logger.debug("ignoring original NodeID" + originatingNodeID + " receivedID = " + nodeID); - } + logger.debug("ignoring original NodeID{} receivedID = {}", originatingNodeID, nodeID); if (checkExpiration()) { callListeners(); } @@ -316,9 +310,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { continue; } - if (logger.isDebugEnabled()) { - logger.debug("Received nodeID " + nodeID + " with originatingID = " + originatingNodeID); - } + logger.debug("Received nodeID{} with originatingID = {}", nodeID, originatingNodeID); int size = buffer.readInt(); @@ -336,9 +328,9 @@ public final class DiscoveryGroup implements ActiveMQComponent { if (logger.isDebugEnabled()) { - logger.debug("Received " + entriesRead.length + " discovery entry elements"); + logger.debug("Received {} discovery entry elements", entriesRead.length); for (DiscoveryEntry entryDisco : entriesRead) { - logger.debug("" + entryDisco); + logger.debug("{}", entryDisco); } } @@ -353,7 +345,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { changed = changed || checkExpiration(); if (logger.isDebugEnabled()) { - logger.debug("changed = " + changed); + logger.debug("changed = {}", changed); } } //only call the listeners if we have changed @@ -365,18 +357,13 @@ public final class DiscoveryGroup implements ActiveMQComponent { logger.trace("{}", connector); } } - if (logger.isDebugEnabled()) { - logger.debug("Calling listeners"); - } + logger.debug("Calling listeners"); callListeners(); } synchronized (waitLock) { received = true; - - if (logger.isDebugEnabled()) { - logger.debug("Calling notifyAll"); - } + logger.debug("Calling notifyAll"); waitLock.notifyAll(); } } catch (Throwable e) { @@ -422,9 +409,7 @@ public final class DiscoveryGroup implements ActiveMQComponent { Map.Entry entry = iter.next(); if (entry.getValue().getLastUpdate() + timeout <= now) { - if (logger.isTraceEnabled()) { - logger.trace("Timed out node on discovery:" + entry.getValue()); - } + logger.trace("Timed out node on discovery:{}", entry.getValue()); iter.remove(); changed = true; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java index 9a7c8c5008..cd47eb625d 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/impl/CoreMessage.java @@ -625,16 +625,16 @@ public class CoreMessage extends RefCountMessage implements ICoreMessage { private RuntimeException onCheckPropertiesError(Throwable e) { // This is not an expected error, hence no specific logger created - logger.warn("Could not decode properties for CoreMessage[messageID=" + messageID + ",durable=" + durable + ",userID=" + userID + ",priority=" + priority + - ", timestamp=" + timestamp + ",expiration=" + expiration + ",address=" + address + ", propertiesLocation=" + propertiesLocation, e); + logger.warn("Could not decode properties for CoreMessage[messageID={},durable={},userID={},priority={}, timestamp={},expiration={},address={}, propertiesLocation={}", + messageID, durable, userID, priority, timestamp, expiration, address, propertiesLocation, e); final ByteBuf buffer = this.buffer; if (buffer != null) { //risky: a racy modification to buffer indexes could break this duplicate operation final ByteBuf duplicatebuffer = buffer.duplicate(); duplicatebuffer.readerIndex(0); - logger.warn("Failed message has messageID=" + messageID + " and the following buffer:\n" + ByteBufUtil.prettyHexDump(duplicatebuffer)); + logger.warn("Failed message has messageID={} and the following buffer:\n{}", messageID, ByteBufUtil.prettyHexDump(duplicatebuffer)); } else { - logger.warn("Failed message has messageID=" + messageID + " and the buffer was null"); + logger.warn("Failed message has messageID={} and the buffer was null", messageID); } return new RuntimeException(e.getMessage(), e); } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java index 0e375d4c6e..1e960fb7a5 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQClientProtocolManager.java @@ -529,9 +529,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager { } if (topMessage.isExit()) { - if (logger.isDebugEnabled()) { - logger.debug("Notifying " + topMessage.getNodeID() + " going down"); - } + logger.debug("Notifying {} going down", topMessage.getNodeID()); if (topologyResponseHandler != null) { topologyResponseHandler.notifyNodeDown(eventUID, topMessage.getNodeID()); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java index f5bf232a96..0cc1013f6b 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQSessionContext.java @@ -498,7 +498,7 @@ public class ActiveMQSessionContext extends SessionContext { } if (logger.isTraceEnabled()) { - logger.trace("finished commit on " + ClientSessionImpl.convert(xid) + " with response = " + response); + logger.trace("finished commit on {} with response = {}", ClientSessionImpl.convert(xid), response); } } @@ -662,7 +662,7 @@ public class ActiveMQSessionContext extends SessionContext { buffer.append(","); } } - logger.trace("xaScan returning " + xidArray.length + " xids = [" + buffer.toString() + "]"); + logger.trace("xaScan returning {} xids = [{}]", xidArray.length, buffer.toString()); } return xidArray; diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java index d89d3f6b1c..d7fa20df9b 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ChannelImpl.java @@ -261,7 +261,8 @@ public final class ChannelImpl implements Channel { } if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Sending packet nonblocking " + packet + " on channelID=" + id); + logger.trace("RemotingConnectionID={} Sending packet nonblocking {} on channelID={}", + (connection == null ? "NULL" : connection.getID()), packet, id); } ActiveMQBuffer buffer = packet.encode(connection); @@ -287,7 +288,7 @@ public final class ChannelImpl implements Channel { } if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Writing buffer for channelID=" + id); + logger.trace("RemotingConnectionID={} Writing buffer for channelID={}", (connection == null ? "NULL" : connection.getID()), id); } //We do this outside the lock as ResponseCache is threadsafe and allows responses to come in, @@ -378,7 +379,8 @@ public final class ChannelImpl implements Channel { } if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Sending packet nonblocking " + packet + " on channelID=" + id); + logger.trace("RemotingConnectionID={} Sending packet nonblocking {} on channelID={}", + (connection == null ? "NULL" : connection.getID()), packet, id); } ActiveMQBuffer buffer = packet.encode(connection); @@ -404,7 +406,7 @@ public final class ChannelImpl implements Channel { } if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Writing buffer for channelID=" + id); + logger.trace("RemotingConnectionID={} Writing buffer for channelID={}", (connection == null ? "NULL" : connection.getID()), id); } checkReconnectID(reconnectID); @@ -461,7 +463,7 @@ public final class ChannelImpl implements Channel { if (interceptionResult != null) { if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " interceptionResult=" + interceptionResult); + logger.trace("RemotingConnectionID={} interceptionResult={}", (connection == null ? "NULL" : connection.getID()), interceptionResult); } // if we don't throw an exception here the client might not unblock throw ActiveMQClientMessageBundle.BUNDLE.interceptorRejectedPacket(interceptionResult); @@ -469,14 +471,14 @@ public final class ChannelImpl implements Channel { if (closed) { if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " closed."); + logger.trace("RemotingConnectionID={} closed.", (connection == null ? "NULL" : connection.getID())); } throw ActiveMQClientMessageBundle.BUNDLE.connectionDestroyed(); } if (connection.getBlockingCallTimeout() == -1) { if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Cannot do a blocking call timeout on a server side connection"); + logger.trace("RemotingConnectionID={} Cannot do a blocking call timeout on a server side connection", (connection == null ? "NULL" : connection.getID())); } throw new IllegalStateException("Cannot do a blocking call timeout on a server side connection"); } @@ -506,7 +508,7 @@ public final class ChannelImpl implements Channel { checkReconnectID(reconnectID); if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Sending blocking " + packet); + logger.trace("RemotingConnectionID={} Sending blocking {}", (connection == null ? "NULL" : connection.getID()), packet); } connection.getTransportConnection().write(buffer, false, false); @@ -603,7 +605,7 @@ public final class ChannelImpl implements Channel { if (confWindowSize < 0) { final String msg = "You can't set confirmationHandler on a connection with confirmation-window-size < 0." + " Look at the documentation for more information."; if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " " + msg); + logger.trace("RemotingConnectionID={} {}", (connection == null ? "NULL" : connection.getID()), msg); } throw new IllegalStateException(msg); } @@ -615,7 +617,7 @@ public final class ChannelImpl implements Channel { if (confWindowSize < 0) { final String msg = "You can't set responseHandler on a connection with confirmation-window-size < 0." + " Look at the documentation for more information."; if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " " + msg); + logger.trace("RemotingConnectionID={} {}", (connection == null ? "NULL" : connection.getID()), msg); } throw new IllegalStateException(msg); } @@ -625,7 +627,7 @@ public final class ChannelImpl implements Channel { @Override public void setHandler(final ChannelHandler handler) { if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Setting handler on " + this + " as " + handler); + logger.trace("RemotingConnectionID={} Setting handler on {} as {}", (connection == null ? "NULL" : connection.getID()), this, handler); } this.handler = handler; @@ -673,7 +675,9 @@ public final class ChannelImpl implements Channel { connection.removeChannel(id); if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " transferConnection to new RemotingConnectionID=" + (newConnection == null ? "NULL" : newConnection.getID())); + logger.trace("RemotingConnectionID={} transferConnection to new RemotingConnectionID={}", + (connection == null ? "NULL" : connection.getID()), + (newConnection == null ? "NULL" : newConnection.getID())); } // And switch it @@ -690,7 +694,7 @@ public final class ChannelImpl implements Channel { public void replayCommands(final int otherLastConfirmedCommandID) { if (resendCache != null) { if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " Replaying commands on channelID=" + id); + logger.trace("RemotingConnectionID={} Replaying commands on channelID={}", (connection == null ? "NULL" : connection.getID()), id); } clearUpTo(otherLastConfirmedCommandID); @@ -708,7 +712,7 @@ public final class ChannelImpl implements Channel { @Override public void lock() { if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " lock channel " + this); + logger.trace("RemotingConnectionID={} lock channel {}", (connection == null ? "NULL" : connection.getID()), this); } lock.lock(); @@ -722,7 +726,7 @@ public final class ChannelImpl implements Channel { @Override public void unlock() { if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " unlock channel " + this); + logger.trace("RemotingConnectionID={} unlock channel {}", (connection == null ? "NULL" : connection.getID()), this); } lock.lock(); @@ -749,7 +753,8 @@ public final class ChannelImpl implements Channel { confirmed.setChannelID(id); if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " ChannelImpl::flushConfirmation flushing confirmation " + confirmed); + logger.trace("RemotingConnectionID={} ChannelImpl::flushConfirmation flushing confirmation {}", + (connection == null ? "NULL" : connection.getID()), confirmed); } doWrite(confirmed); @@ -768,7 +773,8 @@ public final class ChannelImpl implements Channel { lastConfirmedCommandID.incrementAndGet(); if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " ChannelImpl::confirming packet " + packet + " last commandID=" + lastConfirmedCommandID); + logger.trace("RemotingConnectionID={} ChannelImpl::confirming packet {} last commandID={}", + (connection == null ? "NULL" : connection.getID()), packet, lastConfirmedCommandID); } receivedBytes += packet.getPacketSize(); @@ -840,7 +846,8 @@ public final class ChannelImpl implements Channel { resendCache.add(packet); if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " ChannelImpl::addResendPacket adding packet " + packet + " stored commandID=" + firstStoredCommandID + " possible commandIDr=" + (firstStoredCommandID + resendCache.size())); + logger.trace("RemotingConnectionID={} ChannelImpl::addResendPacket adding packet {} stored commandID={} possible commandIDr={}", + (connection == null ? "NULL" : connection.getID()), packet, firstStoredCommandID, (firstStoredCommandID + resendCache.size())); } } @@ -848,7 +855,8 @@ public final class ChannelImpl implements Channel { final int numberToClear = 1 + lastReceivedCommandID - firstStoredCommandID; if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + (connection == null ? "NULL" : connection.getID()) + " ChannelImpl::clearUpTo lastReceived commandID=" + lastReceivedCommandID + " first commandID=" + firstStoredCommandID + " number to clear " + numberToClear); + logger.trace("RemotingConnectionID={} ChannelImpl::clearUpTo lastReceived commandID={} first commandID={} number to clear {}", + (connection == null ? "NULL" : connection.getID()), lastReceivedCommandID, firstStoredCommandID, numberToClear); } for (int i = 0; i < numberToClear; i++) { @@ -861,7 +869,8 @@ public final class ChannelImpl implements Channel { } if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + connection.getID() + " ChannelImpl::clearUpTo confirming " + packet + " towards " + commandConfirmationHandler); + logger.trace("RemotingConnectionID={} ChannelImpl::clearUpTo confirming {} towards {}", + connection.getID(), packet, commandConfirmationHandler); } if (commandConfirmationHandler != null) { commandConfirmationHandler.commandConfirmed(packet); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java index 6065dd561f..ea007b6691 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/RemotingConnectionImpl.java @@ -132,9 +132,7 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement transportConnection.setProtocolConnection(this); - if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionImpl created: " + this); - } + logger.trace("RemotingConnectionImpl created: {}", this); } // RemotingConnection implementation @@ -380,7 +378,7 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement final Packet packet = packetDecoder.decode(buffer, this); if (logger.isTraceEnabled()) { - logger.trace("RemotingConnectionID=" + getID() + " handling packet " + packet); + logger.trace("RemotingConnectionID={} handling packet {}", getID(), packet); } doBufferReceived(packet); diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/CertificateUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/CertificateUtil.java index db90c409ff..a29c0ace72 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/CertificateUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/CertificateUtil.java @@ -119,14 +119,13 @@ public class CertificateUtil { x509Certs[i] = (X509Certificate) CertificateFactory .getInstance("X.509").generateCertificate(new ByteArrayInputStream(plainCerts[i].getEncoded())); } catch (Exception ex) { - if (logger.isTraceEnabled()) { - logger.trace("Failed to convert SSL cert", ex); - } + logger.trace("Failed to convert SSL cert", ex); return null; } } + if (logger.isTraceEnabled()) { - logger.trace("Cert #" + i + " = " + x509Certs[i]); + logger.trace("Cert #{} = {}", i, x509Certs[i]); } } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java index b1ce0a4203..b12a57a6a1 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java @@ -246,7 +246,8 @@ public class NettyConnection implements Connection { } catch (OutOfMemoryError oom) { final long totalPendingWriteBytes = batchBufferSize(this.channel); // I'm not using the ActiveMQLogger framework here, as I wanted the class name to be very specific here - logger.warn("Trying to allocate " + size + " bytes, System is throwing OutOfMemoryError on NettyConnection " + this + ", there are currently " + "pendingWrites: [NETTY] -> " + totalPendingWriteBytes + " causes: " + oom.getMessage(), oom); + logger.warn("Trying to allocate {} bytes, System is throwing OutOfMemoryError on NettyConnection {}, there are currently pendingWrites: [NETTY] -> {} causes: {}", + size, this, totalPendingWriteBytes, oom.getMessage(), oom); throw oom; } } @@ -309,12 +310,10 @@ public class NettyConnection implements Connection { if (Env.isTestEnv()) { // this will only show when inside the testsuite. // we may great the log for FAILURE - logger.warn("FAILURE! The code is using blockUntilWritable inside a Netty worker, which would block. " + "The code will probably need fixing!", new Exception("trace")); + logger.warn("FAILURE! The code is using blockUntilWritable inside a Netty worker, which would block. The code will probably need fixing!", new Exception("trace")); } - if (logger.isDebugEnabled()) { - logger.debug("Calling blockUntilWritable using a thread where it's not allowed"); - } + logger.debug("Calling blockUntilWritable using a thread where it's not allowed"); } return channel.isWritable(); } else { @@ -382,9 +381,7 @@ public class NettyConnection implements Connection { if (!channel.eventLoop().inEventLoop()) { waitFor(promise, DEFAULT_WAIT_MILLIS); } else { - if (logger.isDebugEnabled()) { - logger.debug("Calling write with flush from a thread where it's not allowed"); - } + logger.debug("Calling write with flush from a thread where it's not allowed"); } } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java index 130066a9de..d8458523c8 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java @@ -523,7 +523,7 @@ public class NettyConnector extends AbstractConnector { } connectorType = EPOLL_CONNECTOR_TYPE; channelClazz = EpollSocketChannel.class; - logger.debug("Connector " + this + " using native epoll"); + logger.debug("Connector {} using native epoll", this); } else if (useKQueue && CheckDependencies.isKQueueAvailable()) { if (useGlobalWorkerPool) { group = SharedEventLoopGroup.getInstance((threadFactory -> new KQueueEventLoopGroup(remotingThreads, threadFactory))); @@ -532,7 +532,7 @@ public class NettyConnector extends AbstractConnector { } connectorType = KQUEUE_CONNECTOR_TYPE; channelClazz = KQueueSocketChannel.class; - logger.debug("Connector " + this + " using native kqueue"); + logger.debug("Connector {} using native kqueue", this); } else { if (useGlobalWorkerPool) { channelClazz = NioSocketChannel.class; @@ -543,7 +543,7 @@ public class NettyConnector extends AbstractConnector { } connectorType = NIO_CONNECTOR_TYPE; channelClazz = NioSocketChannel.class; - logger.debug("Connector + " + this + " using nio"); + logger.debug("Connector {} using nio", this); } // if we are a servlet wrap the socketChannelFactory @@ -642,7 +642,7 @@ public class NettyConnector extends AbstractConnector { channel.pipeline().addLast(proxyHandler); - logger.debug("Using a SOCKS proxy at " + proxyHost + ":" + proxyPort); + logger.debug("Using a SOCKS proxy at {}:{}", proxyHost, proxyPort); if (proxyRemoteDNS) { bootstrap.resolver(NoopAddressResolverGroup.INSTANCE); @@ -848,7 +848,7 @@ public class NettyConnector extends AbstractConnector { remoteDestination = new InetSocketAddress(IPV6Util.stripBracketsAndZoneID(host), port); } - logger.debug("Remote destination: " + remoteDestination); + logger.debug("Remote destination: {}", remoteDestination); ChannelFuture future; //port 0 does not work so only use local address if set @@ -1014,9 +1014,8 @@ public class NettyConnector extends AbstractConnector { */ @Override public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { - if (logger.isDebugEnabled()) { - logger.debug("Received msg=" + msg); - } + logger.debug("Received msg={}", msg); + if (msg instanceof HttpResponse) { HttpResponse response = (HttpResponse) msg; if (response.status().code() == HttpResponseStatus.SWITCHING_PROTOCOLS.code() && response.headers().get(HttpHeaderNames.UPGRADE).equals(ACTIVEMQ_REMOTING)) { @@ -1279,11 +1278,13 @@ public class NettyConnector extends AbstractConnector { String host = ConfigurationHelper.getStringProperty(TransportConstants.HOST_PROP_NAME, TransportConstants.DEFAULT_HOST, configuration); int port = ConfigurationHelper.getIntProperty(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_PORT, configuration); - if (port != this.port) + if (port != this.port) { return false; + } - if (host.equals(this.host)) + if (host.equals(this.host)) { return true; + } //The host may be an alias. We need to compare raw IP address. boolean result = false; @@ -1292,7 +1293,10 @@ public class NettyConnector extends AbstractConnector { InetAddress inetAddr2 = InetAddress.getByName(this.host); String ip1 = inetAddr1.getHostAddress(); String ip2 = inetAddr2.getHostAddress(); - logger.debug(this + " host 1: " + host + " ip address: " + ip1 + " host 2: " + this.host + " ip address: " + ip2); + + if (logger.isDebugEnabled()) { + logger.debug("{} host 1: {} ip address: {} host 2: {} ip address: {}", this, host, ip1, this.host, ip2); + } result = ip1.equals(ip2); } catch (UnknownHostException e) { diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/AutoCreateUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/AutoCreateUtil.java index 7e9375e81b..33b2003352 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/AutoCreateUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/AutoCreateUtil.java @@ -51,7 +51,7 @@ public class AutoCreateUtil { .setAddress(destAddress); setRequiredQueueConfigurationIfNotSet(queueConfiguration,response, RoutingType.ANYCAST, selectorString, true); session.createQueue(queueConfiguration); - logger.debug("The queue " + destAddress + " was created automatically"); + logger.debug("The queue {} was created automatically", destAddress); } catch (ActiveMQQueueExistsException e) { // The queue was created by another client/admin between the query check and send create queue packet } diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java index 707ee88127..f28b83a902 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/utils/XMLUtil.java @@ -287,7 +287,7 @@ public final class XMLUtil { sysProp = val; } // interesting choice to replace with val == "" with no match! - logger.debug("replacing " + subString + " with " + sysProp); + logger.debug("replacing {} with {}", subString, sysProp); xml = xml.replace(subString, sysProp); } diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/uri/ConnectorTransportConfigurationParserURITest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/uri/ConnectorTransportConfigurationParserURITest.java index 15826a3f2c..8d82fbb577 100644 --- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/uri/ConnectorTransportConfigurationParserURITest.java +++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/tests/uri/ConnectorTransportConfigurationParserURITest.java @@ -39,7 +39,7 @@ public class ConnectorTransportConfigurationParserURITest { System.out.println(transportURI); List objects = parser.newObject(transportURI, "test"); if (logger.isInfoEnabled()) { - objects.forEach((t) -> logger.info("transportConfig:" + t.toString())); + objects.forEach(t -> logger.info("transportConfig: {}", t)); } Assert.assertEquals(3, objects.size()); diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java index ac0ca98fd6..4b03f91779 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java @@ -169,7 +169,7 @@ public class JDBCSequentialFile implements SequentialFile { int noBytes = dbDriver.writeToFile(this, data, append); seek(append ? writePosition + noBytes : noBytes); if (logger.isTraceEnabled()) { - logger.trace("Write: ID: " + this.getId() + " FileName: " + this.getFileName() + size()); + logger.trace("Write: ID: {} FileName: {}{}", getId(), getFileName(), size()); } if (callback != null) callback.done(); @@ -371,10 +371,7 @@ public class JDBCSequentialFile implements SequentialFile { JDBCSequentialFile clone = (JDBCSequentialFile) cloneFile; try { synchronized (writeLock) { - if (logger.isTraceEnabled()) { - logger.trace("JDBC Copying File. From: " + this + " To: " + cloneFile); - } - + logger.trace("JDBC Copying File. From: {} To: {}", this, cloneFile); clone.open(); dbDriver.copyFileData(this, clone); clone.setWritePosition(writePosition); diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java index f1b9c2accd..4c1bccafc7 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java @@ -164,7 +164,9 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver { if (blob != null) { file.setWritePosition(blob.length()); } else { - logger.trace("No Blob found for file: " + file.getFileName() + " " + file.getId()); + if (logger.isTraceEnabled()) { + logger.trace("No Blob found for file: {} {}", file.getFileName(), file.getId()); + } } } connection.commit(); diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java index 6e9927141c..88782dad6c 100644 --- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java +++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java @@ -221,10 +221,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { for (JDBCJournalRecord record : recordRef) { - if (logger.isTraceEnabled()) { - logger.trace("sync::preparing JDBC statement for " + record); - } - + logger.trace("sync::preparing JDBC statement for {}", record); switch (record.getRecordType()) { case JDBCJournalRecord.DELETE_RECORD: @@ -261,9 +258,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { deleteJournalTxRecords.executeBatch(); connection.commit(); - if (logger.isTraceEnabled()) { - logger.trace("JDBC commit worked"); - } + logger.trace("JDBC commit worked"); if (cleanupTxRecords(deletedRecords, committedTransactions, deleteJournalTxRecords)) { deleteJournalTxRecords.executeBatch(); @@ -285,9 +280,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { failed.set(true); criticalIOErrorListener.onIOException(e, "Critical IO Error. Failed to process JDBC Record statements", null); - if (logger.isTraceEnabled()) { - logger.trace("Rolling back Transaction, just in case"); - } + logger.trace("Rolling back Transaction, just in case"); if (recordRef != null) { executeCallbacks(recordRef, false); @@ -334,7 +327,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { public void run() { for (JDBCJournalRecord record : records) { if (logger.isTraceEnabled()) { - logger.trace("Calling callback " + record + " with success = " + success); + logger.trace("Calling callback {} with success = {}", record, success); } record.complete(success); } @@ -367,9 +360,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { // better to be safe ;) checkStatus(); - if (logger.isTraceEnabled()) { - logger.trace("appendRecord " + record); - } + logger.trace("appendRecord {}", record); record.storeLineUp(); if (!started) { @@ -401,7 +392,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { private synchronized void addTxRecord(JDBCJournalRecord record) throws Exception { if (logger.isTraceEnabled()) { - logger.trace("addTxRecord " + record + ", started=" + started + ", failed=" + failed); + logger.trace("addTxRecord {}, started={}, failed={}", record, started, failed); } checkStatus(); @@ -434,12 +425,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setRecord(record); r.setSync(sync); - - if (logger.isTraceEnabled()) { - logger.trace("appendAddRecord bytes[] " + r); - } - - + logger.trace("appendAddRecord bytes[] {}", r); appendRecord(r); } @@ -451,10 +437,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setRecord(persister, record); r.setSync(sync); - if (logger.isTraceEnabled()) { - logger.trace("appendAddRecord (encoding) " + r + " with record = " + record); - } - + logger.trace("appendAddRecord (encoding) {} with record = {}", r, record); appendRecord(r); } @@ -474,10 +457,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setSync(sync); r.setIoCompletion(completionCallback); - if (logger.isTraceEnabled()) { - logger.trace("appendAddRecord (completionCallback & encoding) " + r + " with record = " + record); - } - + logger.trace("appendAddRecord (completionCallback & encoding) {} with record = {}", r, record); appendRecord(r); } @@ -491,10 +471,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setRecord(record); r.setSync(sync); - if (logger.isTraceEnabled()) { - logger.trace("appendUpdateRecord (bytes)) " + r); - } - + logger.trace("appendUpdateRecord (bytes)) {}", r); appendRecord(r); } @@ -511,10 +488,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setRecord(persister, record); r.setSync(sync); - if (logger.isTraceEnabled()) { - logger.trace("appendUpdateRecord (encoding)) " + r + " with record " + record); - } - + logger.trace("appendUpdateRecord (encoding)) {} with record {}", r, record); appendRecord(r); } @@ -539,10 +513,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setSync(sync); r.setIoCompletion(completionCallback); - if (logger.isTraceEnabled()) { - logger.trace("appendUpdateRecord (encoding & completioncallback)) " + r + " with record " + record); - } - + logger.trace("appendUpdateRecord (encoding & completioncallback)) {} with record {}", r, record); appendRecord(r); } @@ -569,7 +540,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setSync(sync); if (logger.isTraceEnabled()) { - logger.trace("appendDeleteRecord id=" + id + " sync=" + sync); + logger.trace("appendDeleteRecord id={} sync={}", id, sync); } appendRecord(r); @@ -589,10 +560,9 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setIoCompletion(completionCallback); if (logger.isTraceEnabled()) { - logger.trace("appendDeleteRecord id=" + id + " sync=" + sync + " with completionCallback"); + logger.trace("appendDeleteRecord id={} sync={} with completionCallback", id, sync); } - appendRecord(r); } @@ -612,10 +582,8 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { appendRecord(r); if (logger.isTraceEnabled()) { - logger.trace("appendAddRecordTransactional txID=" + txID + " id=" + id + " using bytes[] r=" + r); + logger.trace("appendAddRecordTransactional txID={} id={} using bytes[] r={}", txID, id, r); } - - } @Override @@ -630,10 +598,9 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setTxId(txID); if (logger.isTraceEnabled()) { - logger.trace("appendAddRecordTransactional txID=" + txID + " id=" + id + " using encoding=" + record + " and r=" + r); + logger.trace("appendAddRecordTransactional txID={} id={} using encoding={} and r={}", txID, id, record, r); } - appendRecord(r); } @@ -647,10 +614,9 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setTxId(txID); if (logger.isTraceEnabled()) { - logger.trace("appendUpdateRecordTransactional txID=" + txID + " id=" + id + " using bytes and r=" + r); + logger.trace("appendUpdateRecordTransactional txID={} id={} using bytes and r={}", txID, id, r); } - appendRecord(r); } @@ -666,7 +632,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setTxId(txID); if (logger.isTraceEnabled()) { - logger.trace("appendUpdateRecordTransactional txID=" + txID + " id=" + id + " using encoding=" + record + " and r=" + r); + logger.trace("appendUpdateRecordTransactional txID={} id={} using encoding={} and r={}", txID, id, record, r); } appendRecord(r); @@ -681,7 +647,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setTxId(txID); if (logger.isTraceEnabled()) { - logger.trace("appendDeleteRecordTransactional txID=" + txID + " id=" + id + " using bytes and r=" + r); + logger.trace("appendDeleteRecordTransactional txID={} id={} using bytes and r={}", txID, id, r); } appendRecord(r); @@ -696,10 +662,9 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setTxId(txID); if (logger.isTraceEnabled()) { - logger.trace("appendDeleteRecordTransactional txID=" + txID + " id=" + id + " using encoding=" + record + " and r=" + r); + logger.trace("appendDeleteRecordTransactional txID={} id={} using encoding={} and r={}", txID, id, record, r); } - appendRecord(r); } @@ -711,7 +676,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setTxId(txID); if (logger.isTraceEnabled()) { - logger.trace("appendDeleteRecordTransactional txID=" + txID + " id=" + id); + logger.trace("appendDeleteRecordTransactional txID={} id={}", txID, id); } appendRecord(r); @@ -726,10 +691,9 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setSync(sync); if (logger.isTraceEnabled()) { - logger.trace("appendCommitRecord txID=" + txID + " sync=" + sync); + logger.trace("appendCommitRecord txID={} sync={}", txID, sync); } - appendRecord(r); } @@ -743,7 +707,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setIoCompletion(callback); if (logger.isTraceEnabled()) { - logger.trace("appendCommitRecord txID=" + txID + " callback=" + callback); + logger.trace("appendCommitRecord txID={} callback={}", txID, callback); } appendRecord(r); @@ -763,7 +727,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setSync(sync); if (logger.isTraceEnabled()) { - logger.trace("appendCommitRecord txID=" + txID + " using callback, lineup=" + lineUpContext); + logger.trace("appendCommitRecord txID={} using callback, lineup={}", txID, lineUpContext); } appendRecord(r); @@ -779,10 +743,9 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setSync(sync); if (logger.isTraceEnabled()) { - logger.trace("appendPrepareRecord txID=" + txID + " using sync=" + sync); + logger.trace("appendPrepareRecord txID={} using sync={}", txID, sync); } - appendRecord(r); } @@ -801,10 +764,9 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setIoCompletion(callback); if (logger.isTraceEnabled()) { - logger.trace("appendPrepareRecord txID=" + txID + " using callback, sync=" + sync); + logger.trace("appendPrepareRecord txID={} using callback, sync={}", txID, sync); } - appendRecord(r); } @@ -818,10 +780,9 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setSync(sync); if (logger.isTraceEnabled()) { - logger.trace("appendPrepareRecord txID=" + txID + " transactionData, sync=" + sync); + logger.trace("appendPrepareRecord txID={} transactionData, sync={}", txID, sync); } - appendRecord(r); } @@ -834,7 +795,7 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setSync(sync); if (logger.isTraceEnabled()) { - logger.trace("appendRollbackRecord txID=" + txID + " sync=" + sync); + logger.trace("appendRollbackRecord txID={} sync={}", txID, sync); } appendRecord(r); @@ -850,10 +811,9 @@ public class JDBCJournalImpl extends AbstractJDBCDriver implements Journal { r.setIoCompletion(callback); if (logger.isTraceEnabled()) { - logger.trace("appendRollbackRecord txID=" + txID + " sync=" + sync + " using callback"); + logger.trace("appendRollbackRecord txID={} sync={} using callback", txID, sync); } - appendRecord(r); } diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java index bda6521506..af72e4cc0f 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/bridge/impl/JMSBridgeImpl.java @@ -318,7 +318,7 @@ public final class JMSBridgeImpl implements JMSBridge { this.objectName = ObjectName.getInstance(objectName); StandardMBean mbean = new StandardMBean(controlBean, JMSBridgeControl.class); mbeanServer.registerMBean(mbean, this.objectName); - logger.debug("Registered JMSBridge instance as: " + this.objectName.getCanonicalName()); + logger.debug("Registered JMSBridge instance as: {}", this.objectName.getCanonicalName()); } catch (Exception e) { throw new IllegalStateException("Failed to register JMSBridge MBean", e); } @@ -327,9 +327,7 @@ public final class JMSBridgeImpl implements JMSBridge { } } - if (logger.isTraceEnabled()) { - logger.trace("Created " + this); - } + logger.trace("Created {}", this); } @Override @@ -363,9 +361,7 @@ public final class JMSBridgeImpl implements JMSBridge { return; } - if (logger.isTraceEnabled()) { - logger.trace("Starting " + this); - } + logger.trace("Starting {}", this); // bridge has been stopped and is restarted if (executor.isShutdown()) { @@ -426,9 +422,7 @@ public final class JMSBridgeImpl implements JMSBridge { started = true; if (maxBatchTime != -1) { - if (logger.isTraceEnabled()) { - logger.trace("Starting time checker thread"); - } + logger.trace("Starting time checker thread"); batchExpiryTime = System.currentTimeMillis() + maxBatchTime; @@ -436,9 +430,7 @@ public final class JMSBridgeImpl implements JMSBridge { batchTimeCheckerTask = executor.submit(new BatchTimeChecker()); - if (logger.isTraceEnabled()) { - logger.trace("Started time checker thread"); - } + logger.trace("Started time checker thread"); } else { batchTimeCheckerFinished = null; @@ -450,9 +442,7 @@ public final class JMSBridgeImpl implements JMSBridge { sourceReceiverTask = executor.submit(new SourceReceiver()); - if (logger.isTraceEnabled()) { - logger.trace("Started " + this); - } + logger.trace("Started {}", this); } private void initPasswords() throws ActiveMQException { @@ -515,9 +505,7 @@ public final class JMSBridgeImpl implements JMSBridge { } synchronized (this) { - if (logger.isTraceEnabled()) { - logger.trace("Stopping " + this); - } + logger.trace("Stopping {}", this); Connection sourceConn = this.sourceConn; if (!connectedSource && sourceConn != null) { try { @@ -577,9 +565,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (tx != null) { // Terminate any transaction - if (logger.isTraceEnabled()) { - logger.trace("Rolling back remaining tx"); - } + logger.trace("Rolling back remaining tx"); try { stopSessionFailover(); @@ -588,14 +574,10 @@ public final class JMSBridgeImpl implements JMSBridge { tx.rollback(); abortedMessageCount += messages.size(); } catch (Exception ignore) { - if (logger.isTraceEnabled()) { - logger.trace("Failed to rollback", ignore); - } + logger.trace("Failed to rollback", ignore); } - if (logger.isTraceEnabled()) { - logger.trace("Rolled back remaining tx"); - } + logger.trace("Rolled back remaining tx"); } catch (Throwable t) { logger.trace("Failed stopSessionFailover", t); } @@ -624,9 +606,7 @@ public final class JMSBridgeImpl implements JMSBridge { messages.clear(); } - if (logger.isTraceEnabled()) { - logger.trace("Stopped " + this); - } + logger.trace("Stopped {}", this); } finally { if (isFailureHandler) { executor.shutdownNow(); @@ -684,9 +664,7 @@ public final class JMSBridgeImpl implements JMSBridge { @Override public synchronized void pause() throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("Pausing " + this); - } + logger.trace("Pausing {}", this); synchronized (lock) { paused = true; @@ -694,16 +672,12 @@ public final class JMSBridgeImpl implements JMSBridge { sourceConn.stop(); } - if (logger.isTraceEnabled()) { - logger.trace("Paused " + this); - } + logger.trace("Paused {}", this); } @Override public synchronized void resume() throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("Resuming " + this); - } + logger.trace("Resuming {}", this); synchronized (lock) { paused = false; @@ -711,9 +685,7 @@ public final class JMSBridgeImpl implements JMSBridge { sourceConn.start(); } - if (logger.isTraceEnabled()) { - logger.trace("Resumed " + this); - } + logger.trace("Resumed {}", this); } @Override @@ -998,9 +970,7 @@ public final class JMSBridgeImpl implements JMSBridge { } private void enlistResources(final Transaction tx) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("Enlisting resources in tx"); - } + logger.trace("Enlisting resources in tx"); XAResource resSource = ((XASession) sourceSession).getXAResource(); @@ -1010,24 +980,18 @@ public final class JMSBridgeImpl implements JMSBridge { tx.enlistResource(resDest); - if (logger.isTraceEnabled()) { - logger.trace("Enlisted resources in tx"); - } + logger.trace("Enlisted resources in tx"); } private void delistResources(final Transaction tx) { - if (logger.isTraceEnabled()) { - logger.trace("Delisting resources from tx"); - } + logger.trace("Delisting resources from tx"); XAResource resSource = ((XASession) sourceSession).getXAResource(); try { tx.delistResource(resSource, XAResource.TMSUCCESS); } catch (Exception e) { - if (logger.isTraceEnabled()) { - logger.trace("Failed to delist source resource", e); - } + logger.trace("Failed to delist source resource", e); } XAResource resDest = ((XASession) targetSession).getXAResource(); @@ -1035,20 +999,14 @@ public final class JMSBridgeImpl implements JMSBridge { try { tx.delistResource(resDest, XAResource.TMSUCCESS); } catch (Exception e) { - if (logger.isTraceEnabled()) { - logger.trace("Failed to delist target resource", e); - } + logger.trace("Failed to delist target resource", e); } - if (logger.isTraceEnabled()) { - logger.trace("Delisted resources from tx"); - } + logger.trace("Delisted resources from tx"); } private Transaction startTx() throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("Starting JTA transaction"); - } + logger.trace("Starting JTA transaction"); if (tm == null) { tm = ServiceUtils.getTransactionManager(); @@ -1067,9 +1025,7 @@ public final class JMSBridgeImpl implements JMSBridge { tm.suspend(); - if (logger.isTraceEnabled()) { - logger.trace("Started JTA transaction"); - } + logger.trace("Started JTA transaction"); return tx; } @@ -1096,26 +1052,18 @@ public final class JMSBridgeImpl implements JMSBridge { if (username == null) { if (isXA) { - if (logger.isTraceEnabled()) { - logger.trace("Creating an XA connection"); - } + logger.trace("Creating an XA connection"); conn = ((XAConnectionFactory) cf).createXAConnection(); } else { - if (logger.isTraceEnabled()) { - logger.trace("Creating a non XA connection"); - } + logger.trace("Creating a non XA connection"); conn = ((ConnectionFactory) cf).createConnection(); } } else { if (isXA) { - if (logger.isTraceEnabled()) { - logger.trace("Creating an XA connection"); - } + logger.trace("Creating an XA connection"); conn = ((XAConnectionFactory) cf).createXAConnection(username, password); } else { - if (logger.isTraceEnabled()) { - logger.trace("Creating a non XA connection"); - } + logger.trace("Creating a non XA connection"); conn = ((ConnectionFactory) cf).createConnection(username, password); } } @@ -1218,16 +1166,12 @@ public final class JMSBridgeImpl implements JMSBridge { // QoS = ONCE_AND_ONLY_ONCE if (forwardMode == JMSBridgeImpl.FORWARD_MODE_XA) { // Create an XASession for consuming from the source - if (logger.isTraceEnabled()) { - logger.trace("Creating XA source session"); - } + logger.trace("Creating XA source session"); sourceConn = createConnection(sourceUsername, sourcePassword, sourceCff, clientID, true, true); sourceSession = ((XAConnection) sourceConn).createXASession(); } else { // QoS = DUPLICATES_OK || AT_MOST_ONCE - if (logger.isTraceEnabled()) { - logger.trace("Creating non XA source session"); - } + logger.trace("Creating non XA source session"); sourceConn = createConnection(sourceUsername, sourcePassword, sourceCff, clientID, false, true); if (qualityOfServiceMode == QualityOfServiceMode.AT_MOST_ONCE && maxBatchSize == 1) { @@ -1262,9 +1206,7 @@ public final class JMSBridgeImpl implements JMSBridge { } else { // bridging across different servers // QoS = ONCE_AND_ONLY_ONCE if (forwardMode == JMSBridgeImpl.FORWARD_MODE_XA) { - if (logger.isTraceEnabled()) { - logger.trace("Creating XA dest session"); - } + logger.trace("Creating XA dest session"); // Create an XA session for sending to the destination @@ -1272,9 +1214,7 @@ public final class JMSBridgeImpl implements JMSBridge { targetSession = ((XAConnection) targetConn).createXASession(); } else { // QoS = DUPLICATES_OK || AT_MOST_ONCE - if (logger.isTraceEnabled()) { - logger.trace("Creating non XA dest session"); - } + logger.trace("Creating non XA dest session"); // Create a standard session for sending to the target @@ -1289,9 +1229,7 @@ public final class JMSBridgeImpl implements JMSBridge { } if (forwardMode == JMSBridgeImpl.FORWARD_MODE_XA) { - if (logger.isTraceEnabled()) { - logger.trace("Starting JTA transaction"); - } + logger.trace("Starting JTA transaction"); tx = startTx(); @@ -1321,9 +1259,7 @@ public final class JMSBridgeImpl implements JMSBridge { try { sourceConn.stop(); } catch (Throwable ignore) { - if (logger.isTraceEnabled()) { - logger.trace("Failed to stop source connection", ignore); - } + logger.trace("Failed to stop source connection", ignore); } } @@ -1331,18 +1267,14 @@ public final class JMSBridgeImpl implements JMSBridge { try { delistResources(tx); } catch (Throwable ignore) { - if (logger.isTraceEnabled()) { - logger.trace("Failed to delist resources", ignore); - } + logger.trace("Failed to delist resources", ignore); } try { // Terminate the tx tx.rollback(); abortedMessageCount += messages.size(); } catch (Throwable ignore) { - if (logger.isTraceEnabled()) { - logger.trace("Failed to rollback", ignore); - } + logger.trace("Failed to rollback", ignore); } } @@ -1351,9 +1283,7 @@ public final class JMSBridgeImpl implements JMSBridge { try { sourceConn.close(); } catch (Throwable ignore) { - if (logger.isTraceEnabled()) { - logger.trace("Failed to close source connection", ignore); - } + logger.trace("Failed to close source connection", ignore); } } try { @@ -1361,9 +1291,7 @@ public final class JMSBridgeImpl implements JMSBridge { targetConn.close(); } } catch (Throwable ignore) { - if (logger.isTraceEnabled()) { - logger.trace("Failed to close target connection", ignore); - } + logger.trace("Failed to close target connection", ignore); } } @@ -1381,9 +1309,7 @@ public final class JMSBridgeImpl implements JMSBridge { } private boolean setupJMSObjectsWithRetry() { - if (logger.isTraceEnabled()) { - logger.trace("Setting up connections"); - } + logger.trace("Setting up connections"); int count = 0; @@ -1414,14 +1340,12 @@ public final class JMSBridgeImpl implements JMSBridge { private void sendBatch() { if (logger.isTraceEnabled()) { - logger.trace("Sending batch of " + messages.size() + " messages"); + logger.trace("Sending batch of {} messages", messages.size()); } if (paused) { // Don't send now - if (logger.isTraceEnabled()) { - logger.trace("Paused, so not sending now"); - } + logger.trace("Paused, so not sending now"); return; } @@ -1440,15 +1364,11 @@ public final class JMSBridgeImpl implements JMSBridge { if (qualityOfServiceMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE || (qualityOfServiceMode == QualityOfServiceMode.AT_MOST_ONCE && maxBatchSize > 1)) { // We client ack before sending - if (logger.isTraceEnabled()) { - logger.trace("Client acking source session"); - } + logger.trace("Client acking source session"); messages.getLast().acknowledge(); - if (logger.isTraceEnabled()) { - logger.trace("Client acked source session"); - } + logger.trace("Client acked source session"); } boolean exHappened; @@ -1467,15 +1387,11 @@ public final class JMSBridgeImpl implements JMSBridge { if (maxBatchSize > 1) { // The sending session is transacted - we need to commit it - if (logger.isTraceEnabled()) { - logger.trace("Committing target session"); - } + logger.trace("Committing target session"); targetSession.commit(); - if (logger.isTraceEnabled()) { - logger.trace("Committed target session"); - } + logger.trace("Committed target session"); } if (qualityOfServiceMode == QualityOfServiceMode.DUPLICATES_OK) { @@ -1484,15 +1400,11 @@ public final class JMSBridgeImpl implements JMSBridge { // Note we could actually use Session.DUPS_OK_ACKNOWLEDGE here // For a slightly less strong delivery guarantee - if (logger.isTraceEnabled()) { - logger.trace("Client acking source session"); - } + logger.trace("Client acking source session"); messages.getLast().acknowledge(); - if (logger.isTraceEnabled()) { - logger.trace("Client acked source session"); - } + logger.trace("Client acked source session"); } } catch (Exception e) { if (!stopping) { @@ -1523,15 +1435,11 @@ public final class JMSBridgeImpl implements JMSBridge { // Commit the JTA transaction and start another delistResources(tx); - if (logger.isTraceEnabled()) { - logger.trace("Committing JTA transaction"); - } + logger.trace("Committing JTA transaction"); tx.commit(); - if (logger.isTraceEnabled()) { - logger.trace("Committed JTA transaction"); - } + logger.trace("Committed JTA transaction"); } catch (Exception e) { try { // we call this just in case there is a failure other than failover @@ -1573,9 +1481,7 @@ public final class JMSBridgeImpl implements JMSBridge { sourceSession.commit(); - if (logger.isTraceEnabled()) { - logger.trace("Committed source session"); - } + logger.trace("Committed source session"); } catch (Exception e) { ActiveMQJMSBridgeLogger.LOGGER.bridgeAckError(bridgeName, e); @@ -1607,9 +1513,7 @@ public final class JMSBridgeImpl implements JMSBridge { addMessageIDInHeader(msg); } - if (logger.isTraceEnabled()) { - logger.trace("Sending message " + msg); - } + logger.trace("Sending message {}", msg); // Make sure the correct time to live gets propagated @@ -1626,9 +1530,7 @@ public final class JMSBridgeImpl implements JMSBridge { targetProducer.send(targetDestination, msg, msg.getJMSDeliveryMode(), msg.getJMSPriority(), timeToLive); messageCount++; - if (logger.isTraceEnabled()) { - logger.trace("Sent message " + msg); - } + logger.trace("Sent message {}", msg); } } @@ -1657,9 +1559,7 @@ public final class JMSBridgeImpl implements JMSBridge { // Each bridge (if there are more than one) in the chain can concatenate the message id // So in the case of multiple bridges having routed the message this can be used in a multi-hop // distributed request/response - if (logger.isTraceEnabled()) { - logger.trace("Adding old message id in Message header"); - } + logger.trace("Adding old message id in Message header"); JMSBridgeImpl.copyProperties(msg); @@ -1787,7 +1687,7 @@ public final class JMSBridgeImpl implements JMSBridge { } } catch (JMSException jmse) { if (logger.isTraceEnabled()) { - logger.trace(this + " exception while receiving a message", jmse); + logger.trace("{} exception while receiving a message", this, jmse); } } @@ -1795,9 +1695,7 @@ public final class JMSBridgeImpl implements JMSBridge { try { lock.wait(500); } catch (InterruptedException e) { - if (logger.isTraceEnabled()) { - logger.trace(this + " thread was interrupted"); - } + logger.trace("{} thread was interrupted", this); if (stopping) { return; } @@ -1806,28 +1704,22 @@ public final class JMSBridgeImpl implements JMSBridge { continue; } - if (logger.isTraceEnabled()) { - logger.trace(this + " received message " + msg); - } + logger.trace("{} received message {}", this, msg); messages.add(msg); batchExpiryTime = System.currentTimeMillis() + maxBatchTime; if (logger.isTraceEnabled()) { - logger.trace(this + " rescheduled batchExpiryTime to " + batchExpiryTime); + logger.trace("{} rescheduled batchExpiryTime to {}", this, batchExpiryTime); } if (maxBatchSize != -1 && messages.size() >= maxBatchSize) { - if (logger.isTraceEnabled()) { - logger.trace(this + " maxBatchSize has been reached so sending batch"); - } + logger.trace("{} maxBatchSize has been reached so sending batch", this); sendBatch(); - if (logger.isTraceEnabled()) { - logger.trace(this + " sent batch"); - } + logger.trace("{} sent batch", this); } } } @@ -1875,9 +1767,7 @@ public final class JMSBridgeImpl implements JMSBridge { @Override public void run() { - if (logger.isTraceEnabled()) { - logger.trace("Failure handler running"); - } + logger.trace("Failure handler running"); // Clear the messages messages.clear(); @@ -1943,9 +1833,7 @@ public final class JMSBridgeImpl implements JMSBridge { @Override public void run() { - if (logger.isTraceEnabled()) { - logger.trace(this + " running"); - } + logger.trace("{} running", this); final CountDownLatch completed = batchTimeCheckerFinished; try { @@ -1954,21 +1842,15 @@ public final class JMSBridgeImpl implements JMSBridge { long toWait = batchExpiryTime - System.currentTimeMillis(); if (toWait <= 0) { - if (logger.isTraceEnabled()) { - logger.trace(this + " waited enough"); - } + logger.trace("{} waited enough", this); synchronized (lock) { if (!failed && !messages.isEmpty()) { - if (logger.isTraceEnabled()) { - logger.trace(this + " got some messages so sending batch"); - } + logger.trace("{} got some messages so sending batch", this); sendBatch(); - if (logger.isTraceEnabled()) { - logger.trace(this + " sent batch"); - } + logger.trace("{} sent batch", this); } } @@ -1976,18 +1858,15 @@ public final class JMSBridgeImpl implements JMSBridge { } else { try { if (logger.isTraceEnabled()) { - logger.trace(this + " waiting for " + toWait); + logger.trace("{} waiting for {}", this, toWait); } lock.wait(toWait); - if (logger.isTraceEnabled()) { - logger.trace(this + " woke up"); - } + logger.trace("{} woke up", this); } catch (InterruptedException e) { - if (logger.isTraceEnabled()) { - logger.trace(this + " thread was interrupted"); - } + logger.trace("{} thread was interrupted", this); + if (stopping) { return; } @@ -2033,9 +1912,7 @@ public final class JMSBridgeImpl implements JMSBridge { } if (failed) { // The failure has already been detected and is being handled - if (logger.isTraceEnabled()) { - logger.trace("Failure recovery already in progress"); - } + logger.trace("Failure recovery already in progress"); } else { boolean shouldHandleFailure = true; if (ha) { @@ -2060,7 +1937,7 @@ public final class JMSBridgeImpl implements JMSBridge { registry = sl.iterator().next(); } } catch (Throwable e) { - logger.debug("unable to load recovery registry " + locatorClasse, e); + logger.debug("unable to load recovery registry {}", locatorClasse, e); } if (registry != null) { break; @@ -2068,7 +1945,7 @@ public final class JMSBridgeImpl implements JMSBridge { } if (registry != null) { - logger.debug("Recovery Registry located = " + registry); + logger.debug("Recovery Registry located = {}", registry); } } } @@ -2145,7 +2022,7 @@ public final class JMSBridgeImpl implements JMSBridge { if (timedOut) { //timeout, presumably failover failed. - logger.debug("Timed out waiting for failover completion " + this); + logger.debug("Timed out waiting for failover completion {}", this); return false; } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFile.java index ba970de2a6..790f0bf672 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFile.java @@ -109,7 +109,7 @@ public abstract class AbstractSequentialFile implements SequentialFile { @Override public void copyTo(SequentialFile newFileName) throws Exception { try { - logger.debug("Copying " + this + " as " + newFileName); + logger.debug("Copying {} as {}", this, newFileName); if (!newFileName.isOpen()) { newFileName.open(); } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java index 3781bbee99..7efd8bfe89 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java @@ -35,17 +35,12 @@ import org.apache.activemq.artemis.journal.ActiveMQJournalLogger; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.critical.CriticalAnalyzer; import org.apache.activemq.artemis.utils.critical.EmptyCriticalAnalyzer; -import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; -import org.slf4j.Logger; /** * An abstract SequentialFileFactory containing basic functionality for both AIO and NIO SequentialFactories */ public abstract class AbstractSequentialFileFactory implements SequentialFileFactory { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - // Timeout used to wait executors to shutdown protected static final int EXECUTOR_TIMEOUT = 60; diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java index 33f92c6d99..422ce0774d 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFile.java @@ -117,7 +117,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { aioFile.close(); } catch (Throwable e) { // an exception here would means a double - logger.debug("Exeption while closing file - " + e.getMessage(), e); + logger.debug("Exeption while closing file", e); } finally { aioFile = null; aioFactory.afterClose(); @@ -126,9 +126,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { @Override public synchronized void fill(final int size) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("Filling file: " + getFileName()); - } + logger.trace("Filling file: {}", getFileName()); checkOpened(); aioFile.fill(aioFactory.getAlignment(), size); @@ -149,14 +147,12 @@ public class AIOSequentialFile extends AbstractSequentialFile { } opened = true; - if (logger.isTraceEnabled()) { - logger.trace("Opening file: " + getFileName()); - } + logger.trace("Opening file: {}", getFileName()); try { aioFile = aioFactory.libaioContext.openFile(getFile(), factory.isDatasync()); } catch (IOException e) { - logger.error("Error opening file: " + getFileName()); + logger.error("Error opening file: {}", getFileName()); factory.onIOError(e, e.getMessage(), this); throw new ActiveMQNativeIOError(e.getMessage(), e); } @@ -181,7 +177,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { // Sending it through the callback would make it released aioFile.read(positionToRead, bytesToRead, bytes, getCallback(callback, null)); } catch (IOException e) { - logger.error("IOError reading file: " + getFileName(), e); + logger.error("IOError reading file: {}", getFileName(), e); factory.onIOError(e, e.getMessage(), this); throw new ActiveMQNativeIOError(e.getMessage(), e); } @@ -203,7 +199,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { @Override public void writeDirect(final ByteBuffer bytes, final boolean sync) throws Exception { if (logger.isTraceEnabled()) { - logger.trace("Write Direct, Sync: " + sync + " File: " + getFileName()); + logger.trace("Write Direct, Sync: {} File: {}", sync, getFileName()); } if (sync) { @@ -219,9 +215,7 @@ public class AIOSequentialFile extends AbstractSequentialFile { @Override public void blockingWriteDirect(ByteBuffer bytes,boolean sync, boolean releaseBuffer) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("Write Direct, Sync: true File: " + getFileName()); - } + logger.trace("Write Direct, Sync: true File: {}", getFileName()); final SimpleWaitIOCallback completion = new SimpleWaitIOCallback(); diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java index 3395505c3d..6056c6264a 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java @@ -58,7 +58,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor if (DISABLED) { // This is only used in tests, hence I'm not creating a Logger for this - logger.info(AIOSequentialFileFactory.class.getName() + ".DISABLED = true"); + logger.info("{}.DISABLED = true", AIOSequentialFileFactory.class.getName()); } } @@ -111,9 +111,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor } final int adjustedMaxIO = Math.max(2, maxIO); callbackPool = PlatformDependent.hasUnsafe() ? new MpmcArrayQueue<>(adjustedMaxIO) : new MpmcAtomicArrayQueue<>(adjustedMaxIO); - if (logger.isTraceEnabled()) { - logger.trace("New AIO File Created"); - } + logger.trace("New AIO File Created"); } public AIOSequentialCallback getCallback() { @@ -394,9 +392,10 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor @Override public void onError(int errno, String message) { - if (logger.isDebugEnabled()) { - logger.trace("AIO on error issued. Error(code: " + errno + " msg: " + message + ")"); + if (logger.isTraceEnabled()) { + logger.trace("AIO on error issued. Error(code: {} msg: {})", errno, message); } + this.error = true; this.errorCode = errno; this.errorMessage = message; @@ -481,8 +480,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor // just to cleanup this if (bufferSize > 0 && System.currentTimeMillis() - bufferReuseLastTime > 10000) { if (logger.isTraceEnabled()) { - logger.trace("Clearing reuse buffers queue with " + reuseBuffersQueue.size() + - " elements"); + logger.trace("Clearing reuse buffers queue with {} elements", reuseBuffersQueue.size()); } bufferReuseLastTime = System.currentTimeMillis(); diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java index 2f6c676fba..4aa69aeb23 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java @@ -504,7 +504,7 @@ public final class TimedBuffer extends CriticalComponentImpl { } catch (Exception e) { useSleep = false; // I don't think we need to individualize a logger code here, this is unlikely to happen anyways - logger.warn(e.getMessage() + ", disabling sleep on TimedBuffer, using spin now", e); + logger.warn("{}, disabling sleep on TimedBuffer, using spin now", e.getMessage(), e); } return useSleep; } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedFile.java index 3873078f1b..b7a11642fb 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/MappedFile.java @@ -64,7 +64,7 @@ final class MappedFile implements AutoCloseable { length = (int) channel.size(); if (length != capacity && length != 0) { if (logger.isDebugEnabled()) { - logger.debug("Adjusting capacity to " + length + " while it was " + capacity + " on file " + file); + logger.debug("Adjusting capacity to {} while it was {} on file {}", length, capacity, file); } capacity = length; } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFile.java index b45f0e13d4..0a8b2ebb47 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFile.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/nio/NIOSequentialFile.java @@ -451,9 +451,8 @@ public class NIOSequentialFile extends AbstractSequentialFile { @Override public void copyTo(SequentialFile dstFile) throws IOException { - if (logger.isDebugEnabled()) { - logger.debug("Copying " + this + " as " + dstFile); - } + logger.debug("Copying {} as {}", this, dstFile); + if (isOpen()) { throw new IllegalStateException("File opened!"); } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/util/FileIOUtil.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/util/FileIOUtil.java index c703d10867..9614024097 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/util/FileIOUtil.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/util/FileIOUtil.java @@ -52,7 +52,7 @@ public class FileIOUtil { int bytesRead = from.read(buffer); if (logger.isTraceEnabled()) { - logger.trace("appending " + bytesRead + " bytes on " + to.getFileName()); + logger.trace("appending {} bytes on {}", bytesRead, to.getFileName()); } if (bytesRead > 0) { @@ -60,7 +60,7 @@ public class FileIOUtil { } if (bytesRead < buffer.capacity()) { - logger.trace("Interrupting reading as the whole thing was sent on " + to.getFileName()); + logger.trace("Interrupting reading as the whole thing was sent on {}", to.getFileName()); break; } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java index 605f5d0f8b..1e4ea2e8dd 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalCompactor.java @@ -96,15 +96,16 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ */ public void addPendingTransaction(final long transactionID, final long[] ids) { if (logger.isTraceEnabled()) { - logger.trace("addPendingTransaction::tx=" + transactionID + ", ids=" + Arrays.toString(ids)); + logger.trace("addPendingTransaction::tx={}, ids={}", transactionID, Arrays.toString(ids)); } pendingTransactions.put(transactionID, new PendingTransaction(ids)); } public void addCommandCommit(final JournalTransaction liveTransaction, final JournalFile currentFile) { if (logger.isTraceEnabled()) { - logger.trace("addCommandCommit " + liveTransaction.getId()); + logger.trace("addCommandCommit {}", liveTransaction.getId()); } + pendingCommands.add(new CommitCompactCommand(liveTransaction, currentFile)); long[] ids = liveTransaction.getPositiveArray(); @@ -132,9 +133,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ } public void addCommandRollback(final JournalTransaction liveTransaction, final JournalFile currentFile) { - if (logger.isTraceEnabled()) { - logger.trace("addCommandRollback " + liveTransaction + " currentFile " + currentFile); - } + logger.trace("addCommandRollback {} currentFile {}", liveTransaction, currentFile); pendingCommands.add(new RollbackCompactCommand(liveTransaction, currentFile)); } @@ -144,7 +143,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ */ public void addCommandDelete(final long id, final JournalFile usedFile) { if (logger.isTraceEnabled()) { - logger.trace("addCommandDelete id " + id + " usedFile " + usedFile); + logger.trace("addCommandDelete id {} usedFile {}", id, usedFile); } pendingCommands.add(new DeleteCompactCommand(id, usedFile)); } @@ -155,7 +154,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ */ public void addCommandUpdate(final long id, final JournalFile usedFile, final int size, final boolean replaceableUpdate) { if (logger.isTraceEnabled()) { - logger.trace("addCommandUpdate id " + id + " usedFile " + usedFile + " size " + size); + logger.trace("addCommandUpdate id {} usedFile {} size {}", id, usedFile, size); } pendingCommands.add(new UpdateCompactCommand(id, usedFile, size, replaceableUpdate)); } @@ -190,9 +189,8 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ */ public void replayPendingCommands() { for (CompactCommand command : pendingCommands) { - if (logger.isTraceEnabled()) { - logger.trace("Replay " + command); - } + logger.trace("Replay {}", command); + try { command.execute(); } catch (Exception e) { @@ -220,9 +218,8 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ @Override public void onReadAddRecord(final RecordInfo info) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("Read Record " + info); - } + logger.trace("Read Record {}", info); + if (containsRecord(info.id)) { JournalInternalRecord addRecord = new JournalAddRecord(true, info.id, info.getUserRecordType(), EncoderPersister.getInstance(), new ByteArrayEncoding(info.data)); addRecord.setCompactCount((short) (info.compactCount + 1)); @@ -238,8 +235,9 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ @Override public void onReadAddRecordTX(final long transactionID, final RecordInfo info) throws Exception { if (logger.isTraceEnabled()) { - logger.trace("Read Add Record TX " + transactionID + " info " + info); + logger.trace("Read Add Record TX {} info {}", transactionID, info); } + if (pendingTransactions.get(transactionID) != null) { produceAddRecordTX(transactionID, info); } else if (containsRecord(info.id)) { @@ -263,9 +261,8 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ @Override public void onReadCommitRecord(final long transactionID, final int numberOfRecords) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("onReadCommitRecord " + transactionID); + logger.trace("onReadCommitRecord {}", transactionID); } if (pendingTransactions.get(transactionID) != null) { @@ -289,7 +286,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ @Override public void onReadDeleteRecord(final long recordID) throws Exception { if (logger.isTraceEnabled()) { - logger.trace("onReadDeleteRecord " + recordID); + logger.trace("onReadDeleteRecord {}", recordID); } if (newRecords.get(recordID) != null) { @@ -302,7 +299,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ @Override public void onReadDeleteRecordTX(final long transactionID, final RecordInfo info) throws Exception { if (logger.isTraceEnabled()) { - logger.trace("onReadDeleteRecordTX " + transactionID + " info " + info); + logger.trace("onReadDeleteRecordTX {} info {}", transactionID, info); } if (pendingTransactions.get(transactionID) != null) { @@ -362,7 +359,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ final byte[] extraData, final int numberOfRecords) throws Exception { if (logger.isTraceEnabled()) { - logger.trace("onReadPrepareRecord " + transactionID); + logger.trace("onReadPrepareRecord {}", transactionID); } if (pendingTransactions.get(transactionID) != null) { @@ -386,13 +383,12 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ @Override public void onReadRollbackRecord(final long transactionID) throws Exception { if (logger.isTraceEnabled()) { - logger.trace("onReadRollbackRecord " + transactionID); + logger.trace("onReadRollbackRecord {}", transactionID); } if (pendingTransactions.get(transactionID) != null) { // Sanity check, this should never happen - logger.debug("Inconsistency during compacting: RollbackRecord ID = " + transactionID + - " for an already rolled back transaction during compacting"); + logger.debug("Inconsistency during compacting: RollbackRecord ID = {} for an already rolled back transaction during compacting", transactionID); } else { JournalTransaction newTransaction = newTransactions.remove(transactionID); if (newTransaction != null) { @@ -423,9 +419,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ @Override public void onReadUpdateRecord(final RecordInfo info) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("onReadUpdateRecord " + info); - } + logger.trace("onReadUpdateRecord {}", info); if (containsRecord(info.id)) { LongObjectHashMap longmap = pendingUpdates.get(info.userRecordType); @@ -458,9 +452,7 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ @Override public void onReadUpdateRecordTX(final long transactionID, final RecordInfo info) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("onReadUpdateRecordTX " + info); - } + logger.trace("onReadUpdateRecordTX {}", info); if (pendingTransactions.get(transactionID) != null) { produceUpdateRecordTX(transactionID, info); @@ -491,14 +483,13 @@ public class JournalCompactor extends AbstractJournalUpdateTask implements Journ JournalTransaction newTransaction = newTransactions.get(transactionID); if (newTransaction == null) { if (logger.isTraceEnabled()) { - logger.trace("creating new journal Transaction " + transactionID); + logger.trace("creating new journal Transaction {}", transactionID); } newTransaction = new JournalTransaction(transactionID, this); newTransactions.put(transactionID, newTransaction); } else if (logger.isTraceEnabled()) { // just logging - logger.trace("reusing TX " + transactionID); - + logger.trace("reusing TX {}", transactionID); } return newTransaction; } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java index 50da09c5a3..e100da7a8b 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java @@ -367,7 +367,7 @@ public class JournalFilesRepository { final boolean renameTmp, final boolean checkDelete) throws Exception { if (logger.isDebugEnabled()) { - logger.debug("Adding free file " + file + ", renameTMP=" + renameTmp + ", checkDelete=" + checkDelete); + logger.debug("Adding free file {}, renameTMP={}, checkDelete={}", file, renameTmp, checkDelete); } long calculatedSize = 0; try { @@ -381,9 +381,8 @@ public class JournalFilesRepository { // Re-initialise it if (logger.isTraceEnabled()) { - logger.trace("Re-initializing file " + file + " as checkDelete=" + checkDelete + - ", freeFilesCount=" + freeFilesCount + ", dataFiles.size=" + dataFiles.size() + - ", openedFiles=" + openedFiles + ", poolSize=" + poolSize); + logger.trace("Re-initializing file {} as checkDelete={}, freeFilesCount={}, dataFiles.size={} openedFiles={}, poolSize={}", + file, checkDelete, freeFilesCount, dataFiles.size(), openedFiles, poolSize); } JournalFile jf = reinitializeFile(file); @@ -395,17 +394,15 @@ public class JournalFilesRepository { freeFiles.add(jf); freeFilesCount.getAndIncrement(); } else { - if (logger.isDebugEnabled()) { - logger.debug("Deleting file " + file.getFile()); - } + logger.debug("Deleting file {}", file.getFile()); + if (logger.isTraceEnabled()) { - logger.trace("DataFiles.size() = " + dataFiles.size()); - logger.trace("openedFiles.size() = " + openedFiles.size()); - logger.trace("minfiles = " + minFiles + ", poolSize = " + poolSize); - logger.trace("Free Files = " + freeFilesCount.get()); - logger.trace("File " + file + " being deleted as freeFiles.size() + dataFiles.size() + 1 + openedFiles.size() (" + - (freeFilesCount.get() + dataFiles.size() + 1 + openedFiles.size()) + - ") < minFiles (" + minFiles + ")"); + logger.trace("DataFiles.size() = {}", dataFiles.size()); + logger.trace("openedFiles.size() = {}", openedFiles.size()); + logger.trace("minfiles = {}, poolSize = {}", minFiles, poolSize); + logger.trace("Free Files = {}", freeFilesCount.get()); + logger.trace("File {} being deleted as freeFiles.size() + dataFiles.size() + 1 + openedFiles.size() () < minFiles ({})", + file, (freeFilesCount.get() + dataFiles.size() + 1 + openedFiles.size()), minFiles); } file.getFile().delete(); } @@ -474,7 +471,7 @@ public class JournalFilesRepository { */ public JournalFile openFile() throws InterruptedException, ActiveMQIOErrorException { if (logger.isTraceEnabled()) { - logger.trace("enqueueOpenFile with openedFiles.size=" + openedFiles.size()); + logger.trace("enqueueOpenFile with openedFiles.size={}", openedFiles.size()); } // First try to get an open file, that's prepared and already open @@ -505,9 +502,8 @@ public class JournalFilesRepository { throw ActiveMQJournalBundle.BUNDLE.fileNotOpened(); } } - if (logger.isTraceEnabled()) { - logger.trace("Returning file " + nextFile); - } + + logger.trace("Returning file {}", nextFile); return nextFile; } @@ -526,9 +522,7 @@ public class JournalFilesRepository { public synchronized void pushOpenedFile() throws Exception { JournalFile nextOpenedFile = takeFile(true, true, true, false); - if (logger.isTraceEnabled()) { - logger.trace("pushing openFile " + nextOpenedFile); - } + logger.trace("pushing openFile {}", nextOpenedFile); if (!openedFiles.offer(nextOpenedFile)) { ActiveMQJournalLogger.LOGGER.failedToAddFile(nextOpenedFile); @@ -647,9 +641,7 @@ public class JournalFilesRepository { final String fileName = createFileName(tmpCompact, fileID); - if (logger.isTraceEnabled()) { - logger.trace("Creating file " + fileName); - } + logger.trace("Creating file {}", fileName); String tmpFileName = fileName + ".tmp"; @@ -667,9 +659,7 @@ public class JournalFilesRepository { sequentialFile.close(false, false); - if (logger.isTraceEnabled()) { - logger.trace("Renaming file " + tmpFileName + " as " + fileName); - } + logger.trace("Renaming file {} as {}", tmpFileName, fileName); sequentialFile.renameTo(fileName); diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java index d56041ad66..f4460f8a58 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java @@ -272,7 +272,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal File[] repeatFiles = historyFolder.listFiles((a, name) -> name.startsWith(getFilePrefix()) && name.endsWith(file.getFileID() + "." + filesRepository.getFileExtension())); for (File f : repeatFiles) { - logger.warn("File " + f + " was partially copied before, removing the file"); + logger.warn("File {} was partially copied before, removing the file", f); f.delete(); } } @@ -754,18 +754,10 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal preparedTransactionExtraDataSize)) { // Avoid a buffer overflow caused by damaged data... continue // scanning for more pendingTransactions... - logger.trace("Record at position " + pos + - " recordType = " + - recordType + - " file:" + - file.getFile().getFileName() + - " recordSize: " + - recordSize + - " variableSize: " + - variableSize + - " preparedTransactionExtraDataSize: " + - preparedTransactionExtraDataSize + - " is corrupted and it is being ignored (II)"); + if (logger.isTraceEnabled()) { + logger.trace("Record at position {} recordType = {} file:{} recordSize: {} variableSize: {} preparedTransactionExtraDataSize: {} is corrupted and it is being ignored (II)", + pos, recordType, file.getFile().getFileName(), recordSize, variableSize, preparedTransactionExtraDataSize); + } // If a file has damaged pendingTransactions, we make it a dataFile, and the // next reclaiming will fix it reader.markAsDataFile(file); @@ -787,16 +779,10 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal // This is like testing a hash for the record. (We could replace the // checkSize by some sort of calculated hash) if (checkSize != variableSize + recordSize + preparedTransactionExtraDataSize) { - logger.trace("Record at position " + pos + - " recordType = " + - recordType + - " possible transactionID = " + - transactionID + - " possible recordID = " + - recordID + - " file:" + - file.getFile().getFileName() + - " is corrupted and it is being ignored (III)"); + if (logger.isTraceEnabled()) { + logger.trace("Record at position {} recordType = {} possible transactionID = {} possible recordID = {} file:{} is corrupted and it is being ignored (III)", + pos, recordType, transactionID, recordID, file.getFile().getFileName()); + } // If a file has damaged pendingTransactions, we make it a dataFile, and the // next reclaiming will fix it @@ -813,7 +799,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal // the data now. if (logger.isTraceEnabled()) { - logger.trace("reading " + recordID + ", userRecordType=" + userRecordType + ", compactCount=" + compactCount); + logger.trace("reading {}, userRecordType={}, compactCount={}", recordID, userRecordType, compactCount); } boolean replaceableUpdate = replaceableRecords != null ? replaceableRecords.containsKey(userRecordType) : false; @@ -933,10 +919,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal lineUpContext(callback); if (logger.isTraceEnabled()) { - logger.trace("scheduling appendAddRecord::id=" + id + - ", userRecordType=" + - recordType + - ", record = " + record); + logger.trace("scheduling appendAddRecord::id={}, userRecordType={}, record = {}", id, recordType, record); } final long maxRecordSize = getMaxRecordSize(); @@ -958,21 +941,17 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal records.put(id, new JournalRecord(usedFile, addRecordEncodeSize)); if (logger.isTraceEnabled()) { - logger.trace("appendAddRecord::id=" + id + - ", userRecordType=" + - recordType + - ", record = " + record + - ", usedFile = " + - usedFile); + logger.trace("appendAddRecord::id={}, userRecordType={}, record = {}, usedFile = {}", + id, recordType, record, usedFile); } result.set(true); } catch (ActiveMQShutdownException e) { result.fail(e); - logger.error("appendAddRecord:" + e, e); + logger.error("Exception during appendAddRecord:", e); } catch (Throwable e) { result.fail(e); setErrorCondition(callback, null, e); - logger.error("appendAddRecord::" + e, e); + logger.error("Exception during appendAddRecord:", e); } finally { journalLock.readLock().unlock(); } @@ -994,10 +973,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal lineUpContext(callback); if (logger.isTraceEnabled()) { - logger.trace("scheduling appendAddEvent::id=" + id + - ", userRecordType=" + - recordType + - ", record = " + record); + logger.trace("scheduling appendAddEvent::id={}, userRecordType={}, record = {}", id, recordType, record); } final long maxRecordSize = getMaxRecordSize(); @@ -1016,21 +992,17 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal JournalFile usedFile = appendRecord(addRecord, false, sync, null, callback); if (logger.isTraceEnabled()) { - logger.trace("appendAddEvent:id=" + id + - ", userRecordType=" + - recordType + - ", record = " + record + - ", usedFile = " + - usedFile); + logger.trace("appendAddEvent:id={}, userRecordType={}, record = {}, usedFile = {}", + id, recordType, record, usedFile); } result.set(true); } catch (ActiveMQShutdownException e) { result.fail(e); - logger.error("appendAddEvent:" + e, e); + logger.error("Exception during appendAddEvent:", e); } catch (Throwable e) { result.fail(e); setErrorCondition(callback, null, e); - logger.error("appendAddEvent::" + e, e); + logger.error("Exception during appendAddEvent:", e); } finally { journalLock.readLock().unlock(); } @@ -1050,9 +1022,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal lineUpContext(callback); if (logger.isTraceEnabled()) { - logger.trace("scheduling appendUpdateRecord::id=" + id + - ", userRecordType=" + - recordType); + logger.trace("scheduling appendUpdateRecord::id={}, userRecordType={}", id, recordType); } final SimpleFuture onFoundAddInfo; @@ -1088,12 +1058,9 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal lineUpContext(callback); if (logger.isTraceEnabled()) { - logger.trace("scheduling appendUpdateRecord::id=" + id + - ", userRecordType=" + - recordType); + logger.trace("scheduling appendUpdateRecord::id={}, userRecordType={}", id, recordType); } - internalAppendUpdateRecord(id, recordType, persister, record, sync, replaceableUpdate, updateCallback, callback); } @@ -1121,7 +1088,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal updateCallback.onUpdate(id, false); } if (logger.isDebugEnabled()) { - logger.debug("Record " + id + " had not been found"); + logger.debug("Record {} had not been found", id); } if (callback != null) { @@ -1134,11 +1101,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal JournalFile usedFile = appendRecord(updateRecord, false, sync, null, callback); if (logger.isTraceEnabled()) { - logger.trace("appendUpdateRecord::id=" + id + - ", userRecordType=" + - recordType + - ", usedFile = " + - usedFile); + logger.trace("appendUpdateRecord::id={}, userRecordType={}, usedFile = {}", id, recordType, usedFile); } // record==null here could only mean there is a compactor @@ -1158,13 +1121,13 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (updateCallback != null) { updateCallback.onUpdate(id, false); } - logger.error("appendUpdateRecord:" + e, e); + logger.error("Exception during appendUpdateRecord:", e); } catch (Throwable e) { if (updateCallback != null) { updateCallback.onUpdate(id, false); } setErrorCondition(callback, null, e); - logger.error("appendUpdateRecord:" + e, e); + logger.error("Exception during appendUpdateRecord:", e); } finally { journalLock.readLock().unlock(); } @@ -1175,7 +1138,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal @Override public void appendDeleteRecord(final long id, final boolean sync, final IOCompletion callback) throws Exception { if (logger.isTraceEnabled()) { - logger.trace("scheduling appendDeleteRecord::id=" + id); + logger.trace("scheduling appendDeleteRecord::id={}", id); } checkJournalIsLoaded(); @@ -1205,7 +1168,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal public void tryAppendDeleteRecord(final long id, final boolean sync, final JournalUpdateCallback updateCallback, final IOCompletion callback) throws Exception { if (logger.isTraceEnabled()) { - logger.trace("scheduling appendDeleteRecord::id=" + id); + logger.trace("scheduling appendDeleteRecord::id={}", id); } @@ -1256,7 +1219,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal JournalFile usedFile = appendRecord(deleteRecord, false, sync, null, callback); if (logger.isTraceEnabled()) { - logger.trace("appendDeleteRecord::id=" + id + ", usedFile = " + usedFile); + logger.trace("appendDeleteRecord::id={}, usedFile = {}", id, usedFile); } // record==null here could only mean there is a compactor @@ -1274,12 +1237,12 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (updateCallback != null) { updateCallback.onUpdate(id, false); } - logger.error("appendDeleteRecord:" + e, e); + logger.error("Exception during appendDeleteRecord:", e); } catch (Throwable e) { if (updateCallback != null) { updateCallback.onUpdate(id, false); } - logger.error("appendDeleteRecord:" + e, e); + logger.error("Exception during appendDeleteRecord:", e); setErrorCondition(callback, null, e); } finally { journalLock.readLock().unlock(); @@ -1300,12 +1263,8 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal final Object record) throws Exception { checkJournalIsLoaded(); if (logger.isTraceEnabled()) { - logger.trace("scheduling appendAddRecordTransactional:txID=" + txID + - ",id=" + - id + - ", userRecordType=" + - recordType + - ", record = " + record); + logger.trace("scheduling appendAddRecordTransactional:txID={}, id={}, userRecordType={}, record = {}", + txID, id, recordType, record); } @@ -1327,19 +1286,13 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal JournalFile usedFile = appendRecord(addRecord, false, false, tx, null); if (logger.isTraceEnabled()) { - logger.trace("appendAddRecordTransactional:txID=" + txID + - ",id=" + - id + - ", userRecordType=" + - recordType + - ", record = " + record + - ", usedFile = " + - usedFile); + logger.trace("appendAddRecordTransactional:txID={},id={}, userRecordType={}, record = {}, usedFile = {}", + txID, id, recordType, record, usedFile); } tx.addPositive(usedFile, id, encodeSize, false); } catch (Throwable e) { - logger.error("appendAddRecordTransactional:" + e, e); + logger.error("Exception during appendAddRecordTransactional:", e); setErrorCondition(null, tx, e); } finally { journalLock.readLock().unlock(); @@ -1364,12 +1317,8 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal final Persister persister, final Object record) throws Exception { if ( logger.isTraceEnabled() ) { - logger.trace( "scheduling appendUpdateRecordTransactional::txID=" + txID + - ",id=" + - id + - ", userRecordType=" + - recordType + - ", record = " + record); + logger.trace("scheduling appendUpdateRecordTransactional::txID={}, id={}, userRecordType={}, record = {}", + txID, id, recordType, record); } checkJournalIsLoaded(); @@ -1389,20 +1338,14 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal JournalInternalRecord updateRecordTX = new JournalAddRecordTX( false, txID, id, recordType, persister, record ); JournalFile usedFile = appendRecord( updateRecordTX, false, false, tx, null ); - if ( logger.isTraceEnabled() ) { - logger.trace( "appendUpdateRecordTransactional::txID=" + txID + - ",id=" + - id + - ", userRecordType=" + - recordType + - ", record = " + record + - ", usedFile = " + - usedFile ); + if (logger.isTraceEnabled()) { + logger.trace("appendUpdateRecordTransactional::txID={}, id={}, userRecordType={}, record = {}, usedFile = {}", + txID, id, recordType, record, usedFile ); } tx.addPositive( usedFile, id, updateRecordTX.getEncodeSize(), false); } catch (Throwable e ) { - logger.error("appendUpdateRecordTransactional:" + e.getMessage(), e ); + logger.error("Exception during appendUpdateRecordTransactional:", e ); setErrorCondition(null, tx, e ); } finally { journalLock.readLock().unlock(); @@ -1415,11 +1358,8 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal public void appendDeleteRecordTransactional(final long txID, final long id, final EncodingSupport record) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("scheduling appendDeleteRecordTransactional::txID=" + txID + - ", id=" + - id); - } + + logger.trace("scheduling appendDeleteRecordTransactional::txID={}, id={}", txID, id); checkJournalIsLoaded(); @@ -1440,16 +1380,12 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal JournalFile usedFile = appendRecord(deleteRecordTX, false, false, tx, null); if (logger.isTraceEnabled()) { - logger.trace("appendDeleteRecordTransactional::txID=" + txID + - ", id=" + - id + - ", usedFile = " + - usedFile); + logger.trace("appendDeleteRecordTransactional::txID={}, id={}, usedFile = {}", txID, id, usedFile); } tx.addNegative(usedFile, id); } catch (Throwable e) { - logger.error("appendDeleteRecordTransactional:" + e, e); + logger.error("Exception during appendDeleteRecordTransactional:", e); setErrorCondition(null, tx, e); } finally { journalLock.readLock().unlock(); @@ -1478,7 +1414,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal lineUpContext(callback); if (logger.isTraceEnabled()) { - logger.trace("scheduling appendPrepareRecord::txID=" + txID); + logger.trace("scheduling appendPrepareRecord::txID={}", txID); } final SimpleFuture result = newSyncAndCallbackResult(sync, callback); @@ -1497,16 +1433,16 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal JournalFile usedFile = appendRecord(prepareRecord, true, sync, tx, callback); if (logger.isTraceEnabled()) { - logger.trace("appendPrepareRecord::txID=" + txID + ", usedFile = " + usedFile); + logger.trace("appendPrepareRecord::txID={}, usedFile = {}", txID, usedFile); } tx.prepare(usedFile); } catch (ActiveMQShutdownException e) { result.fail(e); - logger.error("appendPrepareRecord:" + e, e); + logger.error("Exception during appendPrepareRecord:", e); } catch (Throwable e) { result.fail(e); - logger.error("appendPrepareRecord:" + e, e); + logger.error("Exception during appendPrepareRecord:", e); setErrorCondition(callback, tx, e); } finally { journalLock.readLock().unlock(); @@ -1556,9 +1492,8 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal lineUpContext(callback); } - if (logger.isTraceEnabled()) { - logger.trace("scheduling appendCommitRecord::txID=" + txID ); + logger.trace("scheduling appendCommitRecord::txID={}", txID); } JournalTransaction txcheck = transactions.get(txID); @@ -1585,16 +1520,16 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal JournalFile usedFile = appendRecord(commitRecord, true, sync, tx, callback); if (logger.isTraceEnabled()) { - logger.trace("appendCommitRecord::txID=" + txID + ", usedFile = " + usedFile); + logger.trace("appendCommitRecord::txID={}, usedFile = {}", txID, usedFile); } tx.commit(usedFile); } catch (ActiveMQShutdownException e) { result.fail(e); - logger.error("appendCommitRecord:" + e, e); + logger.error("Exception during appendCommitRecord:", e); } catch (Throwable e) { result.fail(e); - logger.error("appendCommitRecord:" + e, e); + logger.error("Exception during appendCommitRecord:", e); setErrorCondition(callback, tx, e); } finally { journalLock.readLock().unlock(); @@ -1614,13 +1549,10 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal checkJournalIsLoaded(); lineUpContext(callback); - if (logger.isTraceEnabled()) { - logger.trace("scheduling appendRollbackRecord::txID=" + txID ); + logger.trace("scheduling appendRollbackRecord::txID={}", txID); } - - final SimpleFuture result = newSyncAndCallbackResult(sync, callback); appendExecutor.execute(new Runnable() { @Override @@ -1630,7 +1562,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal final JournalTransaction tx = transactions.remove(txID); try { if (logger.isTraceEnabled()) { - logger.trace("appendRollbackRecord::txID=" + txID ); + logger.trace("appendRollbackRecord::txID={}", txID); } if (tx == null) { @@ -1644,10 +1576,10 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal tx.rollback(usedFile); } catch (ActiveMQShutdownException e) { result.fail(e); - logger.error("appendRollbackRecord:" + e, e); + logger.error("Exception during appendRollbackRecord:", e); } catch (Throwable e) { result.fail(e); - logger.error("appendRollbackRecord:" + e, e); + logger.error("Exception during appendRollbackRecord:", e); setErrorCondition(callback, tx, e); } finally { journalLock.readLock().unlock(); @@ -1851,7 +1783,8 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal } if (logger.isDebugEnabled()) { - logger.debug("JournalImpl::compact " + JournalImpl.this + " for its " + (++compactCount) + " time"); + ++compactCount; // Member used only for logging state when debug enabled + logger.debug("JournalImpl::compact {} for its {} time", JournalImpl.this, compactCount); } compactorLock.writeLock().lock(); @@ -1861,9 +1794,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal boolean previousReclaimValue = isAutoReclaim(); try { - if (logger.isDebugEnabled()) { - logger.debug("Starting compacting operation on journal " + this); - } + logger.debug("Starting compacting operation on journal {}", this); onCompactStart(); @@ -1928,14 +1859,12 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal // Restore compacted dataFiles for (int i = newDatafiles.size() - 1; i >= 0; i--) { JournalFile fileToAdd = newDatafiles.get(i); - if (logger.isTraceEnabled()) { - logger.trace("Adding file " + fileToAdd + " back as datafile"); - } + logger.trace("Adding file {} back as datafile", fileToAdd); filesRepository.addDataFileOnTop(fileToAdd); } if (logger.isTraceEnabled()) { - logger.trace("There are " + filesRepository.getDataFilesCount() + " datafiles Now"); + logger.trace("There are {} datafiles Now", filesRepository.getDataFilesCount()); } // Replay pending commands (including updates, deletes and commits) @@ -1949,9 +1878,8 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal // that happened during the compacting localCompactor.getNewTransactions().forEach((id, newTransaction) -> { - if (logger.isTraceEnabled()) { - logger.trace("Merging pending transaction " + newTransaction + " after compacting the journal"); - } + logger.trace("Merging pending transaction {} after compacting the journal", newTransaction); + JournalTransaction liveTransaction = transactions.get(newTransaction.getId()); if (liveTransaction != null) { liveTransaction.merge(newTransaction); @@ -1974,15 +1902,11 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal renameFiles(dataFilesToProcess, newDatafiles); deleteControlFile(controlFile); - if (logger.isDebugEnabled()) { - logger.debug("Flushing compacting on journal " + this); - } + logger.debug("Flushing compacting on journal {}", this); setAutoReclaim(previousReclaimValue); - if (logger.isDebugEnabled()) { - logger.debug("Finished compacting on journal " + this); - } + logger.debug("Finished compacting on journal {}", this); } catch (Throwable e) { try { @@ -1993,10 +1917,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal } } finally { compactorLock.writeLock().unlock(); - if (logger.isDebugEnabled()) { - logger.debug("JournalImpl::compact finalized"); - } - + logger.debug("JournalImpl::compact finalized"); } @@ -2131,7 +2052,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal final AtomicLong maxID = new AtomicLong(-1); for (final JournalFile file : orderedFiles) { - logger.trace("Loading file " + file.getFile().getFileName()); + logger.trace("Loading file {}", file.getFile().getFileName()); final AtomicBoolean hasData = new AtomicBoolean(false); @@ -2442,8 +2363,9 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal @Override public void processBackupCleanup() { if (logger.isDebugEnabled()) { - logger.debug("processBackupCleanup with maxFiles = " + journalRetentionMaxFiles + " and period = " + journalRetentionPeriod); + logger.debug("processBackupCleanup with maxFiles = {} and period = {}", journalRetentionMaxFiles, journalRetentionPeriod); } + if (journalRetentionFolder != null && (journalRetentionMaxFiles > 0 || journalRetentionPeriod > 0)) { FilenameFilter fnf = (d, name) -> name.endsWith("." + filesRepository.getFileExtension()); @@ -2459,10 +2381,10 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal for (String fileName : fileNames) { long timeOnFile = getDatePortionMillis(fileName); if (timeOnFile < timeCutOf) { - logger.debug("File " + fileName + " is too old and should go"); + logger.debug("File {} is too old and should go", fileName); File fileToRemove = new File(journalRetentionFolder, fileName); if (!fileToRemove.delete()) { - logger.debug("Could not remove " + fileToRemove); + logger.debug("Could not remove {}", fileToRemove); } } else { break; @@ -2478,7 +2400,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal int toRemove = fileNames.length - journalRetentionMaxFiles; for (String file : fileNames) { - logger.debug("Removing " + file); + logger.debug("Removing {}", file); File fileToRemove = new File(journalRetentionFolder, file); fileToRemove.delete(); toRemove--; @@ -2551,9 +2473,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal File copyTo = new File(journalRetentionFolder, fileName); - if (logger.isDebugEnabled()) { - logger.debug("Copying journal retention from " + copyFrom + " to " + copyTo); - } + logger.debug("Copying journal retention from {} to {}", copyFrom, copyTo); try { Files.copy(copyFrom.toPath(), copyTo.toPath(), StandardCopyOption.REPLACE_EXISTING); @@ -2641,9 +2561,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal for (JournalFile file : filesRepository.getDataFiles()) { if (file.isCanReclaim()) { // File can be reclaimed or deleted - if (logger.isTraceEnabled()) { - logger.trace("Reclaiming file " + file); - } + logger.trace("Reclaiming file {}", file); filesRepository.removeDataFile(file); @@ -2676,12 +2594,14 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal if (updateFactor > UPDATE_FACTOR) { // this means every add records with at least 10 records if (logger.isDebugEnabled()) { - logger.debug("There are " + addRecord + " records, with " + updateCount + " towards them. UpdateCound / AddCount = " + updateFactor + ", being greater than " + UPDATE_FACTOR + " meaning we have to schedule compacting"); + logger.debug("There are {} records, with {} towards them. UpdateCound / AddCount = {}, being greater than {} meaning we have to schedule compacting", + addRecord, updateCount, updateFactor, UPDATE_FACTOR); } return true; } else { if (logger.isDebugEnabled()) { - logger.debug("There are " + addRecord + " records, with " + updateCount + " towards them. UpdateCound / AddCount = " + updateFactor + ", which is lower than " + UPDATE_FACTOR + " meaning we are ok to leave these records"); + logger.debug("There are {} records, with {} towards them. UpdateCound / AddCount = {}, which is lower than {} meaning we are ok to leave these records", + addRecord, updateCount, updateFactor, UPDATE_FACTOR); } } } @@ -3659,9 +3579,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal scheduleReclaim(); } - if (logger.isTraceEnabled()) { - logger.trace("Moving next file " + currentFile); - } + logger.trace("Moving next file {}", currentFile); fileFactory.activateBuffer(currentFile.getFile()); } @@ -3681,7 +3599,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal try { scheduleCompactAndBlock(60); } catch (Exception e) { - logger.warn("Error during compact", e.getMessage(), e); + logger.warn("Error during compact", e); throw new RuntimeException(e); } } diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalTransaction.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalTransaction.java index c8a74defd4..7fb104df4b 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalTransaction.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalTransaction.java @@ -240,14 +240,15 @@ public class JournalTransaction { // without setting this properly... if (compacting && compactor != null) { if (logger.isTraceEnabled()) { - logger.trace("adding txID=" + this.id + " into compacting"); + logger.trace("adding txID={} into compacting", this.id); } compactor.addCommandCommit(this, file); } else { if (logger.isTraceEnabled()) { - logger.trace("there was no compactor on commit txID=" + this.id); + logger.trace("there was no compactor on commit txID={}", this.id); } + if (pos != null) { for (JournalUpdate trUpdate : pos) { JournalRecord posFiles = journal.getRecords().get(trUpdate.id); diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java index 4b660d355d..c44a9d5546 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPConnectionCallback.java @@ -108,7 +108,7 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { if (factory != null) { result = factory.create(server, manager, connection, protonConnectionDelegate); } else { - logger.debug("Mo matching mechanism found for: " + mechanism); + logger.debug("Mo matching mechanism found for: {}", mechanism); } } return result; @@ -241,7 +241,7 @@ public class AMQPConnectionCallback implements FailureListener, CloseListener { } if (tx == null) { - logger.warn("Couldn't find txid = " + txid); + logger.warn("Couldn't find txid = {}", txid); throw ActiveMQAMQPProtocolMessageBundle.BUNDLE.txNotFound(txid.toString()); } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java index 972ec58763..efa25c89cb 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPSessionCallback.java @@ -714,7 +714,7 @@ public class AMQPSessionCallback implements SessionCallback { ((ProtonServerSenderContext) consumer.getProtocolContext()).close(ec); connection.flush(); } catch (ActiveMQAMQPException e) { - logger.error("Error closing link for " + consumer.getQueue().getAddress()); + logger.error("Error closing link for {}", consumer.getQueue().getAddress()); } }); } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/client/ProtonClientConnectionManager.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/client/ProtonClientConnectionManager.java index cd80501235..cdf998f267 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/client/ProtonClientConnectionManager.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/client/ProtonClientConnectionManager.java @@ -87,10 +87,10 @@ public class ProtonClientConnectionManager implements BaseConnectionLifeCycleLis public void connectionReadyForWrites(Object connectionID, boolean ready) { RemotingConnection connection = connectionMap.get(connectionID); if (connection != null) { - log.info("Connection " + connection.getRemoteAddress() + " ready"); + log.info("Connection {} ready", connection.getRemoteAddress()); connection.getTransportConnection().fireReady(true); } else { - log.error("Connection with id " + connectionID + " not found in connectionReadyForWrites()!"); + log.error("Connection with id {} not found in connectionReadyForWrites()!", connectionID); } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnection.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnection.java index e8551f0699..69ca43a060 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnection.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnection.java @@ -337,7 +337,7 @@ public class AMQPBrokerConnection implements ClientConnectionLifeCycleListener, retryCounter++; ActiveMQAMQPProtocolLogger.LOGGER.retryConnection(brokerConnectConfiguration.getName(), host + ":" + port, retryCounter, brokerConnectConfiguration.getReconnectAttempts()); if (logger.isDebugEnabled()) { - logger.debug("Reconnecting in " + brokerConnectConfiguration.getRetryInterval() + ", this is the " + retryCounter + " of " + brokerConnectConfiguration.getReconnectAttempts()); + logger.debug("Reconnecting in {}, this is the {} of {}", brokerConnectConfiguration.getRetryInterval(), retryCounter, brokerConnectConfiguration.getReconnectAttempts()); } reconnectFuture = scheduledExecutorService.schedule(() -> connectExecutor.execute(() -> doConnect()), brokerConnectConfiguration.getRetryInterval(), TimeUnit.MILLISECONDS); } else { @@ -346,7 +346,7 @@ public class AMQPBrokerConnection implements ClientConnectionLifeCycleListener, connecting = false; ActiveMQAMQPProtocolLogger.LOGGER.retryConnectionFailed(brokerConnectConfiguration.getName(), host + ":" + port, lastRetryCounter); if (logger.isDebugEnabled()) { - logger.debug("no more reconnections as the retry counter reached " + retryCounter + " out of " + brokerConnectConfiguration.getReconnectAttempts()); + logger.debug("no more reconnections as the retry counter reached {} out of {}", retryCounter, brokerConnectConfiguration.getReconnectAttempts()); } } } @@ -395,15 +395,13 @@ public class AMQPBrokerConnection implements ClientConnectionLifeCycleListener, mirrorControlQueue = server.createQueue(new QueueConfiguration(getMirrorSNF(replicaConfig)).setAddress(getMirrorSNF(replicaConfig)).setRoutingType(RoutingType.ANYCAST).setDurable(replicaConfig.isDurable()).setInternal(true), true); } - if (logger.isDebugEnabled()) { - logger.debug("Mirror queue " + mirrorControlQueue.getName()); - } + logger.debug("Mirror queue {}", mirrorControlQueue.getName()); mirrorControlQueue.setMirrorController(true); QueueBinding snfReplicaQueueBinding = (QueueBinding)server.getPostOffice().getBinding(getMirrorSNF(replicaConfig)); if (snfReplicaQueueBinding == null) { - logger.warn("Queue does not exist even after creation! " + replicaConfig); + logger.warn("Queue does not exist even after creation! {}", replicaConfig); throw new IllegalAccessException("Cannot start replica"); } @@ -453,9 +451,7 @@ public class AMQPBrokerConnection implements ClientConnectionLifeCycleListener, AMQPSessionContext sessionContext, Queue queue, Symbol... capabilities) { - if (logger.isDebugEnabled()) { - logger.debug("Connecting inbound for " + queue); - } + logger.debug("Connecting inbound for {}", queue); if (session == null) { logger.debug("session is null"); @@ -501,10 +497,7 @@ public class AMQPBrokerConnection implements ClientConnectionLifeCycleListener, String brokerID, Symbol[] desiredCapabilities, Symbol[] targetCapabilities) { - if (logger.isDebugEnabled()) { - logger.debug("Connecting outbound for " + queue); - } - + logger.debug("Connecting outbound for {}", queue); if (session == null) { logger.debug("Session is null"); @@ -697,9 +690,7 @@ public class AMQPBrokerConnection implements ClientConnectionLifeCycleListener, // keeping a single executor thread to this purpose would simplify things connectExecutor.execute(() -> { if (connecting) { - if (logger.isDebugEnabled()) { - logger.debug("Broker connection " + this.getName() + " was already in retry mode, exception or retry not captured"); - } + logger.debug("Broker connection {} was already in retry mode, exception or retry not captured", getName()); return; } connecting = true; diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnectionManager.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnectionManager.java index 7e3206a0ec..ec9e865d2b 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnectionManager.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnectionManager.java @@ -76,9 +76,8 @@ public class AMQPBrokerConnectionManager implements ActiveMQComponent, ClientCon NettyConnector bridgesConnector = (NettyConnector)factory.createConnector(config.getTransportConfigurations().get(0).getParams(), null, this, server.getExecutorFactory().getExecutor(), server.getThreadPool(), server.getScheduledPool(), new ClientProtocolManagerWithAMQP(protonProtocolManager)); bridgesConnector.start(); - if (logger.isDebugEnabled()) { - logger.debug("Connecting " + config); - } + logger.debug("Connecting {}", config); + AMQPBrokerConnection amqpBrokerConnection = new AMQPBrokerConnection(this, config, protonProtocolManager, server, bridgesConnector); amqpBrokerConnectionList.add(amqpBrokerConnection); server.registerBrokerConnection(amqpBrokerConnection); diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerSource.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerSource.java index ca0ca97949..188742af2c 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerSource.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerSource.java @@ -128,9 +128,7 @@ public class AMQPMirrorControllerSource extends BasicMirrorController im @Override public void addAddress(AddressInfo addressInfo) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace(server + " addAddress " + addressInfo); - } + logger.trace("{} addAddress {}", server, addressInfo); if (getControllerInUse() != null && !addressInfo.isInternal()) { return; @@ -148,9 +146,8 @@ public class AMQPMirrorControllerSource extends BasicMirrorController im @Override public void deleteAddress(AddressInfo addressInfo) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace(server + " deleteAddress " + addressInfo); - } + logger.trace("{} deleteAddress {}", server, addressInfo); + if (invalidTarget(getControllerInUse()) || addressInfo.isInternal()) { return; } @@ -165,18 +162,18 @@ public class AMQPMirrorControllerSource extends BasicMirrorController im @Override public void createQueue(QueueConfiguration queueConfiguration) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace(server + " createQueue " + queueConfiguration); - } + logger.trace("{} createQueue {}", server, queueConfiguration); + if (invalidTarget(getControllerInUse()) || queueConfiguration.isInternal()) { if (logger.isTraceEnabled()) { - logger.trace("Rejecting ping pong on create " + queueConfiguration + " as isInternal=" + queueConfiguration.isInternal() + " and mirror target = " + getControllerInUse()); + logger.trace("Rejecting ping pong on create {} as isInternal={} and mirror target = {}", queueConfiguration, queueConfiguration.isInternal(), getControllerInUse()); } + return; } if (ignoreAddress(queueConfiguration.getAddress())) { if (logger.isTraceEnabled()) { - logger.trace("Skipping create " + queueConfiguration + ", queue address " + queueConfiguration.getAddress() + " doesn't match filter"); + logger.trace("Skipping create {}, queue address {} doesn't match filter", queueConfiguration, queueConfiguration.getAddress()); } return; } @@ -189,7 +186,7 @@ public class AMQPMirrorControllerSource extends BasicMirrorController im @Override public void deleteQueue(SimpleString address, SimpleString queue) throws Exception { if (logger.isTraceEnabled()) { - logger.trace(server + " deleteQueue " + address + "/" + queue); + logger.trace("{} deleteQueue {}/{}", server, address, queue); } if (invalidTarget(getControllerInUse())) { @@ -223,29 +220,21 @@ public class AMQPMirrorControllerSource extends BasicMirrorController im SimpleString address = context.getAddress(message); if (invalidTarget(context.getMirrorSource())) { - if (logger.isTraceEnabled()) { - logger.trace("server " + server + " is discarding send to avoid infinite loop (reflection with the mirror)"); - } + logger.trace("server {} is discarding send to avoid infinite loop (reflection with the mirror)", server); return; } if (context.isInternal()) { - if (logger.isTraceEnabled()) { - logger.trace("server " + server + " is discarding send to avoid sending to internal queue"); - } + logger.trace("server {} is discarding send to avoid sending to internal queue", server); return; } if (ignoreAddress(address)) { - if (logger.isTraceEnabled()) { - logger.trace("server " + server + " is discarding send to address " + address + ", address doesn't match filter"); - } + logger.trace("server {} is discarding send to address {}, address doesn't match filter", server, address); return; } - if (logger.isTraceEnabled()) { - logger.trace(server + " send message " + message); - } + logger.trace("{} send message {}", server, message); try { context.setReusable(false); @@ -253,9 +242,7 @@ public class AMQPMirrorControllerSource extends BasicMirrorController im MessageReference ref = MessageReference.Factory.createReference(message, snfQueue); String nodeID = setProtocolData(idSupplier, ref); if (nodeID != null && nodeID.equals(getRemoteMirrorId())) { - if (logger.isTraceEnabled()) { - logger.trace("Message " + message + "already belonged to the node, " + getRemoteMirrorId() + ", it won't circle send"); - } + logger.trace("Message {} already belonged to the node, {}, it won't circle send", message, getRemoteMirrorId()); return; } snfQueue.refUp(ref); @@ -331,26 +318,24 @@ public class AMQPMirrorControllerSource extends BasicMirrorController im if ((ref.getQueue() != null && (ref.getQueue().isInternalQueue() || ref.getQueue().isMirrorController()))) { if (logger.isDebugEnabled()) { - logger.debug(server + " rejecting postAcknowledge queue=" + ref.getQueue().getName() + ", ref=" + ref + " to avoid infinite loop with the mirror (reflection)"); + logger.debug("{} rejecting postAcknowledge queue={}, ref={} to avoid infinite loop with the mirror (reflection)", server, ref.getQueue().getName(), ref); } return; } if (ignoreAddress(ref.getQueue().getAddress())) { if (logger.isTraceEnabled()) { - logger.trace(server + " rejecting postAcknowledge queue=" + ref.getQueue().getName() + ", ref=" + ref + ", queue address is excluded"); + logger.trace("{} rejecting postAcknowledge queue={}, ref={}, queue address is excluded", server, ref.getQueue().getName(), ref); } return; } - if (logger.isTraceEnabled()) { - logger.trace(server + " postAcknowledge " + ref); - } + logger.trace("{} postAcknowledge {}", server, ref); String nodeID = idSupplier.getServerID(ref); // notice the brokerID will be null for any message generated on this broker. long internalID = idSupplier.getID(ref); if (logger.isTraceEnabled()) { - logger.trace(server + " sending ack message from server " + nodeID + " with messageID=" + internalID); + logger.trace("{} sending ack message from server {} with messageID={}", server, nodeID, internalID); } Message message = createMessage(ref.getQueue().getAddress(), ref.getQueue().getName(), POST_ACK, nodeID, internalID, reason); route(server, message); diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerTarget.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerTarget.java index a17aa355a2..4ca9c9dcd6 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerTarget.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerTarget.java @@ -120,9 +120,7 @@ public class AMQPMirrorControllerTarget extends ProtonAbstractReceiver implement @Override public void run() { - if (logger.isTraceEnabled()) { - logger.trace("Delivery settling for " + delivery + ", context=" + delivery.getContext()); - } + logger.trace("Delivery settling for {}, context={}", delivery, delivery.getContext()); delivery.disposition(Accepted.getInstance()); settle(delivery); connection.flush(); @@ -188,9 +186,7 @@ public class AMQPMirrorControllerTarget extends ProtonAbstractReceiver implement recoverContext(); incrementSettle(); - if (logger.isTraceEnabled()) { - logger.trace(server + "::actualdelivery call for " + message); - } + logger.trace("{}::actualdelivery call for {}", server, message); setControllerInUse(this); delivery.setContext(message); @@ -280,17 +276,15 @@ public class AMQPMirrorControllerTarget extends ProtonAbstractReceiver implement @Override public void addAddress(AddressInfo addressInfo) throws Exception { - if (logger.isDebugEnabled()) { - logger.debug(server + " adding address " + addressInfo); - } + logger.debug("{} adding address {}", server, addressInfo); + server.addAddressInfo(addressInfo); } @Override public void deleteAddress(AddressInfo addressInfo) throws Exception { - if (logger.isDebugEnabled()) { - logger.debug(server + " delete address " + addressInfo); - } + logger.debug("{} delete address {}", server, addressInfo); + try { server.removeAddressInfo(addressInfo.getName(), null, true); } catch (ActiveMQAddressDoesNotExistException expected) { @@ -303,25 +297,26 @@ public class AMQPMirrorControllerTarget extends ProtonAbstractReceiver implement @Override public void createQueue(QueueConfiguration queueConfiguration) throws Exception { - if (logger.isDebugEnabled()) { - logger.debug(server + " adding queue " + queueConfiguration); - } + logger.debug("{} adding queue {}", server, queueConfiguration); + try { server.createQueue(queueConfiguration, true); } catch (Exception e) { - logger.debug("Queue could not be created, already existed " + queueConfiguration, e); + logger.debug("Queue could not be created, already existed {}", queueConfiguration, e); } } @Override public void deleteQueue(SimpleString addressName, SimpleString queueName) throws Exception { if (logger.isDebugEnabled()) { - logger.debug(server + " destroy queue " + queueName + " on address = " + addressName + " server " + server.getIdentity()); + logger.debug("{} destroy queue {} on address = {} server {}", server, queueName, addressName, server.getIdentity()); } try { server.destroyQueue(queueName, null, false, true, false, false); } catch (ActiveMQNonExistentQueueException expected) { - logger.debug(server + " queue " + queueName + " was previously removed", expected); + if (logger.isDebugEnabled()) { + logger.debug("{} queue {} was previously removed", server, queueName, expected); + } } } @@ -333,19 +328,20 @@ public class AMQPMirrorControllerTarget extends ProtonAbstractReceiver implement final Queue targetQueue = server.locateQueue(queue); if (targetQueue == null) { - logger.warn("Queue " + queue + " not found on mirror target, ignoring ack for queue=" + queue + ", messageID=" + messageID + ", nodeID=" + nodeID); + logger.warn("Queue {} not found on mirror target, ignoring ack for queue={}, messageID={}, nodeID={}", queue, queue, messageID, nodeID); return false; } if (logger.isDebugEnabled()) { // we only do the following check if debug if (targetQueue.getConsumerCount() > 0) { - logger.debug("server " + server.getIdentity() + ", queue " + targetQueue.getName() + " has consumers while delivering ack for " + messageID); + logger.debug("server {}, queue {} has consumers while delivering ack for {}", server.getIdentity(), targetQueue.getName(), messageID); } } if (logger.isTraceEnabled()) { - logger.trace("Server " + server.getIdentity() + " with queue = " + queue + " being acked for " + messageID + " coming from " + messageID + " targetQueue = " + targetQueue); + logger.trace("Server {} with queue = {} being acked for {} coming from {} targetQueue = {}", + server.getIdentity(), queue, messageID, messageID, targetQueue); } performAck(nodeID, messageID, targetQueue, ackMessage, reason, (short)0); @@ -359,13 +355,13 @@ public class AMQPMirrorControllerTarget extends ProtonAbstractReceiver implement private void performAck(String nodeID, long messageID, Queue targetQueue, ACKMessageOperation ackMessageOperation, AckReason reason, final short retry) { if (logger.isTraceEnabled()) { - logger.trace("performAck (nodeID=" + nodeID + ", messageID=" + messageID + ")" + ", targetQueue=" + targetQueue.getName()); + logger.trace("performAck (nodeID={}, messageID={}), targetQueue={}", nodeID, messageID, targetQueue.getName()); } MessageReference reference = targetQueue.removeWithSuppliedID(nodeID, messageID, referenceNodeStore); if (reference == null) { if (logger.isDebugEnabled()) { - logger.debug("Retrying Reference not found on messageID=" + messageID + " nodeID=" + nodeID + ", currentRetry=" + retry); + logger.debug("Retrying Reference not found on messageID={}, nodeID={}, currentRetry={}", messageID, nodeID, retry); } switch (retry) { case 0: @@ -394,7 +390,7 @@ public class AMQPMirrorControllerTarget extends ProtonAbstractReceiver implement if (reference != null) { if (logger.isTraceEnabled()) { - logger.trace("Post ack Server " + server + " worked well for messageID=" + messageID + " nodeID=" + nodeID); + logger.trace("Post ack Server {} worked well for messageID={} nodeID={}", server, messageID, nodeID); } try { switch (reason) { @@ -437,7 +433,7 @@ public class AMQPMirrorControllerTarget extends ProtonAbstractReceiver implement } if (logger.isTraceEnabled()) { - logger.trace("sendMessage on server " + server + " for message " + message + " with internalID = " + internalIDLong + " mirror id " + internalMirrorID); + logger.trace("sendMessage on server {} for message {} with internalID = {} mirror id {}", server, message, internalIDLong, internalMirrorID); } routingContext.setDuplicateDetection(false); // we do our own duplicate detection here diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java index 486d39c9e5..caaf5c62f2 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java @@ -776,7 +776,7 @@ public class AMQPConnectionContext extends ProtonInitializable implements EventH if (handler != null) { handler.onMessage(delivery); } else { - log.warn("Handler is null, can't delivery " + delivery, new Exception("tracing location")); + log.warn("Handler is null, can't delivery {}", delivery, new Exception("tracing location")); } } diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java index 65952fb298..3e0c3699e8 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java @@ -678,9 +678,8 @@ public class ProtonServerSenderContext extends ProtonInitializable implements Pr replaceInitialHeader(deliveryAnnotationsToEncode, context, new NettyWritable(frameBuffer)); } catch (IndexOutOfBoundsException indexOutOfBoundsException) { assert position == 0 : "this shouldn't happen unless replaceInitialHeader is updating position before modifying frameBuffer"; - if (log.isDebugEnabled()) { - log.debug("Delivery of message failed with an overFlowException, retrying again with expandable buffer"); - } + log.debug("Delivery of message failed with an overFlowException, retrying again with expandable buffer"); + // on the very first packet, if the initial header was replaced with a much bigger header (re-encoding) // we could recover the situation with a retry using an expandable buffer. // this is tested on org.apache.activemq.artemis.tests.integration.amqp.AmqpMessageDivertsTest diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java index b7cfae0cf7..25fb38c4c5 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java +++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/handler/ProtonHandler.java @@ -411,7 +411,7 @@ public class ProtonHandler extends ProtonInitializable implements SaslListener { int received = sasl.recv(dataSASL, 0, dataSASL.length); if (log.isTraceEnabled()) { - log.trace("Working on sasl, length:" + received); + log.trace("Working on sasl, length:{}", received); } byte[] response = chosenMechanism.processSASL(received != -1 ? dataSASL : null); @@ -559,9 +559,8 @@ public class ProtonHandler extends ProtonInitializable implements SaslListener { } while ((ev = collector.peek()) != null) { for (EventHandler h : handlers) { - if (log.isTraceEnabled()) { - log.trace("Handling " + ev + " towards " + h); - } + log.trace("Handling {} towards {}", ev, h); + try { Events.dispatch(ev, h); } catch (ActiveMQSecurityException e) { diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java index 9ddc71f9a0..20d5d001a5 100644 --- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java +++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/converter/TestConversions.java @@ -418,7 +418,7 @@ public class TestConversions extends Assert { for (int i = 0; i < 10; i++) { if (logger.isDebugEnabled()) { - logger.debug("Message encoded :: " + encodedMessage.toDebugString()); + logger.debug("Message encoded :: {}", encodedMessage.toDebugString()); } encodedMessage.messageChanged(); @@ -428,9 +428,7 @@ public class TestConversions extends Assert { // this line is needed to force a failure ICoreMessage coreMessage = encodedMessage.toCore(); - if (logger.isDebugEnabled()) { - logger.debug("Converted message: " + coreMessage); - } + logger.debug("Converted message: {}", coreMessage); } } @@ -459,9 +457,7 @@ public class TestConversions extends Assert { AmqpValue value = (AmqpValue) encodedMessage.getProtonMessage().getBody(); Assert.assertEquals(text, (String) value.getValue()); ICoreMessage coreMessage = encodedMessage.toCore(); - if (logger.isDebugEnabled()) { - logger.debug("Converted message: " + coreMessage); - } + logger.debug("Converted message: {}", coreMessage); // I'm going to replace the message every 10 messages by a re-encoded version to check if the wiring still acturate. // I want to mix replacing and not replacing to make sure the re-encoding is not giving me any surprises diff --git a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java index 9e7c710dea..1bf3c35bd9 100644 --- a/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java +++ b/artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTPublishManager.java @@ -243,9 +243,7 @@ public class MQTTPublishManager { if (closeMqttConnectionOnPublishAuthorizationFailure) { throw e; } else { - if (logger.isDebugEnabled()) { - logger.debug("MQTT 3.1.1 client not authorized to publish message."); - } + logger.debug("MQTT 3.1.1 client not authorized to publish message."); } } else { /* @@ -258,9 +256,7 @@ public class MQTTPublishManager { * * Log the failure since we have to just swallow it. */ - if (logger.isDebugEnabled()) { - logger.debug("MQTT 3.1 client not authorized to publish message."); - } + logger.debug("MQTT 3.1 client not authorized to publish message."); } } catch (Throwable t) { MQTTLogger.LOGGER.failedToPublishMqttMessage(t.getMessage(), t); @@ -364,7 +360,7 @@ public class MQTTPublishManager { releaseFlowControl(ref.getB()); } } catch (ActiveMQIllegalStateException e) { - logger.warn("MQTT Client(" + session.getState().getClientId() + ") attempted to Ack already Ack'd message"); + logger.warn("MQTT Client({}) attempted to Ack already Ack'd message", session.getState().getClientId()); } } diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java index 3e67ef417f..943d9a3cf2 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java @@ -293,7 +293,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se * Log packaged into a separate method for performance reasons. */ private static void traceBufferReceived(Object connectionID, Command command) { - logger.trace("connectionID: " + connectionID + " RECEIVED: " + (command == null ? "NULL" : command)); + logger.trace("connectionID: {} RECEIVED: {}", connectionID, (command == null ? "NULL" : command)); } @Override @@ -531,7 +531,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se * Log packaged into a separate method for performance reasons. */ private static void tracePhysicalSend(Connection transportConnection, Command command) { - logger.trace("connectionID: " + (transportConnection == null ? "" : transportConnection.getID()) + " SENDING: " + (command == null ? "NULL" : command)); + logger.trace("connectionID: {} SENDING: {}", (transportConnection == null ? "" : transportConnection.getID()), (command == null ? "NULL" : command)); } public void physicalSend(Command command) throws IOException { @@ -770,8 +770,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se try { protocolManager.getScheduledPool().schedule(() -> { fail(new ActiveMQException(reason, cause, ActiveMQExceptionType.GENERIC_EXCEPTION), reason); - logger.warn("Stopping " + transportConnection.getRemoteAddress() + "because " + - reason); + logger.warn("Stopping {} because {}", transportConnection.getRemoteAddress(), reason); }, waitTimeMillis, TimeUnit.MILLISECONDS); } catch (Throwable t) { logger.warn("Cannot stop connection. This exception will be ignored.", t); @@ -868,9 +867,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se * This will answer with commands to the client */ public boolean sendCommand(final Command command) { - if (logger.isTraceEnabled()) { - logger.trace("sending " + command); - } + logger.trace("sending {}", command); if (isDestroyed()) { return false; @@ -922,7 +919,8 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se if (!tempDestinationExists(info.getDestination().getPhysicalName())) { this.state.addTempDestination(info); if (logger.isDebugEnabled()) { - logger.debug(this + " added temp destination to state: " + info.getDestination().getPhysicalName() + "; " + state.getTempDestinations().size()); + logger.debug("{} added temp destination to state: {} ; {}", + this, info.getDestination().getPhysicalName(), state.getTempDestinations().size()); } } } @@ -1035,7 +1033,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se ActiveMQDestination dest = new ActiveMQTempQueue(bindingName.toString()); state.removeTempDestination(dest); if (logger.isDebugEnabled()) { - logger.debug(this + " removed temp destination from state: " + bindingName + "; " + state.getTempDestinations().size()); + logger.debug("{} removed temp destination from state: {} ; {}", this, bindingName, state.getTempDestinations().size()); } if (!AdvisorySupport.isAdvisoryTopic(dest)) { @@ -1046,7 +1044,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se try { protocolManager.fireAdvisory(context, topic, advInfo); } catch (Exception e) { - logger.warn("Failed to fire advisory on " + topic, e); + logger.warn("Failed to fire advisory on {}", topic, e); } } } @@ -1138,7 +1136,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se if (!dest.isTemporary()) { // this should not really happen, // so I'm not creating a Logger for this - logger.warn("OpenWire client sending a queue remove towards " + dest.getPhysicalName()); + logger.warn("OpenWire client sending a queue remove towards {}", dest.getPhysicalName()); } try { server.destroyQueue(new SimpleString(dest.getPhysicalName()), getRemotingConnection()); @@ -1369,9 +1367,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se ex.errorCode = XAException.XA_HEURRB; throw ex; } else { - if (logger.isTraceEnabled()) { - logger.trace("xarollback into " + tx + ", xid=" + xid + " forcing a rollback regular"); - } + logger.trace("xarollback into {}, xid={} forcing a rollback regular", tx, xid); try { if (amqSession != null) { @@ -1387,9 +1383,8 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se } } else { if (tx.getState() == Transaction.State.SUSPENDED) { - if (logger.isTraceEnabled()) { - logger.trace("xarollback into " + tx + " sending tx back as it was suspended"); - } + logger.trace("xarollback into {} sending tx back as it was suspended", tx); + // Put it back resourceManager.putTransaction(xid, tx, OpenWireConnection.this); XAException ex = new XAException("Cannot commit transaction, it is suspended " + xid); @@ -1520,9 +1515,8 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se if (txID.isXATransaction()) { ResourceManager resourceManager = server.getResourceManager(); Xid xid = OpenWireUtil.toXID(txID); - if (logger.isTraceEnabled()) { - logger.trace("XAcommit into " + tx + ", xid=" + xid); - } + + logger.trace("XAcommit into {}, xid={}", tx, xid); if (tx == null) { if (resourceManager.getHeuristicCommittedTransactions().contains(xid)) { @@ -1535,9 +1529,7 @@ public class OpenWireConnection extends AbstractRemotingConnection implements Se ex.errorCode = XAException.XA_HEURRB; throw ex; } else { - if (logger.isTraceEnabled()) { - logger.trace("XAcommit into " + tx + ", xid=" + xid + " cannot find it"); - } + logger.trace("XAcommit into {}, xid={} cannot find it", tx, xid); XAException ex = new XAException("Cannot find xid in resource manager: " + xid); ex.errorCode = XAException.XAER_NOTA; throw ex; diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABytesMessage.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABytesMessage.java index f62ee992ca..36c721ca39 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABytesMessage.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRABytesMessage.java @@ -40,9 +40,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe public ActiveMQRABytesMessage(final BytesMessage message, final ActiveMQRASession session) { super(message, session); - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + message + ", " + session + ")"); - } + logger.trace("constructor({}, {})", message, session); } /** @@ -53,9 +51,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public long getBodyLength() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getBodyLength()"); - } + logger.trace("getBodyLength()"); return ((BytesMessage) message).getBodyLength(); } @@ -68,9 +64,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public boolean readBoolean() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readBoolean()"); - } + logger.trace("readBoolean()"); return ((BytesMessage) message).readBoolean(); } @@ -83,9 +77,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public byte readByte() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readByte()"); - } + logger.trace("readByte()"); return ((BytesMessage) message).readByte(); } @@ -101,7 +93,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public int readBytes(final byte[] value, final int length) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("readBytes(" + Arrays.toString(value) + ", " + length + ")"); + logger.trace("readBytes({}, {})", Arrays.toString(value), length); } return ((BytesMessage) message).readBytes(value, length); @@ -117,7 +109,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public int readBytes(final byte[] value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("readBytes(" + Arrays.toString(value) + ")"); + logger.trace("readBytes({})", Arrays.toString(value)); } return ((BytesMessage) message).readBytes(value); @@ -131,9 +123,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public char readChar() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readChar()"); - } + logger.trace("readChar()"); return ((BytesMessage) message).readChar(); } @@ -146,9 +136,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public double readDouble() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readDouble()"); - } + logger.trace("readDouble()"); return ((BytesMessage) message).readDouble(); } @@ -161,9 +149,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public float readFloat() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readFloat()"); - } + logger.trace("readFloat()"); return ((BytesMessage) message).readFloat(); } @@ -176,9 +162,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public int readInt() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readInt()"); - } + logger.trace("readInt()"); return ((BytesMessage) message).readInt(); } @@ -191,9 +175,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public long readLong() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readLong()"); - } + logger.trace("readLong()"); return ((BytesMessage) message).readLong(); } @@ -206,9 +188,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public short readShort() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readShort()"); - } + logger.trace("readShort()"); return ((BytesMessage) message).readShort(); } @@ -221,9 +201,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public int readUnsignedByte() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readUnsignedByte()"); - } + logger.trace("readUnsignedByte()"); return ((BytesMessage) message).readUnsignedByte(); } @@ -236,9 +214,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public int readUnsignedShort() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readUnsignedShort()"); - } + logger.trace("readUnsignedShort()"); return ((BytesMessage) message).readUnsignedShort(); } @@ -251,9 +227,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public String readUTF() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readUTF()"); - } + logger.trace("readUTF()"); return ((BytesMessage) message).readUTF(); } @@ -265,9 +239,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public void reset() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("reset()"); - } + logger.trace("reset()"); ((BytesMessage) message).reset(); } @@ -281,7 +253,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public void writeBoolean(final boolean value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeBoolean(" + value + ")"); + logger.trace("writeBoolean({})", value); } ((BytesMessage) message).writeBoolean(value); @@ -296,7 +268,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public void writeByte(final byte value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeByte(" + value + ")"); + logger.trace("writeByte({})", value); } ((BytesMessage) message).writeByte(value); @@ -313,7 +285,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public void writeBytes(final byte[] value, final int offset, final int length) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeBytes(" + Arrays.toString(value) + ", " + offset + ", " + length + ")"); + logger.trace("writeBytes({}, {}, {})", Arrays.toString(value), offset, length); } ((BytesMessage) message).writeBytes(value, offset, length); @@ -328,7 +300,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public void writeBytes(final byte[] value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeBytes(" + Arrays.toString(value) + ")"); + logger.trace("writeBytes({})", Arrays.toString(value)); } ((BytesMessage) message).writeBytes(value); @@ -343,7 +315,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public void writeChar(final char value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeChar(" + value + ")"); + logger.trace("writeChar({})", value); } ((BytesMessage) message).writeChar(value); @@ -358,7 +330,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public void writeDouble(final double value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeDouble(" + value + ")"); + logger.trace("writeDouble({})", value); } ((BytesMessage) message).writeDouble(value); @@ -373,7 +345,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public void writeFloat(final float value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeFloat(" + value + ")"); + logger.trace("writeFloat({})", value); } ((BytesMessage) message).writeFloat(value); @@ -388,7 +360,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public void writeInt(final int value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeInt(" + value + ")"); + logger.trace("writeInt({})", value); } ((BytesMessage) message).writeInt(value); @@ -403,7 +375,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public void writeLong(final long value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeLong(" + value + ")"); + logger.trace("writeLong({})", value); } ((BytesMessage) message).writeLong(value); @@ -417,9 +389,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public void writeObject(final Object value) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("writeObject(" + value + ")"); - } + logger.trace("writeObject({})", value); ((BytesMessage) message).writeObject(value); } @@ -433,7 +403,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe @Override public void writeShort(final short value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeShort(" + value + ")"); + logger.trace("writeShort({})", value); } ((BytesMessage) message).writeShort(value); @@ -447,9 +417,7 @@ public class ActiveMQRABytesMessage extends ActiveMQRAMessage implements BytesMe */ @Override public void writeUTF(final String value) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("writeUTF(" + value + ")"); - } + logger.trace("writeUTF({})", value); ((BytesMessage) message).writeUTF(value); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionFactoryImpl.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionFactoryImpl.java index 9a4e97b4e0..3cc75d4d61 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionFactoryImpl.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionFactoryImpl.java @@ -75,25 +75,19 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact * @param cm The connection manager */ public ActiveMQRAConnectionFactoryImpl(final ActiveMQRAManagedConnectionFactory mcf, final ConnectionManager cm) { - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + mcf + ", " + cm + ")"); - } + logger.trace("constructor({}, {})", mcf, cm); this.mcf = mcf; if (cm == null) { // This is standalone usage, no appserver this.cm = new ActiveMQRAConnectionManager(); - if (logger.isTraceEnabled()) { - logger.trace("Created new ConnectionManager=" + this.cm); - } + logger.trace("Created new ConnectionManager={}", this.cm); } else { this.cm = cm; } - if (logger.isTraceEnabled()) { - logger.trace("Using ManagedConnectionFactory=" + mcf + ", ConnectionManager=" + cm); - } + logger.trace("Using ManagedConnectionFactory={}, ConnectionManager={}", mcf, cm); } /** @@ -103,9 +97,7 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public void setReference(final Reference reference) { - if (logger.isTraceEnabled()) { - logger.trace("setReference(" + reference + ")"); - } + logger.trace("setReference({})", reference); this.reference = reference; } @@ -117,9 +109,8 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public Reference getReference() { - if (logger.isTraceEnabled()) { - logger.trace("getReference()"); - } + logger.trace("getReference()"); + if (reference == null) { try { reference = new Reference(this.getClass().getCanonicalName(), new SerializableObjectRefAddr("ActiveMQ-CF", this), ActiveMQRAConnectionFactoryObjectFactory.class.getCanonicalName(), null); @@ -140,15 +131,11 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public QueueConnection createQueueConnection() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createQueueConnection()"); - } + logger.trace("createQueueConnection()"); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.QUEUE_CONNECTION); - if (logger.isTraceEnabled()) { - logger.trace("Created queue connection: " + s); - } + logger.trace("Created queue connection: {}", s); return s; } @@ -163,9 +150,7 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public QueueConnection createQueueConnection(final String userName, final String password) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createQueueConnection(" + userName + ", ****)"); - } + logger.trace("createQueueConnection({}, ****)", userName); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.QUEUE_CONNECTION); s.setUserName(userName); @@ -173,9 +158,7 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact validateUser(s); - if (logger.isTraceEnabled()) { - logger.trace("Created queue connection: " + s); - } + logger.trace("Created queue connection: {}", s); return s; } @@ -188,15 +171,11 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public TopicConnection createTopicConnection() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createTopicConnection()"); - } + logger.trace("createTopicConnection()"); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.TOPIC_CONNECTION); - if (logger.isTraceEnabled()) { - logger.trace("Created topic connection: " + s); - } + logger.trace("Created topic connection: {}", s); return s; } @@ -211,18 +190,14 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public TopicConnection createTopicConnection(final String userName, final String password) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createTopicConnection(" + userName + ", ****)"); - } + logger.trace("createTopicConnection({}, ****)", userName); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.TOPIC_CONNECTION); s.setUserName(userName); s.setPassword(password); validateUser(s); - if (logger.isTraceEnabled()) { - logger.trace("Created topic connection: " + s); - } + logger.trace("Created topic connection: {}", s); return s; } @@ -235,15 +210,11 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public Connection createConnection() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createConnection()"); - } + logger.trace("createConnection()"); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.CONNECTION); - if (logger.isTraceEnabled()) { - logger.trace("Created connection: " + s); - } + logger.trace("Created connection: {}", s); return s; } @@ -258,9 +229,7 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public Connection createConnection(final String userName, final String password) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createConnection(" + userName + ", ****)"); - } + logger.trace("createConnection({}, ****)", userName); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.CONNECTION); s.setUserName(userName); @@ -268,9 +237,7 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact validateUser(s); - if (logger.isTraceEnabled()) { - logger.trace("Created connection: " + s); - } + logger.trace("Created connection: {}", s); return s; } @@ -283,15 +250,11 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public XAQueueConnection createXAQueueConnection() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createXAQueueConnection()"); - } + logger.trace("createXAQueueConnection()"); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION); - if (logger.isTraceEnabled()) { - logger.trace("Created queue connection: " + s); - } + logger.trace("Created queue connection: {}", s); return s; } @@ -306,18 +269,14 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public XAQueueConnection createXAQueueConnection(final String userName, final String password) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createXAQueueConnection(" + userName + ", ****)"); - } + logger.trace("createXAQueueConnection({}, ****)", userName); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_QUEUE_CONNECTION); s.setUserName(userName); s.setPassword(password); validateUser(s); - if (logger.isTraceEnabled()) { - logger.trace("Created queue connection: " + s); - } + logger.trace("Created queue connection: {}", s); return s; } @@ -330,15 +289,11 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public XATopicConnection createXATopicConnection() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createXATopicConnection()"); - } + logger.trace("createXATopicConnection()"); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION); - if (logger.isTraceEnabled()) { - logger.trace("Created topic connection: " + s); - } + logger.trace("Created topic connection: {}", s); return s; } @@ -353,18 +308,14 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public XATopicConnection createXATopicConnection(final String userName, final String password) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createXATopicConnection(" + userName + ", ****)"); - } + logger.trace("createXATopicConnection({}, ****)", userName); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_TOPIC_CONNECTION); s.setUserName(userName); s.setPassword(password); validateUser(s); - if (logger.isTraceEnabled()) { - logger.trace("Created topic connection: " + s); - } + logger.trace("Created topic connection: {}", s); return s; } @@ -377,15 +328,11 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public XAConnection createXAConnection() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createXAConnection()"); - } + logger.trace("createXAConnection()"); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_CONNECTION); - if (logger.isTraceEnabled()) { - logger.trace("Created connection: " + s); - } + logger.trace("Created connection: {}", s); return s; } @@ -400,18 +347,14 @@ public class ActiveMQRAConnectionFactoryImpl implements ActiveMQRAConnectionFact */ @Override public XAConnection createXAConnection(final String userName, final String password) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createXAConnection(" + userName + ", ****)"); - } + logger.trace("createXAConnection({}, ****)", userName); ActiveMQRASessionFactoryImpl s = new ActiveMQRASessionFactoryImpl(mcf, cm, getResourceAdapter().getTM(), ActiveMQRAConnectionFactory.XA_CONNECTION); s.setUserName(userName); s.setPassword(password); validateUser(s); - if (logger.isTraceEnabled()) { - logger.trace("Created connection: " + s); - } + logger.trace("Created connection: {}", s); return s; } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionManager.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionManager.java index edb72a4721..c5dbcc2ea9 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionManager.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionManager.java @@ -44,9 +44,7 @@ public class ActiveMQRAConnectionManager implements ConnectionManager { * Constructor */ public ActiveMQRAConnectionManager() { - if (logger.isTraceEnabled()) { - logger.trace("constructor()"); - } + logger.trace("constructor()"); } ConcurrentHashSet connections = new ConcurrentHashSet<>(); @@ -62,16 +60,12 @@ public class ActiveMQRAConnectionManager implements ConnectionManager { @Override public Object allocateConnection(final ManagedConnectionFactory mcf, final ConnectionRequestInfo cxRequestInfo) throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("allocateConnection(" + mcf + ", " + cxRequestInfo + ")"); - } + logger.trace("allocateConnection({}, {})", mcf, cxRequestInfo); ManagedConnection mc = mcf.createManagedConnection(null, cxRequestInfo); Object c = mc.getConnection(null, cxRequestInfo); - if (logger.isTraceEnabled()) { - logger.trace("Allocated connection: " + c + ", with managed connection: " + mc); - } + logger.trace("Allocated connection: {}, with managed connection: {}", c, mc); connections.add(mc); return c; diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionMetaData.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionMetaData.java index 78b6a80d63..5687d4e118 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionMetaData.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionMetaData.java @@ -56,9 +56,7 @@ public class ActiveMQRAConnectionMetaData implements ConnectionMetaData { * Constructor */ public ActiveMQRAConnectionMetaData() { - if (logger.isTraceEnabled()) { - logger.trace("constructor()"); - } + logger.trace("constructor()"); } /** @@ -68,9 +66,7 @@ public class ActiveMQRAConnectionMetaData implements ConnectionMetaData { */ @Override public String getJMSVersion() { - if (logger.isTraceEnabled()) { - logger.trace("getJMSVersion()"); - } + logger.trace("getJMSVersion()"); return JMS_VERSION_NAME; } @@ -81,9 +77,7 @@ public class ActiveMQRAConnectionMetaData implements ConnectionMetaData { */ @Override public int getJMSMajorVersion() { - if (logger.isTraceEnabled()) { - logger.trace("getJMSMajorVersion()"); - } + logger.trace("getJMSMajorVersion()"); return JMS_MAJOR_VERSION; } @@ -94,9 +88,7 @@ public class ActiveMQRAConnectionMetaData implements ConnectionMetaData { */ @Override public int getJMSMinorVersion() { - if (logger.isTraceEnabled()) { - logger.trace("getJMSMinorVersion()"); - } + logger.trace("getJMSMinorVersion()"); return JMS_MINOR_VERSION; } @@ -107,9 +99,7 @@ public class ActiveMQRAConnectionMetaData implements ConnectionMetaData { */ @Override public String getJMSProviderName() { - if (logger.isTraceEnabled()) { - logger.trace("getJMSProviderName()"); - } + logger.trace("getJMSProviderName()"); return "ActiveMQ Artemis"; } @@ -121,9 +111,7 @@ public class ActiveMQRAConnectionMetaData implements ConnectionMetaData { */ @Override public String getProviderVersion() { - if (logger.isTraceEnabled()) { - logger.trace("getJMSProviderName()"); - } + logger.trace("getJMSProviderName()"); return "2.4"; } @@ -135,9 +123,7 @@ public class ActiveMQRAConnectionMetaData implements ConnectionMetaData { */ @Override public int getProviderMajorVersion() { - if (logger.isTraceEnabled()) { - logger.trace("getProviderMajorVersion()"); - } + logger.trace("getProviderMajorVersion()"); return 2; } @@ -149,9 +135,7 @@ public class ActiveMQRAConnectionMetaData implements ConnectionMetaData { */ @Override public int getProviderMinorVersion() { - if (logger.isTraceEnabled()) { - logger.trace("getProviderMinorVersion()"); - } + logger.trace("getProviderMinorVersion()"); return 4; } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionRequestInfo.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionRequestInfo.java index ca88e5d1f7..00bb041e5e 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionRequestInfo.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAConnectionRequestInfo.java @@ -67,9 +67,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { * @param type The connection type */ public ActiveMQRAConnectionRequestInfo(final ActiveMQRAProperties prop, final int type) { - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + prop + ")"); - } + logger.trace("constructor({})", prop); userName = prop.getUserName(); password = prop.getPassword(); @@ -88,12 +86,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { */ public ActiveMQRAConnectionRequestInfo(final boolean transacted, final int acknowledgeMode, final int type) { if (logger.isTraceEnabled()) { - logger.trace("constructor(" + transacted + - ", " + - acknowledgeMode + - ", " + - type + - ")"); + logger.trace("constructor({}, {}, {})", transacted, acknowledgeMode, type); } this.transacted = transacted; @@ -107,9 +100,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { * @param prop The resource adapter properties */ public void setDefaults(final ActiveMQRAProperties prop) { - if (logger.isTraceEnabled()) { - logger.trace("setDefaults(" + prop + ")"); - } + logger.trace("setDefaults({})", prop); if (userName == null) { userName = prop.getUserName(); @@ -128,9 +119,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { * @return The value */ public String getUserName() { - if (logger.isTraceEnabled()) { - logger.trace("getUserName()"); - } + logger.trace("getUserName()"); return userName; } @@ -141,9 +130,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { * @param userName The value */ public void setUserName(final String userName) { - if (logger.isTraceEnabled()) { - logger.trace("setUserName(" + userName + ")"); - } + logger.trace("setUserName({})", userName); this.userName = userName; } @@ -154,9 +141,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { * @return The value */ public String getPassword() { - if (logger.isTraceEnabled()) { - logger.trace("getPassword()"); - } + logger.trace("getPassword()"); return password; } @@ -167,9 +152,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { * @param password The value */ public void setPassword(final String password) { - if (logger.isTraceEnabled()) { - logger.trace("setPassword(****)"); - } + logger.trace("setPassword(****)"); this.password = password; } @@ -180,9 +163,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { * @return The value */ public String getClientID() { - if (logger.isTraceEnabled()) { - logger.trace("getClientID()"); - } + logger.trace("getClientID()"); return clientID; } @@ -193,9 +174,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { * @param clientID The value */ public void setClientID(final String clientID) { - if (logger.isTraceEnabled()) { - logger.trace("setClientID(" + clientID + ")"); - } + logger.trace("setClientID({})", clientID); this.clientID = clientID; } @@ -206,9 +185,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { * @return The type */ public int getType() { - if (logger.isTraceEnabled()) { - logger.trace("getType()"); - } + logger.trace("getType()"); return type; } @@ -220,7 +197,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { */ public boolean isTransacted() { if (logger.isTraceEnabled()) { - logger.trace("isTransacted() " + transacted); + logger.trace("isTransacted() {}", transacted); } return transacted; @@ -232,9 +209,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { * @return The mode */ public int getAcknowledgeMode() { - if (logger.isTraceEnabled()) { - logger.trace("getAcknowledgeMode()"); - } + logger.trace("getAcknowledgeMode()"); return acknowledgeMode; } @@ -247,9 +222,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { */ @Override public boolean equals(final Object obj) { - if (logger.isTraceEnabled()) { - logger.trace("equals(" + obj + ")"); - } + logger.trace("equals({})", obj); if (obj == null) { return false; @@ -274,9 +247,7 @@ public class ActiveMQRAConnectionRequestInfo implements ConnectionRequestInfo { */ @Override public int hashCode() { - if (logger.isTraceEnabled()) { - logger.trace("hashCode()"); - } + logger.trace("hashCode()"); int hash = 7; diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRACredential.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRACredential.java index 9dd850afe4..4d424fc620 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRACredential.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRACredential.java @@ -56,9 +56,7 @@ public class ActiveMQRACredential implements Serializable { * Private constructor */ private ActiveMQRACredential() { - if (logger.isTraceEnabled()) { - logger.trace("constructor()"); - } + logger.trace("constructor()"); } /** @@ -67,9 +65,7 @@ public class ActiveMQRACredential implements Serializable { * @return The value */ public String getUserName() { - if (logger.isTraceEnabled()) { - logger.trace("getUserName()"); - } + logger.trace("getUserName()"); return userName; } @@ -80,9 +76,7 @@ public class ActiveMQRACredential implements Serializable { * @param userName The value */ private void setUserName(final String userName) { - if (logger.isTraceEnabled()) { - logger.trace("setUserName(" + userName + ")"); - } + logger.trace("setUserName({})", userName); this.userName = userName; } @@ -93,9 +87,7 @@ public class ActiveMQRACredential implements Serializable { * @return The value */ public String getPassword() { - if (logger.isTraceEnabled()) { - logger.trace("getPassword()"); - } + logger.trace("getPassword()"); return password; } @@ -106,9 +98,7 @@ public class ActiveMQRACredential implements Serializable { * @param password The value */ private void setPassword(final String password) { - if (logger.isTraceEnabled()) { - logger.trace("setPassword(****)"); - } + logger.trace("setPassword(****)"); this.password = password; } @@ -126,7 +116,7 @@ public class ActiveMQRACredential implements Serializable { final Subject subject, final ConnectionRequestInfo info) throws SecurityException { if (logger.isTraceEnabled()) { - logger.trace("getCredential(" + mcf + ", " + subject + ", " + info + ")"); + logger.trace("getCredential({}, {} ,{})", mcf, subject, info); } ActiveMQRACredential jc = new ActiveMQRACredential(); @@ -156,9 +146,7 @@ public class ActiveMQRACredential implements Serializable { */ @Override public String toString() { - if (logger.isTraceEnabled()) { - logger.trace("toString()"); - } + logger.trace("toString()"); return super.toString() + "{ username=" + userName + ", password=**** }"; } @@ -185,9 +173,7 @@ public class ActiveMQRACredential implements Serializable { * @param mcf The managed connection factory */ GetCredentialAction(final Subject subject, final ManagedConnectionFactory mcf) { - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + subject + ", " + mcf + ")"); - } + logger.trace("constructor({}, {})", subject, mcf); this.subject = subject; this.mcf = mcf; @@ -200,9 +186,7 @@ public class ActiveMQRACredential implements Serializable { */ @Override public PasswordCredential run() { - if (logger.isTraceEnabled()) { - logger.trace("run()"); - } + logger.trace("run()"); Set creds = subject.getPrivateCredentials(PasswordCredential.class); PasswordCredential pwdc = null; @@ -224,9 +208,7 @@ public class ActiveMQRACredential implements Serializable { * @return The credential */ static PasswordCredential getCredential(final Subject subject, final ManagedConnectionFactory mcf) { - if (logger.isTraceEnabled()) { - logger.trace("getCredential(" + subject + ", " + mcf + ")"); - } + logger.trace("getCredential({}, {})", subject, mcf); GetCredentialAction action = new GetCredentialAction(subject, mcf); return AccessController.doPrivileged(action); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALocalTransaction.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALocalTransaction.java index fb861a83ee..f8ec48c72e 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALocalTransaction.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRALocalTransaction.java @@ -42,9 +42,7 @@ public class ActiveMQRALocalTransaction implements LocalTransaction { * @param mc The managed connection */ public ActiveMQRALocalTransaction(final ActiveMQRAManagedConnection mc) { - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + mc + ")"); - } + logger.trace("constructor({})", mc); this.mc = mc; } @@ -56,9 +54,7 @@ public class ActiveMQRALocalTransaction implements LocalTransaction { */ @Override public void begin() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("begin()"); - } + logger.trace("begin()"); // mc.setInManagedTx(true); } @@ -70,9 +66,7 @@ public class ActiveMQRALocalTransaction implements LocalTransaction { */ @Override public void commit() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("commit()"); - } + logger.trace("commit()"); mc.lock(); try { @@ -94,9 +88,7 @@ public class ActiveMQRALocalTransaction implements LocalTransaction { */ @Override public void rollback() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("rollback()"); - } + logger.trace("rollback()"); mc.lock(); try { diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMCFProperties.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMCFProperties.java index b40ab6a5e5..b3d60eb7a6 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMCFProperties.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMCFProperties.java @@ -74,9 +74,7 @@ public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties impleme * Constructor */ public ActiveMQRAMCFProperties() { - if (logger.isTraceEnabled()) { - logger.trace("constructor()"); - } + logger.trace("constructor()"); useTryLock = null; } @@ -87,9 +85,7 @@ public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties impleme * @return The type */ public int getType() { - if (logger.isTraceEnabled()) { - logger.trace("getType()"); - } + logger.trace("getType()"); return type; } @@ -99,9 +95,7 @@ public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties impleme } public void setConnectorClassName(final String connectorClassName) { - if (logger.isTraceEnabled()) { - logger.trace("setConnectorClassName(" + connectorClassName + ")"); - } + logger.trace("setConnectorClassName({})", connectorClassName); strConnectorClassName = connectorClassName; @@ -126,9 +120,7 @@ public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties impleme * @param defaultType either javax.jms.Topic or javax.jms.Queue */ public void setSessionDefaultType(final String defaultType) { - if (logger.isTraceEnabled()) { - logger.trace("setSessionDefaultType(" + type + ")"); - } + logger.trace("setSessionDefaultType({})", type); if (defaultType.equals(ActiveMQRAMCFProperties.QUEUE_TYPE)) { type = ActiveMQRAConnectionFactory.QUEUE_CONNECTION; @@ -145,9 +137,7 @@ public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties impleme * @return The default session type */ public String getSessionDefaultType() { - if (logger.isTraceEnabled()) { - logger.trace("getSessionDefaultType()"); - } + logger.trace("getSessionDefaultType()"); if (type == ActiveMQRAConnectionFactory.CONNECTION) { return "BOTH"; @@ -164,9 +154,7 @@ public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties impleme * @return the useTryLock. */ public Integer getUseTryLock() { - if (logger.isTraceEnabled()) { - logger.trace("getUseTryLock()"); - } + logger.trace("getUseTryLock()"); return useTryLock; } @@ -177,9 +165,7 @@ public class ActiveMQRAMCFProperties extends ConnectionFactoryProperties impleme * @param useTryLock the useTryLock. */ public void setUseTryLock(final Integer useTryLock) { - if (logger.isTraceEnabled()) { - logger.trace("setUseTryLock(" + useTryLock + ")"); - } + logger.trace("setUseTryLock({})", useTryLock); this.useTryLock = useTryLock; } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java index 76d0438f91..3dc6b5aea3 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java @@ -142,7 +142,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc final String userName, final String password) throws ResourceException { if (logger.isTraceEnabled()) { - logger.trace("constructor(" + mcf + ", " + cri + ", " + userName + ", ****)"); + logger.trace("constructor({}, {}, {}, ****))", mcf, cri, userName); } this.mcf = mcf; @@ -188,9 +188,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc @Override public synchronized Object getConnection(final Subject subject, final ConnectionRequestInfo cxRequestInfo) throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("getConnection(" + subject + ", " + cxRequestInfo + ")"); - } + logger.trace("getConnection({}, {})", subject, cxRequestInfo); // Check user first ActiveMQRACredential credential = ActiveMQRACredential.getCredential(mcf, subject, cxRequestInfo); @@ -219,9 +217,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * @throws ResourceException Failed to close one or more handles. */ private void destroyHandles() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("destroyHandles()"); - } + logger.trace("destroyHandles()"); for (ActiveMQRASession session : handles) { session.destroy(); @@ -237,9 +233,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc */ @Override public void destroy() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("destroy()"); - } + logger.trace("destroy()"); if (isDestroyed.get() || connection == null) { return; @@ -250,7 +244,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc try { connection.setExceptionListener(null); } catch (JMSException e) { - logger.debug("Error unsetting the exception listener " + this, e); + logger.debug("Error unsetting the exception listener {}", this, e); } connection.signalStopToAllSessions(); @@ -288,7 +282,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc xaSession.close(); } } catch (JMSException e) { - logger.debug("Error closing session " + this, e); + logger.debug("Error closing session {}", this, e); } } catch (Throwable e) { @@ -303,9 +297,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc */ @Override public void cleanup() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("cleanup()"); - } + logger.trace("cleanup()"); if (isDestroyed.get()) { throw new IllegalStateException("ManagedConnection already destroyed"); @@ -333,9 +325,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc */ @Override public void associateConnection(final Object obj) throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("associateConnection(" + obj + ")"); - } + logger.trace("associateConnection({})", obj); if (!isDestroyed.get() && obj instanceof ActiveMQRASession) { ActiveMQRASession h = (ActiveMQRASession) obj; @@ -370,9 +360,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * Aqquire a lock on the managed connection */ protected void lock() { - if (logger.isTraceEnabled()) { - logger.trace("lock()"); - } + logger.trace("lock()"); lock.lock(); } @@ -383,9 +371,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * @throws JMSException Thrown if an error occurs */ protected void tryLock() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("tryLock()"); - } + logger.trace("tryLock()"); Integer tryLock = mcf.getUseTryLock(); if (tryLock == null || tryLock.intValue() <= 0) { @@ -405,9 +391,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * Unlock the managed connection */ protected void unlock() { - if (logger.isTraceEnabled()) { - logger.trace("unlock()"); - } + logger.trace("unlock()"); lock.unlock(); } @@ -419,9 +403,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc */ @Override public void addConnectionEventListener(final ConnectionEventListener l) { - if (logger.isTraceEnabled()) { - logger.trace("addConnectionEventListener(" + l + ")"); - } + logger.trace("addConnectionEventListener({})", l); eventListeners.add(l); } @@ -433,9 +415,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc */ @Override public void removeConnectionEventListener(final ConnectionEventListener l) { - if (logger.isTraceEnabled()) { - logger.trace("removeConnectionEventListener(" + l + ")"); - } + logger.trace("removeConnectionEventListener({})", l); eventListeners.remove(l); } @@ -448,9 +428,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc */ @Override public XAResource getXAResource() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("getXAResource()"); - } + logger.trace("getXAResource()"); // // Spec says a mc must always return the same XA resource, @@ -467,9 +445,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc xaResource = ServiceUtils.wrapXAResource(activeMQRAXAResource, xaResourceProperties); } - if (logger.isTraceEnabled()) { - logger.trace("XAResource=" + xaResource); - } + logger.trace("XAResource={}", xaResource); return xaResource; } @@ -482,15 +458,11 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc */ @Override public LocalTransaction getLocalTransaction() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("getLocalTransaction()"); - } + logger.trace("getLocalTransaction()"); LocalTransaction tx = new ActiveMQRALocalTransaction(this); - if (logger.isTraceEnabled()) { - logger.trace("LocalTransaction=" + tx); - } + logger.trace("LocalTransaction={}", tx); return tx; } @@ -504,9 +476,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc */ @Override public ManagedConnectionMetaData getMetaData() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("getMetaData()"); - } + logger.trace("getMetaData()"); if (isDestroyed.get()) { throw new IllegalStateException("The managed connection is already destroyed"); @@ -523,9 +493,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc */ @Override public void setLogWriter(final PrintWriter out) throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("setLogWriter(" + out + ")"); - } + logger.trace("setLogWriter({})", out); } /** @@ -536,9 +504,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc */ @Override public PrintWriter getLogWriter() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("getLogWriter()"); - } + logger.trace("getLogWriter()"); return null; } @@ -554,12 +520,12 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc return; } if (logger.isTraceEnabled()) { - logger.trace("onException(" + exception + ")"); + logger.trace("onException()", exception); } if (isDestroyed.get()) { if (logger.isTraceEnabled()) { - logger.trace("Ignoring error on already destroyed connection " + this, exception); + logger.trace("Ignoring error on already destroyed connection {}", this, exception); } return; } @@ -584,15 +550,11 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc */ protected Session getSession() throws JMSException { if (xaResource != null && inManagedTx) { - if (logger.isTraceEnabled()) { - logger.trace("getSession() -> XA session " + xaSession.getSession()); - } + logger.trace("getSession() -> XA session {}", xaSession.getSession()); return xaSession.getSession(); } else { - if (logger.isTraceEnabled()) { - logger.trace("getSession() -> non XA session " + nonXAsession); - } + logger.trace("getSession() -> non XA session {}", nonXAsession); return nonXAsession; } @@ -604,9 +566,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * @param event The event to send. */ protected void sendEvent(final ConnectionEvent event) { - if (logger.isTraceEnabled()) { - logger.trace("sendEvent(" + event + ")"); - } + logger.trace("sendEvent({})", event); int type = event.getId(); @@ -647,9 +607,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * @param handle The handle to remove. */ protected void removeHandle(final ActiveMQRASession handle) { - if (logger.isTraceEnabled()) { - logger.trace("removeHandle(" + handle + ")"); - } + logger.trace("removeHandle({})", handle); handles.remove(handle); } @@ -660,9 +618,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * @return The connection request info for this connection. */ protected ActiveMQRAConnectionRequestInfo getCRI() { - if (logger.isTraceEnabled()) { - logger.trace("getCRI()"); - } + logger.trace("getCRI()"); return cri; } @@ -673,9 +629,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * @return The connection factory for this connection. */ protected ActiveMQRAManagedConnectionFactory getManagedConnectionFactory() { - if (logger.isTraceEnabled()) { - logger.trace("getManagedConnectionFactory()"); - } + logger.trace("getManagedConnectionFactory()"); return mcf; } @@ -686,9 +640,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * @throws JMSException Thrown if the connection can't be started */ void start() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("start()"); - } + logger.trace("start()"); if (connection != null) { connection.start(); @@ -701,9 +653,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * @throws JMSException Thrown if the connection can't be stopped */ void stop() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("stop()"); - } + logger.trace("stop()"); if (connection != null) { connection.stop(); @@ -716,9 +666,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * @return The user name */ protected String getUserName() { - if (logger.isTraceEnabled()) { - logger.trace("getUserName()"); - } + logger.trace("getUserName()"); return userName; } @@ -729,9 +677,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc * @throws ResourceException Thrown if a connection couldn't be created */ private void setup() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("setup()"); - } + logger.trace("setup()"); try { diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java index ad17d117c7..c88e69ffb0 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnectionFactory.java @@ -82,9 +82,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti * Constructor */ public ActiveMQRAManagedConnectionFactory() { - if (logger.isTraceEnabled()) { - logger.trace("constructor()"); - } + logger.trace("constructor()"); ra = null; cm = null; @@ -99,9 +97,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti */ @Override public Object createConnectionFactory() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.debug("createConnectionFactory()"); - } + logger.debug("createConnectionFactory()"); return createConnectionFactory(new ActiveMQRAConnectionManager()); } @@ -115,19 +111,14 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti */ @Override public Object createConnectionFactory(final ConnectionManager cxManager) throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("createConnectionFactory(" + cxManager + ")"); - } + logger.trace("createConnectionFactory({})", cxManager); cm = cxManager; ActiveMQRAConnectionFactory cf = new ActiveMQRAConnectionFactoryImpl(this, cm); - if (logger.isTraceEnabled()) { - logger.trace("Created connection factory: " + cf + - ", using connection manager: " + - cm); - } + logger.trace("Created connection factory: {}, using connection manager: {}", cf, cm); + return cf; } @@ -142,23 +133,17 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti @Override public ManagedConnection createManagedConnection(final Subject subject, final ConnectionRequestInfo cxRequestInfo) throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("createManagedConnection(" + subject + ", " + cxRequestInfo + ")"); - } + logger.trace("createManagedConnection({}, {})", subject, cxRequestInfo); ActiveMQRAConnectionRequestInfo cri = getCRI((ActiveMQRAConnectionRequestInfo) cxRequestInfo); ActiveMQRACredential credential = ActiveMQRACredential.getCredential(this, subject, cri); - if (logger.isTraceEnabled()) { - logger.trace("jms credential: " + credential); - } + logger.trace("jms credential: {}", credential); ActiveMQRAManagedConnection mc = new ActiveMQRAManagedConnection(this, cri, ra, credential.getUserName(), credential.getPassword()); - if (logger.isTraceEnabled()) { - logger.trace("created new managed connection: " + mc); - } + logger.trace("created new managed connection: {}", mc); registerRecovery(); @@ -193,20 +178,13 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti final Subject subject, final ConnectionRequestInfo cxRequestInfo) throws ResourceException { if (logger.isTraceEnabled()) { - logger.trace("matchManagedConnections(" + connectionSet + - ", " + - subject + - ", " + - cxRequestInfo + - ")"); + logger.trace("matchManagedConnections({}, {}, {})", connectionSet, subject, cxRequestInfo); } ActiveMQRAConnectionRequestInfo cri = getCRI((ActiveMQRAConnectionRequestInfo) cxRequestInfo); ActiveMQRACredential credential = ActiveMQRACredential.getCredential(this, subject, cri); - if (logger.isTraceEnabled()) { - logger.trace("Looking for connection matching credentials: " + credential); - } + logger.trace("Looking for connection matching credentials: {}", credential); for (Object obj : connectionSet) { if (obj instanceof ActiveMQRAManagedConnection) { @@ -215,9 +193,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti if ((mc.getUserName() == null || mc.getUserName() != null && mc.getUserName().equals(credential.getUserName())) && mcf.equals(this)) { if (cri.equals(mc.getCRI())) { - if (logger.isTraceEnabled()) { - logger.trace("Found matching connection: " + mc); - } + logger.trace("Found matching connection: {}", mc); return mc; } @@ -225,9 +201,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti } } - if (logger.isTraceEnabled()) { - logger.trace("No matching connection was found"); - } + logger.trace("No matching connection was found"); return null; } @@ -240,9 +214,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti */ @Override public void setLogWriter(final PrintWriter out) throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("setLogWriter(" + out + ")"); - } + logger.trace("setLogWriter({})", out); } /** @@ -253,9 +225,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti */ @Override public PrintWriter getLogWriter() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("getLogWriter()"); - } + logger.trace("getLogWriter()"); return null; } @@ -267,9 +237,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti */ @Override public ResourceAdapter getResourceAdapter() { - if (logger.isTraceEnabled()) { - logger.trace("getResourceAdapter()"); - } + logger.trace("getResourceAdapter()"); return ra; } @@ -288,9 +256,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti */ @Override public void setResourceAdapter(final ResourceAdapter ra) throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("setResourceAdapter(" + ra + ")"); - } + logger.trace("setResourceAdapter({})", ra); if (ra == null || !(ra instanceof ActiveMQResourceAdapter)) { throw new ResourceException("Resource adapter is " + ra); @@ -308,9 +274,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti */ @Override public boolean equals(final Object obj) { - if (logger.isTraceEnabled()) { - logger.trace("equals(" + obj + ")"); - } + logger.trace("equals({})", obj); if (obj == null) { return false; @@ -332,9 +296,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti */ @Override public int hashCode() { - if (logger.isTraceEnabled()) { - logger.trace("hashCode()"); - } + logger.trace("hashCode()"); int hash = mcfProperties.hashCode(); hash += 31 * (ra != null ? ra.hashCode() : 0); @@ -348,9 +310,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti * @return The value */ public String getSessionDefaultType() { - if (logger.isTraceEnabled()) { - logger.trace("getSessionDefaultType()"); - } + logger.trace("getSessionDefaultType()"); return mcfProperties.getSessionDefaultType(); } @@ -361,9 +321,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti * @param type either javax.jms.Topic or javax.jms.Queue */ public void setSessionDefaultType(final String type) { - if (logger.isTraceEnabled()) { - logger.trace("setSessionDefaultType(" + type + ")"); - } + logger.trace("setSessionDefaultType({})", type); mcfProperties.setSessionDefaultType(type); } @@ -746,9 +704,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti * @return the useTryLock. */ public Integer getUseTryLock() { - if (logger.isTraceEnabled()) { - logger.trace("getUseTryLock()"); - } + logger.trace("getUseTryLock()"); return mcfProperties.getUseTryLock(); } @@ -759,9 +715,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti * @param useTryLock the useTryLock. */ public void setUseTryLock(final Integer useTryLock) { - if (logger.isTraceEnabled()) { - logger.trace("setUseTryLock(" + useTryLock + ")"); - } + logger.trace("setUseTryLock({})", useTryLock); mcfProperties.setUseTryLock(useTryLock); } @@ -772,9 +726,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti * @return The metadata */ public ConnectionMetaData getMetaData() { - if (logger.isTraceEnabled()) { - logger.trace("getMetadata()"); - } + logger.trace("getMetadata()"); return new ActiveMQRAConnectionMetaData(); } @@ -785,9 +737,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti * @return The properties */ protected ActiveMQRAMCFProperties getProperties() { - if (logger.isTraceEnabled()) { - logger.trace("getProperties()"); - } + logger.trace("getProperties()"); return mcfProperties; } @@ -799,9 +749,7 @@ public final class ActiveMQRAManagedConnectionFactory implements ManagedConnecti * @return The instance */ private ActiveMQRAConnectionRequestInfo getCRI(final ActiveMQRAConnectionRequestInfo info) { - if (logger.isTraceEnabled()) { - logger.trace("getCRI(" + info + ")"); - } + logger.trace("getCRI({})", info); if (info == null) { // Create a default one diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMapMessage.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMapMessage.java index f7389a9dc5..7e8e0297df 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMapMessage.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMapMessage.java @@ -41,9 +41,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag public ActiveMQRAMapMessage(final MapMessage message, final ActiveMQRASession session) { super(message, session); - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + message + ", " + session + ")"); - } + logger.trace("constructor({}, {})", message, session); } /** @@ -55,9 +53,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public boolean getBoolean(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getBoolean(" + name + ")"); - } + logger.trace("getBoolean({})", name); return ((MapMessage) message).getBoolean(name); } @@ -71,9 +67,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public byte getByte(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getByte(" + name + ")"); - } + logger.trace("getByte({})", name); return ((MapMessage) message).getByte(name); } @@ -87,9 +81,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public byte[] getBytes(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getBytes(" + name + ")"); - } + logger.trace("getBytes({})", name); return ((MapMessage) message).getBytes(name); } @@ -103,9 +95,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public char getChar(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getChar(" + name + ")"); - } + logger.trace("getChar({})", name); return ((MapMessage) message).getChar(name); } @@ -119,9 +109,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public double getDouble(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getDouble(" + name + ")"); - } + logger.trace("getDouble({})", name); return ((MapMessage) message).getDouble(name); } @@ -135,9 +123,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public float getFloat(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getFloat(" + name + ")"); - } + logger.trace("getFloat({})", name); return ((MapMessage) message).getFloat(name); } @@ -151,9 +137,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public int getInt(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getInt(" + name + ")"); - } + logger.trace("getInt({})", name); return ((MapMessage) message).getInt(name); } @@ -167,9 +151,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public long getLong(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getLong(" + name + ")"); - } + logger.trace("getLong({})", name); return ((MapMessage) message).getLong(name); } @@ -182,9 +164,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public Enumeration getMapNames() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getMapNames()"); - } + logger.trace("getMapNames()"); return ((MapMessage) message).getMapNames(); } @@ -198,9 +178,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public Object getObject(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getObject(" + name + ")"); - } + logger.trace("getObject({})", name); return ((MapMessage) message).getObject(name); } @@ -214,9 +192,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public short getShort(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getShort(" + name + ")"); - } + logger.trace("getShort({})", name); return ((MapMessage) message).getShort(name); } @@ -230,9 +206,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public String getString(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getString(" + name + ")"); - } + logger.trace("getString({})", name); return ((MapMessage) message).getString(name); } @@ -246,9 +220,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public boolean itemExists(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("itemExists(" + name + ")"); - } + logger.trace("itemExists({})", name); return ((MapMessage) message).itemExists(name); } @@ -263,7 +235,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag @Override public void setBoolean(final String name, final boolean value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setBoolean(" + name + ", " + value + ")"); + logger.trace("setBoolean({}, {})", name, value); } ((MapMessage) message).setBoolean(name, value); @@ -279,7 +251,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag @Override public void setByte(final String name, final byte value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setByte(" + name + ", " + value + ")"); + logger.trace("setByte({}, {})", name, value); } ((MapMessage) message).setByte(name, value); @@ -297,8 +269,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag @Override public void setBytes(final String name, final byte[] value, final int offset, final int length) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setBytes(" + name + ", " + Arrays.toString(value) + ", " + offset + ", " + - length + ")"); + logger.trace("setBytes({}, {}, {}, {})", name, Arrays.toString(value), offset, length); } ((MapMessage) message).setBytes(name, value, offset, length); @@ -314,7 +285,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag @Override public void setBytes(final String name, final byte[] value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setBytes(" + name + ", " + Arrays.toString(value) + ")"); + logger.trace("setBytes({}, {})", name, Arrays.toString(value)); } ((MapMessage) message).setBytes(name, value); @@ -330,7 +301,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag @Override public void setChar(final String name, final char value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setChar(" + name + ", " + value + ")"); + logger.trace("setChar({}, {})", name, value); } ((MapMessage) message).setChar(name, value); @@ -346,7 +317,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag @Override public void setDouble(final String name, final double value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setDouble(" + name + ", " + value + ")"); + logger.trace("setDouble({}, {})", name, value); } ((MapMessage) message).setDouble(name, value); @@ -362,7 +333,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag @Override public void setFloat(final String name, final float value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setFloat(" + name + ", " + value + ")"); + logger.trace("setFloat({}, {})", name, value); } ((MapMessage) message).setFloat(name, value); @@ -378,7 +349,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag @Override public void setInt(final String name, final int value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setInt(" + name + ", " + value + ")"); + logger.trace("setInt({}, {})", name, value); } ((MapMessage) message).setInt(name, value); @@ -394,7 +365,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag @Override public void setLong(final String name, final long value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setLong(" + name + ", " + value + ")"); + logger.trace("setLong({}, {})", name, value); } ((MapMessage) message).setLong(name, value); @@ -410,7 +381,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag @Override public void setObject(final String name, final Object value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setObject(" + name + ", " + value + ")"); + logger.trace("setObject({}, {})", name, value); } ((MapMessage) message).setObject(name, value); @@ -426,7 +397,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag @Override public void setShort(final String name, final short value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setShort(" + name + ", " + value + ")"); + logger.trace("setShort({}, {})", name, value); } ((MapMessage) message).setShort(name, value); @@ -441,9 +412,7 @@ public class ActiveMQRAMapMessage extends ActiveMQRAMessage implements MapMessag */ @Override public void setString(final String name, final String value) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setString(" + name + ", " + value + ")"); - } + logger.trace("setString({}, {})", name, value); ((MapMessage) message).setString(name, value); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessage.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessage.java index 36cb8204d0..5ab313a7c0 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessage.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessage.java @@ -55,9 +55,7 @@ public class ActiveMQRAMessage implements Message { checkNotNull(message); checkNotNull(session); - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + message + ", " + session + ")"); - } + logger.trace("constructor({}, {})", message, session); this.message = message; this.session = session; @@ -70,9 +68,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public void acknowledge() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("acknowledge()"); - } + logger.trace("acknowledge()"); session.getSession(); // Check for closed message.acknowledge(); @@ -85,9 +81,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public void clearBody() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("clearBody()"); - } + logger.trace("clearBody()"); message.clearBody(); } @@ -99,9 +93,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public void clearProperties() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("clearProperties()"); - } + logger.trace("clearProperties()"); message.clearProperties(); } @@ -115,9 +107,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public boolean getBooleanProperty(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getBooleanProperty(" + name + ")"); - } + logger.trace("getBooleanProperty({})", name); return message.getBooleanProperty(name); } @@ -131,9 +121,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public byte getByteProperty(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getByteProperty(" + name + ")"); - } + logger.trace("getByteProperty({})", name); return message.getByteProperty(name); } @@ -147,9 +135,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public double getDoubleProperty(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getDoubleProperty(" + name + ")"); - } + logger.trace("getDoubleProperty({})", name); return message.getDoubleProperty(name); } @@ -163,9 +149,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public float getFloatProperty(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getFloatProperty(" + name + ")"); - } + logger.trace("getFloatProperty({})", name); return message.getFloatProperty(name); } @@ -179,9 +163,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public int getIntProperty(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getIntProperty(" + name + ")"); - } + logger.trace("getIntProperty({})", name); return message.getIntProperty(name); } @@ -194,9 +176,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public String getJMSCorrelationID() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSCorrelationID()"); - } + logger.trace("getJMSCorrelationID()"); return message.getJMSCorrelationID(); } @@ -209,9 +189,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public byte[] getJMSCorrelationIDAsBytes() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSCorrelationIDAsBytes()"); - } + logger.trace("getJMSCorrelationIDAsBytes()"); return message.getJMSCorrelationIDAsBytes(); } @@ -224,9 +202,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public int getJMSDeliveryMode() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSDeliveryMode()"); - } + logger.trace("getJMSDeliveryMode()"); return message.getJMSDeliveryMode(); } @@ -239,9 +215,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public Destination getJMSDestination() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSDestination()"); - } + logger.trace("getJMSDestination()"); return message.getJMSDestination(); } @@ -254,9 +228,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public long getJMSExpiration() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSExpiration()"); - } + logger.trace("getJMSExpiration()"); return message.getJMSExpiration(); } @@ -269,9 +241,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public String getJMSMessageID() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSMessageID()"); - } + logger.trace("getJMSMessageID()"); return message.getJMSMessageID(); } @@ -284,9 +254,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public int getJMSPriority() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSPriority()"); - } + logger.trace("getJMSPriority()"); return message.getJMSPriority(); } @@ -299,9 +267,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public boolean getJMSRedelivered() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSRedelivered()"); - } + logger.trace("getJMSRedelivered()"); return message.getJMSRedelivered(); } @@ -314,9 +280,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public Destination getJMSReplyTo() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSReplyTo()"); - } + logger.trace("getJMSReplyTo()"); return message.getJMSReplyTo(); } @@ -329,9 +293,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public long getJMSTimestamp() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSTimestamp()"); - } + logger.trace("getJMSTimestamp()"); return message.getJMSTimestamp(); } @@ -344,9 +306,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public String getJMSType() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSType()"); - } + logger.trace("getJMSType()"); return message.getJMSType(); } @@ -360,9 +320,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public long getLongProperty(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getLongProperty(" + name + ")"); - } + logger.trace("getLongProperty({})", name); return message.getLongProperty(name); } @@ -376,9 +334,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public Object getObjectProperty(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getObjectProperty(" + name + ")"); - } + logger.trace("getObjectProperty({})", name); return message.getObjectProperty(name); } @@ -391,9 +347,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public Enumeration getPropertyNames() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getPropertyNames()"); - } + logger.trace("getPropertyNames()"); return message.getPropertyNames(); } @@ -407,9 +361,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public short getShortProperty(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getShortProperty(" + name + ")"); - } + logger.trace("getShortProperty({})", name); return message.getShortProperty(name); } @@ -423,9 +375,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public String getStringProperty(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getStringProperty(" + name + ")"); - } + logger.trace("getStringProperty({})", name); return message.getStringProperty(name); } @@ -439,9 +389,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public boolean propertyExists(final String name) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("propertyExists(" + name + ")"); - } + logger.trace("propertyExists({})", name); return message.propertyExists(name); } @@ -456,7 +404,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setBooleanProperty(final String name, final boolean value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setBooleanProperty(" + name + ", " + value + ")"); + logger.trace("setBooleanProperty({}, {})", name, value); } message.setBooleanProperty(name, value); @@ -472,7 +420,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setByteProperty(final String name, final byte value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setByteProperty(" + name + ", " + value + ")"); + logger.trace("setByteProperty({}, {})", name, value); } message.setByteProperty(name, value); @@ -488,7 +436,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setDoubleProperty(final String name, final double value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setDoubleProperty(" + name + ", " + value + ")"); + logger.trace("setDoubleProperty({}, {})", name, value); } message.setDoubleProperty(name, value); @@ -504,7 +452,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setFloatProperty(final String name, final float value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setFloatProperty(" + name + ", " + value + ")"); + logger.trace("setFloatProperty({}, {})", name, value); } message.setFloatProperty(name, value); @@ -520,7 +468,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setIntProperty(final String name, final int value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setIntProperty(" + name + ", " + value + ")"); + logger.trace("setIntProperty({}, {})", name, value); } message.setIntProperty(name, value); @@ -535,7 +483,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setJMSCorrelationID(final String correlationID) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setJMSCorrelationID(" + correlationID + ")"); + logger.trace("setJMSCorrelationID({})", correlationID); } message.setJMSCorrelationID(correlationID); @@ -550,7 +498,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setJMSCorrelationIDAsBytes(final byte[] correlationID) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setJMSCorrelationIDAsBytes(" + Arrays.toString(correlationID) + ")"); + logger.trace("setJMSCorrelationIDAsBytes({})", Arrays.toString(correlationID)); } message.setJMSCorrelationIDAsBytes(correlationID); @@ -565,7 +513,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setJMSDeliveryMode(final int deliveryMode) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setJMSDeliveryMode(" + deliveryMode + ")"); + logger.trace("setJMSDeliveryMode({})", deliveryMode); } message.setJMSDeliveryMode(deliveryMode); @@ -579,9 +527,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public void setJMSDestination(final Destination destination) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setJMSDestination(" + destination + ")"); - } + logger.trace("setJMSDestination({})", destination); message.setJMSDestination(destination); } @@ -595,7 +541,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setJMSExpiration(final long expiration) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setJMSExpiration(" + expiration + ")"); + logger.trace("setJMSExpiration({})", expiration); } message.setJMSExpiration(expiration); @@ -609,9 +555,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public void setJMSMessageID(final String id) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setJMSMessageID(" + id + ")"); - } + logger.trace("setJMSMessageID({})", id); message.setJMSMessageID(id); } @@ -625,7 +569,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setJMSPriority(final int priority) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setJMSPriority(" + priority + ")"); + logger.trace("setJMSPriority({})", priority); } message.setJMSPriority(priority); @@ -640,7 +584,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setJMSRedelivered(final boolean redelivered) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setJMSRedelivered(" + redelivered + ")"); + logger.trace("setJMSRedelivered({})", redelivered); } message.setJMSRedelivered(redelivered); @@ -654,9 +598,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public void setJMSReplyTo(final Destination replyTo) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setJMSReplyTo(" + replyTo + ")"); - } + logger.trace("setJMSReplyTo({})", replyTo); message.setJMSReplyTo(replyTo); } @@ -670,7 +612,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setJMSTimestamp(final long timestamp) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setJMSTimestamp(" + timestamp + ")"); + logger.trace("setJMSTimestamp({})", timestamp); } message.setJMSTimestamp(timestamp); @@ -684,9 +626,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public void setJMSType(final String type) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setJMSType(" + type + ")"); - } + logger.trace("setJMSType({})", type); message.setJMSType(type); } @@ -701,7 +641,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setLongProperty(final String name, final long value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setLongProperty(" + name + ", " + value + ")"); + logger.trace("setLongProperty({}, {})", name, value); } message.setLongProperty(name, value); @@ -716,9 +656,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public void setObjectProperty(final String name, final Object value) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setObjectProperty(" + name + ", " + value + ")"); - } + logger.trace("setObjectProperty({}, {})", name, value); message.setObjectProperty(name, value); } @@ -733,7 +671,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setShortProperty(final String name, final short value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setShortProperty(" + name + ", " + value + ")"); + logger.trace("setShortProperty({}, {})", name, value); } message.setShortProperty(name, value); @@ -749,7 +687,7 @@ public class ActiveMQRAMessage implements Message { @Override public void setStringProperty(final String name, final String value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setStringProperty(" + name + ", " + value + ")"); + logger.trace("setStringProperty({}, {})", name, value); } message.setStringProperty(name, value); @@ -757,34 +695,31 @@ public class ActiveMQRAMessage implements Message { @Override public long getJMSDeliveryTime() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getJMSDeliveryTime()"); - } + logger.trace("getJMSDeliveryTime()"); + return message.getJMSDeliveryTime(); } @Override public void setJMSDeliveryTime(long deliveryTime) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setJMSDeliveryTime(" + deliveryTime + ")"); + logger.trace("setJMSDeliveryTime({})", deliveryTime); } + message.setJMSDeliveryTime(deliveryTime); } @Override public T getBody(Class c) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getBody(" + c + ")"); - } + logger.trace("getBody({})", c); + return message.getBody(c); } @Override public boolean isBodyAssignableTo(Class c) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("isBodyAssignableTo(" + c + ")"); - } + logger.trace("isBodyAssignableTo({})", c); + return message.isBodyAssignableTo(c); } @@ -795,9 +730,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public int hashCode() { - if (logger.isTraceEnabled()) { - logger.trace("hashCode()"); - } + logger.trace("hashCode()"); return message.hashCode(); } @@ -810,9 +743,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public boolean equals(final Object object) { - if (logger.isTraceEnabled()) { - logger.trace("equals(" + object + ")"); - } + logger.trace("equals({})", object); if (object != null && object instanceof ActiveMQRAMessage) { return message.equals(((ActiveMQRAMessage) object).message); @@ -828,9 +759,7 @@ public class ActiveMQRAMessage implements Message { */ @Override public String toString() { - if (logger.isTraceEnabled()) { - logger.trace("toString()"); - } + logger.trace("toString()"); return message.toString(); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageConsumer.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageConsumer.java index 00da38bdd2..2d8341b459 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageConsumer.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageConsumer.java @@ -58,11 +58,7 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { this.session = session; if (logger.isTraceEnabled()) { - logger.trace("new ActiveMQMessageConsumer " + this + - " consumer=" + - consumer + - " session=" + - session); + logger.trace("new ActiveMQMessageConsumer {} consumer={} session={}", this, consumer, session); } } @@ -73,9 +69,8 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { */ @Override public void close() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("close " + this); - } + logger.trace("close {}", this); + try { closeConsumer(); } finally { @@ -89,9 +84,8 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { * @throws JMSException Thrown if an error occurs */ void checkState() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("checkState()"); - } + logger.trace("checkState()"); + session.checkState(); } @@ -103,9 +97,7 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { */ @Override public MessageListener getMessageListener() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getMessageListener()"); - } + logger.trace("getMessageListener()"); checkState(); session.checkStrict(); @@ -142,9 +134,7 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { */ @Override public String getMessageSelector() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getMessageSelector()"); - } + logger.trace("getMessageSelector()"); checkState(); return consumer.getMessageSelector(); @@ -160,16 +150,12 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { public Message receive() throws JMSException { session.lock(); try { - if (logger.isTraceEnabled()) { - logger.trace("receive " + this); - } + logger.trace("receive {}", this); checkState(); Message message = consumer.receive(); - if (logger.isTraceEnabled()) { - logger.trace("received " + this + " result=" + message); - } + logger.trace("received {} result={}", this, message); if (message == null) { return null; @@ -193,15 +179,13 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { session.lock(); try { if (logger.isTraceEnabled()) { - logger.trace("receive " + this + " timeout=" + timeout); + logger.trace("receive {} timeout={}", this, timeout); } checkState(); Message message = consumer.receive(timeout); - if (logger.isTraceEnabled()) { - logger.trace("received " + this + " result=" + message); - } + logger.trace("received {} result={}", this, message); if (message == null) { return null; @@ -223,16 +207,12 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { public Message receiveNoWait() throws JMSException { session.lock(); try { - if (logger.isTraceEnabled()) { - logger.trace("receiveNoWait " + this); - } + logger.trace("receiveNoWait {}", this); checkState(); Message message = consumer.receiveNoWait(); - if (logger.isTraceEnabled()) { - logger.trace("received " + this + " result=" + message); - } + logger.trace("received {} result={}", this, message); if (message == null) { return null; @@ -250,9 +230,7 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { * @throws JMSException Thrown if an error occurs */ void closeConsumer() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("closeConsumer()"); - } + logger.trace("closeConsumer()"); consumer.close(); } @@ -264,9 +242,7 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { * @return The wrapped message */ Message wrapMessage(final Message message) { - if (logger.isTraceEnabled()) { - logger.trace("wrapMessage(" + message + ")"); - } + logger.trace("wrapMessage({})", message); if (message instanceof BytesMessage) { return new ActiveMQRABytesMessage((BytesMessage) message, session); @@ -289,9 +265,7 @@ public class ActiveMQRAMessageConsumer implements MessageConsumer { * @return The wrapped listener */ MessageListener wrapMessageListener(final MessageListener listener) { - if (logger.isTraceEnabled()) { - logger.trace("getMessageSelector()"); - } + logger.trace("getMessageSelector()"); return new ActiveMQRAMessageListener(listener, this); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageListener.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageListener.java index d269f1d49b..e8d1608a1d 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageListener.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageListener.java @@ -48,9 +48,7 @@ public class ActiveMQRAMessageListener implements MessageListener { * @param consumer the consumer */ public ActiveMQRAMessageListener(final MessageListener listener, final ActiveMQRAMessageConsumer consumer) { - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + listener + ", " + consumer + ")"); - } + logger.trace("constructor({}, {})", listener, consumer); this.listener = listener; this.consumer = consumer; @@ -63,9 +61,7 @@ public class ActiveMQRAMessageListener implements MessageListener { */ @Override public void onMessage(Message message) { - if (logger.isTraceEnabled()) { - logger.trace("onMessage(" + message + ")"); - } + logger.trace("onMessage({})", message); message = consumer.wrapMessage(message); listener.onMessage(message); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageProducer.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageProducer.java index 24502fd29e..903b14d4fe 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageProducer.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMessageProducer.java @@ -54,11 +54,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { this.session = session; if (logger.isTraceEnabled()) { - logger.trace("new ActiveMQMessageProducer " + this + - " producer=" + - producer + - " session=" + - session); + logger.trace("new ActiveMQMessageProducer {} producer={} session={}", this, producer, session); } } @@ -69,9 +65,8 @@ public class ActiveMQRAMessageProducer implements MessageProducer { */ @Override public void close() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("close " + this); - } + logger.trace("close {}", this); + try { closeProducer(); } finally { @@ -98,26 +93,15 @@ public class ActiveMQRAMessageProducer implements MessageProducer { session.lock(); try { if (logger.isTraceEnabled()) { - logger.trace("send " + this + - " destination=" + - destination + - " message=" + - message + - " deliveryMode=" + - deliveryMode + - " priority=" + - priority + - " ttl=" + - timeToLive); + logger.trace("send {} destination={} message={} deliveryMode={} priority={} ttl={}", + this, destination, message, deliveryMode, priority, timeToLive); } checkState(); producer.send(destination, message, deliveryMode, priority, timeToLive); - if (logger.isTraceEnabled()) { - logger.trace("sent " + this + " result=" + message); - } + logger.trace("sent {} result={}", this, message); } finally { session.unlock(); } @@ -135,16 +119,14 @@ public class ActiveMQRAMessageProducer implements MessageProducer { session.lock(); try { if (logger.isTraceEnabled()) { - logger.trace("send " + this + " destination=" + destination + " message=" + message); + logger.trace("send {} destination={} message={}", this, destination, message); } checkState(); producer.send(destination, message); - if (logger.isTraceEnabled()) { - logger.trace("sent " + this + " result=" + message); - } + logger.trace("sent {} result={}", this, message); } finally { session.unlock(); } @@ -167,24 +149,15 @@ public class ActiveMQRAMessageProducer implements MessageProducer { session.lock(); try { if (logger.isTraceEnabled()) { - logger.trace("send " + this + - " message=" + - message + - " deliveryMode=" + - deliveryMode + - " priority=" + - priority + - " ttl=" + - timeToLive); + logger.trace("send {} message={} deliveryMode={} priority={} ttl={}", + this, message, deliveryMode, priority, timeToLive); } checkState(); producer.send(message, deliveryMode, priority, timeToLive); - if (logger.isTraceEnabled()) { - logger.trace("sent " + this + " result=" + message); - } + logger.trace("sent {} result={}", this, message); } finally { session.unlock(); } @@ -200,17 +173,13 @@ public class ActiveMQRAMessageProducer implements MessageProducer { public void send(final Message message) throws JMSException { session.lock(); try { - if (logger.isTraceEnabled()) { - logger.trace("send " + this + " message=" + message); - } + logger.trace("send {} result={}", this, message); checkState(); producer.send(message); - if (logger.isTraceEnabled()) { - logger.trace("sent " + this + " result=" + message); - } + logger.trace("sent {} result={}", this, message); } finally { session.unlock(); } @@ -224,9 +193,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { */ @Override public int getDeliveryMode() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getRoutingType()"); - } + logger.trace("getRoutingType()"); return producer.getDeliveryMode(); } @@ -239,9 +206,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { */ @Override public Destination getDestination() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getDestination()"); - } + logger.trace("getDestination()"); return producer.getDestination(); } @@ -254,9 +219,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { */ @Override public boolean getDisableMessageID() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getDisableMessageID()"); - } + logger.trace("getDisableMessageID()"); return producer.getDisableMessageID(); } @@ -269,9 +232,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { */ @Override public boolean getDisableMessageTimestamp() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getDisableMessageTimestamp()"); - } + logger.trace("getDisableMessageTimestamp()"); return producer.getDisableMessageTimestamp(); } @@ -284,9 +245,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { */ @Override public int getPriority() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getPriority()"); - } + logger.trace("getPriority()"); return producer.getPriority(); } @@ -299,9 +258,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { */ @Override public long getTimeToLive() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getTimeToLive()"); - } + logger.trace("getTimeToLive()"); return producer.getTimeToLive(); } @@ -315,7 +272,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { @Override public void setDeliveryMode(final int deliveryMode) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setRoutingType(" + deliveryMode + ")"); + logger.trace("setRoutingType({})", deliveryMode); } producer.setDeliveryMode(deliveryMode); @@ -330,7 +287,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { @Override public void setDisableMessageID(final boolean value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setDisableMessageID(" + value + ")"); + logger.trace("setDisableMessageID({})", value); } producer.setDisableMessageID(value); @@ -345,7 +302,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { @Override public void setDisableMessageTimestamp(final boolean value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setDisableMessageTimestamp(" + value + ")"); + logger.trace("setDisableMessageTimestamp({})", value); } producer.setDisableMessageTimestamp(value); @@ -360,7 +317,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { @Override public void setPriority(final int defaultPriority) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setPriority(" + defaultPriority + ")"); + logger.trace("setPriority({})", defaultPriority); } producer.setPriority(defaultPriority); @@ -375,7 +332,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { @Override public void setTimeToLive(final long timeToLive) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setTimeToLive(" + timeToLive + ")"); + logger.trace("setTimeToLive({})", timeToLive); } producer.setTimeToLive(timeToLive); @@ -384,24 +341,22 @@ public class ActiveMQRAMessageProducer implements MessageProducer { @Override public void setDeliveryDelay(long deliveryDelay) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("setDeliveryDelay(" + deliveryDelay + ")"); + logger.trace("setDeliveryDelay({})", deliveryDelay); } producer.setDeliveryDelay(deliveryDelay); } @Override public long getDeliveryDelay() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getDeliveryDelay()"); - } + logger.trace("getDeliveryDelay()"); + return producer.getDeliveryDelay(); } @Override public void send(Message message, CompletionListener completionListener) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("send(" + message + ", " + completionListener + ")"); - } + logger.trace("send({}, {})", message, completionListener); + producer.send(message, completionListener); } @@ -412,8 +367,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { long timeToLive, CompletionListener completionListener) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("send(" + message + ", " + deliveryMode + ", " + priority + ", " + timeToLive + - ", " + completionListener + ")"); + logger.trace("send({}, {}, {}, {}, {})", message, deliveryMode, priority, timeToLive, completionListener); } producer.send(message, deliveryMode, priority, timeToLive, completionListener); } @@ -423,7 +377,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { Message message, CompletionListener completionListener) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("send(" + destination + ", " + message + ", " + completionListener + ")"); + logger.trace("send({}, {}, {})", destination, message, completionListener); } producer.send(destination, message, completionListener); } @@ -436,8 +390,7 @@ public class ActiveMQRAMessageProducer implements MessageProducer { long timeToLive, CompletionListener completionListener) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("send(" + destination + ", " + message + ", " + deliveryMode + ", " + priority + - ", " + timeToLive + ", " + completionListener + ")"); + logger.trace("send({}, {}, {}, {}, {}, {})", destination, message, deliveryMode, priority, timeToLive, completionListener); } producer.send(destination, message, deliveryMode, priority, timeToLive, completionListener); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMetaData.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMetaData.java index 153d2689e1..5fcc904cb8 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMetaData.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAMetaData.java @@ -41,9 +41,7 @@ public class ActiveMQRAMetaData implements ManagedConnectionMetaData { * @param mc The managed connection */ public ActiveMQRAMetaData(final ActiveMQRAManagedConnection mc) { - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + mc + ")"); - } + logger.trace("constructor({})", mc); this.mc = mc; } @@ -56,9 +54,7 @@ public class ActiveMQRAMetaData implements ManagedConnectionMetaData { */ @Override public String getEISProductName() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("getEISProductName()"); - } + logger.trace("getEISProductName()"); return "ActiveMQ Artemis"; } @@ -71,9 +67,7 @@ public class ActiveMQRAMetaData implements ManagedConnectionMetaData { */ @Override public String getEISProductVersion() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("getEISProductVersion()"); - } + logger.trace("getEISProductVersion()"); return "2.0"; } @@ -86,9 +80,7 @@ public class ActiveMQRAMetaData implements ManagedConnectionMetaData { */ @Override public String getUserName() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("getUserName()"); - } + logger.trace("getUserName()"); return mc.getUserName(); } @@ -101,9 +93,7 @@ public class ActiveMQRAMetaData implements ManagedConnectionMetaData { */ @Override public int getMaxConnections() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("getMaxConnections()"); - } + logger.trace("getMaxConnections()"); return 0; } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAObjectMessage.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAObjectMessage.java index 05ce308eb1..3c4733a6c9 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAObjectMessage.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAObjectMessage.java @@ -40,9 +40,7 @@ public class ActiveMQRAObjectMessage extends ActiveMQRAMessage implements Object public ActiveMQRAObjectMessage(final ObjectMessage message, final ActiveMQRASession session) { super(message, session); - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + message + ", " + session + ")"); - } + logger.trace("constructor({}, {})", message, session); } /** @@ -53,9 +51,7 @@ public class ActiveMQRAObjectMessage extends ActiveMQRAMessage implements Object */ @Override public Serializable getObject() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getObject()"); - } + logger.trace("getObject()"); return ((ObjectMessage) message).getObject(); } @@ -68,9 +64,7 @@ public class ActiveMQRAObjectMessage extends ActiveMQRAMessage implements Object */ @Override public void setObject(final Serializable object) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setObject(" + object + ")"); - } + logger.trace("setObject({})", object); ((ObjectMessage) message).setObject(object); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java index 60f465fadd..3bee0ae81e 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAProperties.java @@ -89,9 +89,7 @@ public class ActiveMQRAProperties extends ConnectionFactoryProperties implements * Constructor */ public ActiveMQRAProperties() { - if (logger.isTraceEnabled()) { - logger.trace("constructor()"); - } + logger.trace("constructor()"); } /** @@ -100,9 +98,7 @@ public class ActiveMQRAProperties extends ConnectionFactoryProperties implements * @return The value */ public String getUserName() { - if (logger.isTraceEnabled()) { - logger.trace("getUserName()"); - } + logger.trace("getUserName()"); return userName; } @@ -113,9 +109,7 @@ public class ActiveMQRAProperties extends ConnectionFactoryProperties implements * @param userName The value */ public void setUserName(final String userName) { - if (logger.isTraceEnabled()) { - logger.trace("setUserName(" + userName + ")"); - } + logger.trace("setUserName({})", userName); this.userName = userName; } @@ -126,9 +120,7 @@ public class ActiveMQRAProperties extends ConnectionFactoryProperties implements * @return The value */ public String getPassword() { - if (logger.isTraceEnabled()) { - logger.trace("getPassword()"); - } + logger.trace("getPassword()"); return password; } @@ -144,9 +136,7 @@ public class ActiveMQRAProperties extends ConnectionFactoryProperties implements * @param password The value */ public void setPassword(final String password) { - if (logger.isTraceEnabled()) { - logger.trace("setPassword(****)"); - } + logger.trace("setPassword(****)"); this.password = password; } @@ -182,9 +172,7 @@ public class ActiveMQRAProperties extends ConnectionFactoryProperties implements * @return The value */ public Boolean getUseLocalTx() { - if (logger.isTraceEnabled()) { - logger.trace("getUseLocalTx()"); - } + logger.trace("getUseLocalTx()"); return localTx; } @@ -195,9 +183,7 @@ public class ActiveMQRAProperties extends ConnectionFactoryProperties implements * @param localTx The value */ public void setUseLocalTx(final Boolean localTx) { - if (logger.isTraceEnabled()) { - logger.trace("setUseLocalTx(" + localTx + ")"); - } + logger.trace("setUseLocalTx({})", localTx); this.localTx = localTx; } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueReceiver.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueReceiver.java index d0f694d932..fe8a0eb2dc 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueReceiver.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueReceiver.java @@ -40,9 +40,7 @@ public class ActiveMQRAQueueReceiver extends ActiveMQRAMessageConsumer implement public ActiveMQRAQueueReceiver(final QueueReceiver consumer, final ActiveMQRASession session) { super(consumer, session); - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + consumer + ", " + session + ")"); - } + logger.trace("constructor({}, {})", consumer, session); } /** @@ -53,9 +51,7 @@ public class ActiveMQRAQueueReceiver extends ActiveMQRAMessageConsumer implement */ @Override public Queue getQueue() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getQueue()"); - } + logger.trace("getQueue()"); checkState(); return ((QueueReceiver) consumer).getQueue(); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueSender.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueSender.java index 1d02def198..3783748c40 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueSender.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAQueueSender.java @@ -42,7 +42,7 @@ public class ActiveMQRAQueueSender extends ActiveMQRAMessageProducer implements super(producer, session); if (logger.isTraceEnabled()) { - logger.trace("constructor(" + producer + ", " + session + ")"); + logger.trace("constructor({}, {})", producer, session); } } @@ -54,9 +54,7 @@ public class ActiveMQRAQueueSender extends ActiveMQRAMessageProducer implements */ @Override public Queue getQueue() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getQueue()"); - } + logger.trace("getQueue()"); return ((QueueSender) producer).getQueue(); } @@ -80,25 +78,14 @@ public class ActiveMQRAQueueSender extends ActiveMQRAMessageProducer implements session.lock(); try { if (logger.isTraceEnabled()) { - logger.trace("send " + this + - " destination=" + - destination + - " message=" + - message + - " deliveryMode=" + - deliveryMode + - " priority=" + - priority + - " ttl=" + - timeToLive); + logger.trace("send {} destination={} message={} deliveryMode={} priority={} ttl={}", + this, destination, message, deliveryMode, priority, timeToLive); } checkState(); producer.send(destination, message, deliveryMode, priority, timeToLive); - if (logger.isTraceEnabled()) { - logger.trace("sent " + this + " result=" + message); - } + logger.trace("sent {} result={}", this, message); } finally { session.unlock(); } @@ -116,15 +103,13 @@ public class ActiveMQRAQueueSender extends ActiveMQRAMessageProducer implements session.lock(); try { if (logger.isTraceEnabled()) { - logger.trace("send " + this + " destination=" + destination + " message=" + message); + logger.trace("send {} destination={} message={}", this, destination, message); } checkState(); producer.send(destination, message); - if (logger.isTraceEnabled()) { - logger.trace("sent " + this + " result=" + message); - } + logger.trace("sent {} result={}", this, message); } finally { session.unlock(); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASession.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASession.java index 9364a4d4eb..6c444f17ea 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASession.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASession.java @@ -98,9 +98,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * @param cri The connection request info */ public ActiveMQRASession(final ActiveMQRAManagedConnection mc, final ActiveMQRAConnectionRequestInfo cri) { - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + mc + ", " + cri + ")"); - } + logger.trace("constructor({}, {})", mc, cri); this.mc = mc; this.cri = cri; @@ -115,9 +113,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * @param sf The session factory */ public void setActiveMQSessionFactory(final ActiveMQRASessionFactory sf) { - if (logger.isTraceEnabled()) { - logger.trace("setActiveMQSessionFactory(" + sf + ")"); - } + logger.trace("setActiveMQSessionFactory({})", sf); this.sf = sf; } @@ -129,9 +125,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * @throws IllegalStateException The session is closed */ protected void lock() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("lock()"); - } + logger.trace("lock()"); final ActiveMQRAManagedConnection mcLocal = this.mc; if (mcLocal != null) { @@ -145,9 +139,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * Unlock */ protected void unlock() { - if (logger.isTraceEnabled()) { - logger.trace("unlock()"); - } + logger.trace("unlock()"); final ActiveMQRAManagedConnection mcLocal = this.mc; if (mcLocal != null) { @@ -168,9 +160,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes public BytesMessage createBytesMessage() throws JMSException { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createBytesMessage" + session); - } + logger.trace("createBytesMessage(), {}", session); return session.createBytesMessage(); } @@ -185,9 +175,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes public MapMessage createMapMessage() throws JMSException { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createMapMessage(), " + session); - } + logger.trace("createMapMessage(), {}", session); return session.createMapMessage(); } @@ -202,9 +190,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes public Message createMessage() throws JMSException { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createMessage" + session); - } + logger.trace("createMessage(), {}", session); return session.createMessage(); } @@ -219,9 +205,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes public ObjectMessage createObjectMessage() throws JMSException { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createObjectMessage" + session); - } + logger.trace("createObjectMessage(), {}", session); return session.createObjectMessage(); } @@ -237,9 +221,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes public ObjectMessage createObjectMessage(final Serializable object) throws JMSException { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createObjectMessage(" + object + ")" + session); - } + logger.trace("createObjectMessage({})", object, session); return session.createObjectMessage(object); } @@ -254,9 +236,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes public StreamMessage createStreamMessage() throws JMSException { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createStreamMessage" + session); - } + logger.trace("createStreamMessage(), {}", session); return session.createStreamMessage(); } @@ -271,9 +251,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes public TextMessage createTextMessage() throws JMSException { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createTextMessage" + session); - } + logger.trace("createTextMessage(), {}", session); return session.createTextMessage(); } @@ -289,9 +267,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes public TextMessage createTextMessage(final String string) throws JMSException { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createTextMessage(" + string + ")" + session); - } + logger.trace("createTextMessage({}) {}", string, session); return session.createTextMessage(string); } @@ -304,9 +280,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes */ @Override public boolean getTransacted() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getTransacted()"); - } + logger.trace("getTransacted()"); getSessionInternal(); return cri.isTransacted(); @@ -320,9 +294,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes */ @Override public MessageListener getMessageListener() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getMessageListener()"); - } + logger.trace("getMessageListener()"); throw new IllegalStateException("Method not allowed"); } @@ -335,9 +307,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes */ @Override public void setMessageListener(final MessageListener listener) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setMessageListener(" + listener + ")"); - } + logger.trace("setMessageListener({})", listener); throw new IllegalStateException("Method not allowed"); } @@ -349,9 +319,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes */ @Override public void run() { - if (logger.isTraceEnabled()) { - logger.trace("run()"); - } + logger.trace("run()"); throw new Error("Method not allowed"); } @@ -364,9 +332,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes */ @Override public void close() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("close()"); - } + logger.trace("close()"); sf.closeSession(this); closeSession(); @@ -392,9 +358,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes throw new IllegalStateException("Session is not transacted"); } - if (logger.isTraceEnabled()) { - logger.trace("Commit session " + this); - } + logger.trace("Commit session {}", this); session.commit(); } finally { @@ -422,9 +386,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes throw new IllegalStateException("Session is not transacted"); } - if (logger.isTraceEnabled()) { - logger.trace("Rollback session " + this); - } + logger.trace("Rollback session {}", this); session.rollback(); } finally { @@ -447,9 +409,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes throw new IllegalStateException("Session is transacted"); } - if (logger.isTraceEnabled()) { - logger.trace("Recover session " + this); - } + logger.trace("Recover session {}", this); session.recover(); } finally { @@ -473,13 +433,13 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createTopic " + session + " topicName=" + topicName); + logger.trace("createTopic {} topicName={}", session, topicName); } Topic result = session.createTopic(topicName); if (logger.isTraceEnabled()) { - logger.trace("createdTopic " + session + " topic=" + result); + logger.trace("createdTopic {} topic={}", session, result); } return result; @@ -498,16 +458,12 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes try { TopicSession session = getTopicSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createSubscriber " + session + " topic=" + topic); - } + logger.trace("createSubscriber {} topic={}", session, topic); TopicSubscriber result = session.createSubscriber(topic); result = new ActiveMQRATopicSubscriber(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdSubscriber " + session + " ActiveMQTopicSubscriber=" + result); - } + logger.trace("createdSubscriber {} ActiveMQTopicSubscriber={}", session, result); addConsumer(result); @@ -535,21 +491,13 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes TopicSession session = getTopicSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createSubscriber " + session + - " topic=" + - topic + - " selector=" + - messageSelector + - " noLocal=" + - noLocal); + logger.trace("createSubscriber {} topic={} selector={} noLocal={}", session, topic, messageSelector, noLocal); } TopicSubscriber result = session.createSubscriber(topic, messageSelector, noLocal); result = new ActiveMQRATopicSubscriber(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdSubscriber " + session + " ActiveMQTopicSubscriber=" + result); - } + logger.trace("createdSubscriber {} ActiveMQTopicSubscriber={}", session, result); addConsumer(result); @@ -578,15 +526,13 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createDurableSubscriber " + session + " topic=" + topic + " name=" + name); + logger.trace("createDurableSubscriber {} topic={} name={}", session, topic, name); } TopicSubscriber result = session.createDurableSubscriber(topic, name); result = new ActiveMQRATopicSubscriber(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdDurableSubscriber " + session + " ActiveMQTopicSubscriber=" + result); - } + logger.trace("createdDurableSubscriber {} ActiveMQTopicSubscriber={}", session, result); addConsumer(result); @@ -616,23 +562,14 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createDurableSubscriber " + session + - " topic=" + - topic + - " name=" + - name + - " selector=" + - messageSelector + - " noLocal=" + - noLocal); + logger.trace("createDurableSubscriber {} topic={} name={} selector={} noLocal={}", + session, topic, name, messageSelector, noLocal); } TopicSubscriber result = session.createDurableSubscriber(topic, name, messageSelector, noLocal); result = new ActiveMQRATopicSubscriber(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdDurableSubscriber " + session + " ActiveMQTopicSubscriber=" + result); - } + logger.trace("createdDurableSubscriber {} ActiveMQTopicSubscriber={}", session, result); addConsumer(result); @@ -655,16 +592,12 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes try { TopicSession session = getTopicSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createPublisher " + session + " topic=" + topic); - } + logger.trace("createPublisher {} topic={}", session, topic); TopicPublisher result = session.createPublisher(topic); result = new ActiveMQRATopicPublisher(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdPublisher " + session + " publisher=" + result); - } + logger.trace("createdPublisher {} publisher=", session, result); addProducer(result); @@ -690,15 +623,11 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes try { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createTemporaryTopic " + session); - } + logger.trace("createTemporaryTopic {}", session); TemporaryTopic temp = session.createTemporaryTopic(); - if (logger.isTraceEnabled()) { - logger.trace("createdTemporaryTopic " + session + " temp=" + temp); - } + logger.trace("createdTemporaryTopic {} temp={}", session, temp); sf.addTemporaryTopic(temp); @@ -724,9 +653,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes try { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("unsubscribe " + session + " name=" + name); - } + logger.trace("unsubscribe {} name={}", session, name); session.unsubscribe(name); } finally { @@ -749,15 +676,11 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createBrowser " + session + " queue=" + queue); - } + logger.trace("createBrowser {} queue={}", session, queue); QueueBrowser result = session.createBrowser(queue); - if (logger.isTraceEnabled()) { - logger.trace("createdBrowser " + session + " browser=" + result); - } + logger.trace("createdBrowser {} browser={}", session, result); return result; } @@ -779,14 +702,12 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createBrowser " + session + " queue=" + queue + " selector=" + messageSelector); + logger.trace("createBrowser {} queue={} selector={}", session, queue, messageSelector); } QueueBrowser result = session.createBrowser(queue, messageSelector); - if (logger.isTraceEnabled()) { - logger.trace("createdBrowser " + session + " browser=" + result); - } + logger.trace("createdBrowser {} browser={}", session, result); return result; } @@ -806,15 +727,11 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createQueue " + session + " queueName=" + queueName); - } + logger.trace("createQueue {} queueName={}", session, queueName); Queue result = session.createQueue(queueName); - if (logger.isTraceEnabled()) { - logger.trace("createdQueue " + session + " queue=" + result); - } + logger.trace("createdQueue {} queue={}", session, result); return result; } @@ -832,16 +749,12 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes try { QueueSession session = getQueueSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createReceiver " + session + " queue=" + queue); - } + logger.trace("createReceiver {} queue={}", session, queue); QueueReceiver result = session.createReceiver(queue); result = new ActiveMQRAQueueReceiver(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdReceiver " + session + " receiver=" + result); - } + logger.trace("createdReceiver {} receiver={}", session, result); addConsumer(result); @@ -866,15 +779,13 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes QueueSession session = getQueueSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createReceiver " + session + " queue=" + queue + " selector=" + messageSelector); + logger.trace("createReceiver {} queue={} selector={}", session, queue, messageSelector); } QueueReceiver result = session.createReceiver(queue, messageSelector); result = new ActiveMQRAQueueReceiver(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdReceiver " + session + " receiver=" + result); - } + logger.trace("createdReceiver {} receiver={}", session, result); addConsumer(result); @@ -897,16 +808,12 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes try { QueueSession session = getQueueSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createSender " + session + " queue=" + queue); - } + logger.trace("createSender {} queue={}", session, queue); QueueSender result = session.createSender(queue); result = new ActiveMQRAQueueSender(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdSender " + session + " sender=" + result); - } + logger.trace("createdSender {} sender={}", session, result); addProducer(result); @@ -932,15 +839,11 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes try { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createTemporaryQueue " + session); - } + logger.trace("createTemporaryQueue {}", session); TemporaryQueue temp = session.createTemporaryQueue(); - if (logger.isTraceEnabled()) { - logger.trace("createdTemporaryQueue " + session + " temp=" + temp); - } + logger.trace("createdTemporaryQueue {} temp={}", session, temp); sf.addTemporaryQueue(temp); @@ -963,16 +866,12 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes try { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createConsumer " + session + " dest=" + destination); - } + logger.trace("createConsumer {} dest={}", session, destination); MessageConsumer result = session.createConsumer(destination); result = new ActiveMQRAMessageConsumer(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdConsumer " + session + " consumer=" + result); - } + logger.trace("createdConsumer {} consumer={}", session, result); addConsumer(result); @@ -998,19 +897,13 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createConsumer " + session + - " dest=" + - destination + - " messageSelector=" + - messageSelector); + logger.trace("createConsumer {} dest={} messageSelector={}", session, destination, messageSelector); } MessageConsumer result = session.createConsumer(destination, messageSelector); result = new ActiveMQRAMessageConsumer(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdConsumer " + session + " consumer=" + result); - } + logger.trace("createdConsumer {} consumer={}", session, result); addConsumer(result); @@ -1038,21 +931,14 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createConsumer " + session + - " dest=" + - destination + - " messageSelector=" + - messageSelector + - " noLocal=" + - noLocal); + logger.trace("createConsumer {} dest={} messageSelector={} noLocal={}", + session, destination, messageSelector, noLocal); } MessageConsumer result = session.createConsumer(destination, messageSelector, noLocal); result = new ActiveMQRAMessageConsumer(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdConsumer " + session + " consumer=" + result); - } + logger.trace("createdConsumer {} consumer={}", session, result); addConsumer(result); @@ -1075,16 +961,12 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes try { Session session = getSessionInternal(); - if (logger.isTraceEnabled()) { - logger.trace("createProducer " + session + " dest=" + destination); - } + logger.trace("createProducer {} dest={}", session, destination); MessageProducer result = session.createProducer(destination); result = new ActiveMQRAMessageProducer(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdProducer " + session + " producer=" + result); - } + logger.trace("createdProducer {} producer={}", session, result); addProducer(result); @@ -1102,9 +984,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes */ @Override public int getAcknowledgeMode() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getAcknowledgeMode()"); - } + logger.trace("getAcknowledgeMode()"); getSessionInternal(); return cri.getAcknowledgeMode(); @@ -1115,9 +995,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes */ @Override public XAResource getXAResource() { - if (logger.isTraceEnabled()) { - logger.trace("getXAResource()"); - } + logger.trace("getXAResource()"); if (cri.getType() == ActiveMQRAConnectionFactory.CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION) { @@ -1154,9 +1032,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes */ @Override public Session getSession() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getNonXAsession()"); - } + logger.trace("getNonXAsession()"); if (cri.getType() == ActiveMQRAConnectionFactory.CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION) { @@ -1179,9 +1055,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes */ @Override public QueueSession getQueueSession() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getQueueSession()"); - } + logger.trace("getQueueSession()"); if (cri.getType() == ActiveMQRAConnectionFactory.CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION) { @@ -1204,9 +1078,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes */ @Override public TopicSession getTopicSession() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getTopicSession()"); - } + logger.trace("getTopicSession()"); if (cri.getType() == ActiveMQRAConnectionFactory.CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION) { @@ -1229,15 +1101,13 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createSharedConsumer " + session + " topic=" + topic + ", sharedSubscriptionName=" + sharedSubscriptionName); + logger.trace("createSharedConsumer {} topic={}, sharedSubscriptionName={}", session, topic, sharedSubscriptionName); } MessageConsumer result = session.createSharedConsumer(topic, sharedSubscriptionName); result = new ActiveMQRAMessageConsumer(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdConsumer " + session + " consumer=" + result); - } + logger.trace("createdConsumer {} consumer={}", session, result); addConsumer(result); @@ -1256,16 +1126,14 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createSharedConsumer " + session + " topic=" + topic + - ", sharedSubscriptionName=" + sharedSubscriptionName + ", messageSelector=" + messageSelector); + logger.trace("createSharedConsumer {} topic={}, sharedSubscriptionName={}, messageSelector={}", + session, topic, sharedSubscriptionName, messageSelector); } MessageConsumer result = session.createSharedConsumer(topic, sharedSubscriptionName, messageSelector); result = new ActiveMQRAMessageConsumer(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdConsumer " + session + " consumer=" + result); - } + logger.trace("createdConsumer {} consumer={}", session, result); addConsumer(result); @@ -1282,15 +1150,13 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createSharedConsumer " + session + " topic=" + topic + ", name=" + name); + logger.trace("createSharedConsumer {} topic={}, name={}", session, topic, name); } MessageConsumer result = session.createDurableConsumer(topic, name); result = new ActiveMQRAMessageConsumer(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdConsumer " + session + " consumer=" + result); - } + logger.trace("createdConsumer {} consumer={}", session, result); addConsumer(result); @@ -1310,16 +1176,14 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createDurableConsumer " + session + " topic=" + topic + ", name=" + name + - ", messageSelector=" + messageSelector + ", noLocal=" + noLocal); + logger.trace("createDurableConsumer {} topic={}, name={}, messageSelector={}, noLocal={}", + session, topic, name, messageSelector, noLocal); } MessageConsumer result = session.createDurableConsumer(topic, name, messageSelector, noLocal); result = new ActiveMQRAMessageConsumer(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdConsumer " + session + " consumer=" + result); - } + logger.trace("createdConsumer {} consumer={}", session, result); addConsumer(result); @@ -1336,16 +1200,13 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createSharedDurableConsumer " + session + " topic=" + topic + ", name=" + - name); + logger.trace("createSharedDurableConsumer {} topic={}, name={}", session, topic, name); } MessageConsumer result = session.createSharedDurableConsumer(topic, name); result = new ActiveMQRAMessageConsumer(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdConsumer " + session + " consumer=" + result); - } + logger.trace("createdConsumer {} consumer={}", session, result); addConsumer(result); @@ -1364,16 +1225,14 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = getSessionInternal(); if (logger.isTraceEnabled()) { - logger.trace("createSharedDurableConsumer " + session + " topic=" + topic + ", name=" + - name + ", messageSelector=" + messageSelector); + logger.trace("createSharedDurableConsumer {} topic={}, name={}, messageSelector={}", + session, topic, name, messageSelector); } MessageConsumer result = session.createSharedDurableConsumer(topic, name, messageSelector); result = new ActiveMQRAMessageConsumer(result, this); - if (logger.isTraceEnabled()) { - logger.trace("createdConsumer " + session + " consumer=" + result); - } + logger.trace("createdConsumer {} consumer={}", session, result); addConsumer(result); @@ -1389,9 +1248,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * @param managedConnection The managed connection */ void setManagedConnection(final ActiveMQRAManagedConnection managedConnection) { - if (logger.isTraceEnabled()) { - logger.trace("setManagedConnection(" + managedConnection + ")"); - } + logger.trace("setManagedConnection({})", managedConnection); if (mc != null) { mc.removeHandle(this); @@ -1411,9 +1268,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * Destroy */ void destroy() { - if (logger.isTraceEnabled()) { - logger.trace("destroy()"); - } + logger.trace("destroy()"); mc = null; } @@ -1424,9 +1279,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * @throws JMSException Thrown if an error occurs */ void start() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("start()"); - } + logger.trace("start()"); if (mc != null) { mc.start(); @@ -1439,9 +1292,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * @throws JMSException Thrown if an error occurs */ void stop() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("stop()"); - } + logger.trace("stop()"); if (mc != null) { mc.stop(); @@ -1454,9 +1305,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * @throws JMSException Thrown if an error occurs */ void checkStrict() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("checkStrict()"); - } + logger.trace("checkStrict()"); if (mc != null) { throw new IllegalStateException(ActiveMQRASessionFactory.ISE); @@ -1516,9 +1365,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * @param consumer The consumer */ void addConsumer(final MessageConsumer consumer) { - if (logger.isTraceEnabled()) { - logger.trace("addConsumer(" + consumer + ")"); - } + logger.trace("addConsumer({})", consumer); synchronized (consumers) { consumers.add(consumer); @@ -1531,9 +1378,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * @param consumer The consumer */ void removeConsumer(final MessageConsumer consumer) { - if (logger.isTraceEnabled()) { - logger.trace("removeConsumer(" + consumer + ")"); - } + logger.trace("removeConsumer({})", consumer); synchronized (consumers) { consumers.remove(consumer); @@ -1546,9 +1391,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * @param producer The producer */ void addProducer(final MessageProducer producer) { - if (logger.isTraceEnabled()) { - logger.trace("addProducer(" + producer + ")"); - } + logger.trace("addProducer({})", producer); synchronized (producers) { producers.add(producer); @@ -1561,9 +1404,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes * @param producer The producer */ void removeProducer(final MessageProducer producer) { - if (logger.isTraceEnabled()) { - logger.trace("removeProducer(" + producer + ")"); - } + logger.trace("removeProducer({})", producer); synchronized (producers) { producers.remove(producer); @@ -1584,9 +1425,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes Session session = mc.getSession(); - if (logger.isTraceEnabled()) { - logger.trace("getSessionInternal " + session + " for " + this); - } + logger.trace("getSessionInternal {} for {}", session, this); return session; } @@ -1607,7 +1446,7 @@ public class ActiveMQRASession implements QueueSession, TopicSession, XAQueueSes XAResource xares = mc.getXAResource(); if (logger.isTraceEnabled()) { - logger.trace("getXAResourceInternal " + xares + " for " + this); + logger.trace("getXAResourceInternal {} for {}", xares, this); } return xares; diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASessionFactoryImpl.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASessionFactoryImpl.java index c214772786..d3581f58b7 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASessionFactoryImpl.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRASessionFactoryImpl.java @@ -147,7 +147,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon this.type = type; if (logger.isTraceEnabled()) { - logger.trace("constructor(" + mcf + ", " + cm + ", " + type); + logger.trace("constructor({}, {}, {})", mcf, cm, type); } } @@ -197,9 +197,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public void setReference(final Reference reference) { - if (logger.isTraceEnabled()) { - logger.trace("setReference(" + reference + ")"); - } + logger.trace("setReference({})", reference); this.reference = reference; } @@ -211,9 +209,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public Reference getReference() { - if (logger.isTraceEnabled()) { - logger.trace("getReference()"); - } + logger.trace("getReference()"); return reference; } @@ -224,9 +220,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon * @param name The user name */ public void setUserName(final String name) { - if (logger.isTraceEnabled()) { - logger.trace("setUserName(" + name + ")"); - } + logger.trace("setUserName({})", name); userName = name; } @@ -237,9 +231,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon * @param password The password */ public void setPassword(final String password) { - if (logger.isTraceEnabled()) { - logger.trace("setPassword(****)"); - } + logger.trace("setPassword(****)"); this.password = password; } @@ -252,9 +244,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public String getClientID() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getClientID()"); - } + logger.trace("getClientID()"); checkClosed(); @@ -273,9 +263,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public void setClientID(final String cID) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setClientID(" + cID + ")"); - } + logger.trace("setClientID({})", cID); throw new IllegalStateException(ISE); } @@ -291,7 +279,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon @Override public QueueSession createQueueSession(final boolean transacted, final int acknowledgeMode) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("createQueueSession(" + transacted + ", " + acknowledgeMode + ")"); + logger.trace("createQueueSession({}, {})", transacted, acknowledgeMode); } checkClosed(); @@ -311,9 +299,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public XAQueueSession createXAQueueSession() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createXAQueueSession()"); - } + logger.trace("createXAQueueSession()"); checkClosed(); @@ -341,14 +327,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon final ServerSessionPool sessionPool, final int maxMessages) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("createConnectionConsumer(" + queue + - ", " + - messageSelector + - ", " + - sessionPool + - ", " + - maxMessages + - ")"); + logger.trace("createConnectionConsumer({}, {}, {}, {})", queue, messageSelector, sessionPool, maxMessages); } throw new IllegalStateException(ISE); @@ -365,7 +344,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon @Override public TopicSession createTopicSession(final boolean transacted, final int acknowledgeMode) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("createTopicSession(" + transacted + ", " + acknowledgeMode + ")"); + logger.trace("createTopicSession({}, {})", transacted, acknowledgeMode); } checkClosed(); @@ -385,9 +364,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public XATopicSession createXATopicSession() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createXATopicSession()"); - } + logger.trace("createXATopicSession()"); checkClosed(); @@ -415,14 +392,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon final ServerSessionPool sessionPool, final int maxMessages) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("createConnectionConsumer(" + topic + - ", " + - messageSelector + - ", " + - sessionPool + - ", " + - maxMessages + - ")"); + logger.trace("createConnectionConsumer({}, {}, {}, {})", topic, messageSelector, sessionPool, maxMessages); } throw new IllegalStateException(ISE); @@ -446,16 +416,8 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon final ServerSessionPool sessionPool, final int maxMessages) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("createConnectionConsumer(" + topic + - ", " + - subscriptionName + - ", " + - messageSelector + - ", " + - sessionPool + - ", " + - maxMessages + - ")"); + logger.trace("createConnectionConsumer({}, {}, {}, {}, {})", + topic, subscriptionName, messageSelector, sessionPool, maxMessages); } throw new IllegalStateException(ISE); @@ -474,12 +436,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon final ServerSessionPool pool, final int maxMessages) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("createConnectionConsumer(" + destination + - ", " + - pool + - ", " + - maxMessages + - ")"); + logger.trace("createConnectionConsumer({}, {}, {})", destination, pool, maxMessages); } throw new IllegalStateException(ISE); @@ -501,14 +458,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon final ServerSessionPool pool, final int maxMessages) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("createConnectionConsumer(" + destination + - ", " + - name + - ", " + - pool + - ", " + - maxMessages + - ")"); + logger.trace("createConnectionConsumer({}, {}, {}, {})", destination, name, pool, maxMessages); } throw new IllegalStateException(ISE); @@ -525,7 +475,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon @Override public Session createSession(final boolean transacted, final int acknowledgeMode) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("createSession(" + transacted + ", " + acknowledgeMode + ")"); + logger.trace("createSession({}, {})", transacted, acknowledgeMode); } checkClosed(); @@ -540,9 +490,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public XASession createXASession() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("createXASession()"); - } + logger.trace("createXASession()"); checkClosed(); return allocateConnection(type); @@ -556,9 +504,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public ConnectionMetaData getMetaData() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getMetaData()"); - } + logger.trace("getMetaData()"); checkClosed(); return mcf.getMetaData(); @@ -572,9 +518,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public ExceptionListener getExceptionListener() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getExceptionListener()"); - } + logger.trace("getExceptionListener()"); throw new IllegalStateException(ISE); } @@ -587,9 +531,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public void setExceptionListener(final ExceptionListener listener) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setExceptionListener(" + listener + ")"); - } + logger.trace("setExceptionListener({})", listener); throw new IllegalStateException(ISE); } @@ -603,9 +545,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon public void start() throws JMSException { checkClosed(); - if (logger.isTraceEnabled()) { - logger.trace("start() " + this); - } + logger.trace("start() {}", this); synchronized (sessions) { if (started) { @@ -626,9 +566,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public void stop() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("stop() " + this); - } + logger.trace("stop() {}", this); throw new IllegalStateException(ISE); } @@ -640,9 +578,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public void close() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("close() " + this); - } + logger.trace("close() {}", this); if (closed) { return; @@ -666,9 +602,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon for (Iterator i = tempQueues.iterator(); i.hasNext(); ) { TemporaryQueue temp = i.next(); try { - if (logger.isTraceEnabled()) { - logger.trace("Closing temporary queue " + temp + " for " + this); - } + logger.trace("Closing temporary queue {} for {}", temp, this); temp.delete(); } catch (Throwable t) { logger.trace("Error deleting temporary queue", t); @@ -681,9 +615,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon for (Iterator i = tempTopics.iterator(); i.hasNext(); ) { TemporaryTopic temp = i.next(); try { - if (logger.isTraceEnabled()) { - logger.trace("Closing temporary topic " + temp + " for " + this); - } + logger.trace("Closing temporary topic {} for {}", temp, this); temp.delete(); } catch (Throwable t) { logger.trace("Error deleting temporary queue", t); @@ -701,9 +633,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public void closeSession(final ActiveMQRASession session) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("closeSession(" + session + ")"); - } + logger.trace("closeSession({})", session); synchronized (sessions) { sessions.remove(session); @@ -717,9 +647,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public void addTemporaryQueue(final TemporaryQueue temp) { - if (logger.isTraceEnabled()) { - logger.trace("addTemporaryQueue(" + temp + ")"); - } + logger.trace("addTemporaryQueue({})", temp); synchronized (tempQueues) { tempQueues.add(temp); @@ -733,9 +661,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon */ @Override public void addTemporaryTopic(final TemporaryTopic temp) { - if (logger.isTraceEnabled()) { - logger.trace("addTemporaryTopic(" + temp + ")"); - } + logger.trace("addTemporaryTopic({})", temp); synchronized (tempTopics) { tempTopics.add(temp); @@ -759,8 +685,8 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon ServerSessionPool sessionPool, int maxMessages) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("createSharedConnectionConsumer(" + topic + ", " + subscriptionName + ", " + - messageSelector + ", " + sessionPool + ", " + maxMessages + ")"); + logger.trace("createSharedConnectionConsumer({}, {}, {}, {}, {})", + topic, subscriptionName, messageSelector, sessionPool, maxMessages); } throw new IllegalStateException(ISE); @@ -773,8 +699,8 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon ServerSessionPool sessionPool, int maxMessages) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("createSharedDurableConnectionConsumer(" + topic + ", " + subscriptionName + - ", " + messageSelector + ", " + sessionPool + ", " + maxMessages + ")"); + logger.trace("createSharedDurableConnectionConsumer({}, {}, {}, {}, {})", + topic, subscriptionName, messageSelector, sessionPool, maxMessages); } throw new IllegalStateException(ISE); @@ -804,12 +730,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon int acknowledgeMode, final int sessionType) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("allocateConnection(" + transacted + - ", " + - acknowledgeMode + - ", " + - sessionType + - ")"); + logger.trace("allocateConnection({}, {}, {})", transacted, acknowledgeMode, sessionType); } try { @@ -866,16 +787,12 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon info.setClientID(clientID); info.setDefaults(((ActiveMQResourceAdapter) mcf.getResourceAdapter()).getProperties()); - if (logger.isTraceEnabled()) { - logger.trace("Allocating session for " + this + " with request info=" + info); - } + logger.trace("Allocating session for {} with request info={}", this, info); ActiveMQRASession session = (ActiveMQRASession) cm.allocateConnection(mcf, info); try { - if (logger.isTraceEnabled()) { - logger.trace("Allocated " + this + " session=" + session); - } + logger.trace("Allocated {} session={}", this, session); session.setActiveMQSessionFactory(this); @@ -921,9 +838,7 @@ public final class ActiveMQRASessionFactoryImpl extends ActiveMQConnectionForCon * @throws IllegalStateException Thrown if closed */ protected void checkClosed() throws IllegalStateException { - if (logger.isTraceEnabled()) { - logger.trace("checkClosed()" + this); - } + logger.trace("checkClosed() {}", this); if (closed) { throw new IllegalStateException("The connection is closed"); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAStreamMessage.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAStreamMessage.java index 658eb4e49c..f7f04925c4 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAStreamMessage.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAStreamMessage.java @@ -40,9 +40,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream public ActiveMQRAStreamMessage(final StreamMessage message, final ActiveMQRASession session) { super(message, session); - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + message + ", " + session + ")"); - } + logger.trace("constructor({}, {})", message, session); } /** @@ -53,9 +51,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public boolean readBoolean() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readBoolean()"); - } + logger.trace("readBoolean()"); return ((StreamMessage) message).readBoolean(); } @@ -68,9 +64,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public byte readByte() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readByte()"); - } + logger.trace("readByte()"); return ((StreamMessage) message).readByte(); } @@ -85,7 +79,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream @Override public int readBytes(final byte[] value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("readBytes(" + Arrays.toString(value) + ")"); + logger.trace("readBytes({})", Arrays.toString(value)); } return ((StreamMessage) message).readBytes(value); @@ -99,9 +93,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public char readChar() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readChar()"); - } + logger.trace("readChar()"); return ((StreamMessage) message).readChar(); } @@ -114,9 +106,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public double readDouble() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readDouble()"); - } + logger.trace("readDouble()"); return ((StreamMessage) message).readDouble(); } @@ -129,9 +119,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public float readFloat() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readFloat()"); - } + logger.trace("readFloat()"); return ((StreamMessage) message).readFloat(); } @@ -144,9 +132,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public int readInt() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readInt()"); - } + logger.trace("readInt()"); return ((StreamMessage) message).readInt(); } @@ -159,9 +145,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public long readLong() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readLong()"); - } + logger.trace("readLong()"); return ((StreamMessage) message).readLong(); } @@ -174,9 +158,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public Object readObject() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readObject()"); - } + logger.trace("readObject()"); return ((StreamMessage) message).readObject(); } @@ -189,9 +171,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public short readShort() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readShort()"); - } + logger.trace("readShort()"); return ((StreamMessage) message).readShort(); } @@ -204,9 +184,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public String readString() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("readString()"); - } + logger.trace("readString()"); return ((StreamMessage) message).readString(); } @@ -218,9 +196,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public void reset() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("reset()"); - } + logger.trace("reset()"); ((StreamMessage) message).reset(); } @@ -234,7 +210,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream @Override public void writeBoolean(final boolean value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeBoolean(" + value + ")"); + logger.trace("writeBoolean({})", value); } ((StreamMessage) message).writeBoolean(value); @@ -249,7 +225,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream @Override public void writeByte(final byte value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeByte(" + value + ")"); + logger.trace("writeByte({})", value); } ((StreamMessage) message).writeByte(value); @@ -266,7 +242,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream @Override public void writeBytes(final byte[] value, final int offset, final int length) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeBytes(" + Arrays.toString(value) + ", " + offset + ", " + length + ")"); + logger.trace("writeBytes({}, {}, {})", Arrays.toString(value), offset, length); } ((StreamMessage) message).writeBytes(value, offset, length); @@ -281,7 +257,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream @Override public void writeBytes(final byte[] value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeBytes(" + Arrays.toString(value) + ")"); + logger.trace("writeBytes({})", Arrays.toString(value)); } ((StreamMessage) message).writeBytes(value); @@ -296,7 +272,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream @Override public void writeChar(final char value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeChar(" + value + ")"); + logger.trace("writeChar({})", value); } ((StreamMessage) message).writeChar(value); @@ -311,7 +287,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream @Override public void writeDouble(final double value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeDouble(" + value + ")"); + logger.trace("writeDouble({})", value); } ((StreamMessage) message).writeDouble(value); @@ -326,7 +302,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream @Override public void writeFloat(final float value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeFloat(" + value + ")"); + logger.trace("writeFloat({})", value); } ((StreamMessage) message).writeFloat(value); @@ -341,7 +317,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream @Override public void writeInt(final int value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeInt(" + value + ")"); + logger.trace("writeInt({})", value); } ((StreamMessage) message).writeInt(value); @@ -356,7 +332,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream @Override public void writeLong(final long value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeLong(" + value + ")"); + logger.trace("writeLong({})", value); } ((StreamMessage) message).writeLong(value); @@ -370,9 +346,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public void writeObject(final Object value) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("writeObject(" + value + ")"); - } + logger.trace("writeObject({})", value); ((StreamMessage) message).writeObject(value); } @@ -386,7 +360,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream @Override public void writeShort(final short value) throws JMSException { if (logger.isTraceEnabled()) { - logger.trace("writeShort(" + value + ")"); + logger.trace("writeShort({})", value); } ((StreamMessage) message).writeShort(value); @@ -400,9 +374,7 @@ public class ActiveMQRAStreamMessage extends ActiveMQRAMessage implements Stream */ @Override public void writeString(final String value) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("writeString(" + value + ")"); - } + logger.trace("writeString({})", value); ((StreamMessage) message).writeString(value); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATextMessage.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATextMessage.java index 3b0e63fb2f..c049c2de4a 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATextMessage.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATextMessage.java @@ -39,9 +39,7 @@ public class ActiveMQRATextMessage extends ActiveMQRAMessage implements TextMess public ActiveMQRATextMessage(final TextMessage message, final ActiveMQRASession session) { super(message, session); - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + message + ", " + session + ")"); - } + logger.trace("constructor({}, {})", message, session); } /** @@ -52,9 +50,7 @@ public class ActiveMQRATextMessage extends ActiveMQRAMessage implements TextMess */ @Override public String getText() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getText()"); - } + logger.trace("getText()"); return ((TextMessage) message).getText(); } @@ -67,9 +63,7 @@ public class ActiveMQRATextMessage extends ActiveMQRAMessage implements TextMess */ @Override public void setText(final String string) throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("setText(" + string + ")"); - } + logger.trace("setText({})", string); ((TextMessage) message).setText(string); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicPublisher.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicPublisher.java index bf024bfbcf..3f0eecdeb1 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicPublisher.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicPublisher.java @@ -41,9 +41,7 @@ public class ActiveMQRATopicPublisher extends ActiveMQRAMessageProducer implemen public ActiveMQRATopicPublisher(final TopicPublisher producer, final ActiveMQRASession session) { super(producer, session); - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + producer + ", " + session + ")"); - } + logger.trace("constructor({}, {})", producer, session); } /** @@ -54,9 +52,7 @@ public class ActiveMQRATopicPublisher extends ActiveMQRAMessageProducer implemen */ @Override public Topic getTopic() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getTopic()"); - } + logger.trace("getTopic()"); return ((TopicPublisher) producer).getTopic(); } @@ -78,24 +74,15 @@ public class ActiveMQRATopicPublisher extends ActiveMQRAMessageProducer implemen session.lock(); try { if (logger.isTraceEnabled()) { - logger.trace("send " + this + - " message=" + - message + - " deliveryMode=" + - deliveryMode + - " priority=" + - priority + - " ttl=" + - timeToLive); + logger.trace("send {} message={} deliveryMode={} priority={} ttl={}", + this, message, deliveryMode, priority, timeToLive); } checkState(); ((TopicPublisher) producer).publish(message, deliveryMode, priority, timeToLive); - if (logger.isTraceEnabled()) { - logger.trace("sent " + this + " result=" + message); - } + logger.trace("sent {} result={}", this, message); } finally { session.unlock(); } @@ -111,17 +98,13 @@ public class ActiveMQRATopicPublisher extends ActiveMQRAMessageProducer implemen public void publish(final Message message) throws JMSException { session.lock(); try { - if (logger.isTraceEnabled()) { - logger.trace("send " + this + " message=" + message); - } + logger.trace("send {} result={}", this, message); checkState(); ((TopicPublisher) producer).publish(message); - if (logger.isTraceEnabled()) { - logger.trace("sent " + this + " result=" + message); - } + logger.trace("sent {} result={}", this, message); } finally { session.unlock(); } @@ -146,26 +129,15 @@ public class ActiveMQRATopicPublisher extends ActiveMQRAMessageProducer implemen session.lock(); try { if (logger.isTraceEnabled()) { - logger.trace("send " + this + - " destination=" + - destination + - " message=" + - message + - " deliveryMode=" + - deliveryMode + - " priority=" + - priority + - " ttl=" + - timeToLive); + logger.trace("send {} destination={} message={} deliveryMode={} priority={} ttl={}", + this, destination, message, deliveryMode, priority, timeToLive); } checkState(); ((TopicPublisher) producer).publish(destination, message, deliveryMode, priority, timeToLive); - if (logger.isTraceEnabled()) { - logger.trace("sent " + this + " result=" + message); - } + logger.trace("sent {} result={}", this, message); } finally { session.unlock(); } @@ -183,16 +155,14 @@ public class ActiveMQRATopicPublisher extends ActiveMQRAMessageProducer implemen session.lock(); try { if (logger.isTraceEnabled()) { - logger.trace("send " + this + " destination=" + destination + " message=" + message); + logger.trace("send {} destination={} message={}", this, destination, message); } checkState(); ((TopicPublisher) producer).publish(destination, message); - if (logger.isTraceEnabled()) { - logger.trace("sent " + this + " result=" + message); - } + logger.trace("sent {} result={}", this, message); } finally { session.unlock(); } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicSubscriber.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicSubscriber.java index 844af8d83b..56418801c6 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicSubscriber.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRATopicSubscriber.java @@ -40,9 +40,7 @@ public class ActiveMQRATopicSubscriber extends ActiveMQRAMessageConsumer impleme public ActiveMQRATopicSubscriber(final TopicSubscriber consumer, final ActiveMQRASession session) { super(consumer, session); - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + consumer + ", " + session + ")"); - } + logger.trace("constructor({}, {})", consumer, session); } /** @@ -53,9 +51,7 @@ public class ActiveMQRATopicSubscriber extends ActiveMQRAMessageConsumer impleme */ @Override public boolean getNoLocal() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getNoLocal()"); - } + logger.trace("getNoLocal()"); checkState(); return ((TopicSubscriber) consumer).getNoLocal(); @@ -69,9 +65,7 @@ public class ActiveMQRATopicSubscriber extends ActiveMQRAMessageConsumer impleme */ @Override public Topic getTopic() throws JMSException { - if (logger.isTraceEnabled()) { - logger.trace("getTopic()"); - } + logger.trace("getTopic()"); checkState(); return ((TopicSubscriber) consumer).getTopic(); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAResource.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAResource.java index 8c3df9a162..339bcca733 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAResource.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAXAResource.java @@ -51,9 +51,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { * @param xaResource the xa resource */ public ActiveMQRAXAResource(final ActiveMQRAManagedConnection managedConnection, final XAResource xaResource) { - if (logger.isTraceEnabled()) { - logger.trace("constructor(" + managedConnection + ", " + xaResource + ")"); - } + logger.trace("constructor({} ,{})", managedConnection, xaResource); this.managedConnection = managedConnection; this.xaResource = xaResource; @@ -69,7 +67,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { @Override public void start(final Xid xid, final int flags) throws XAException { if (logger.isTraceEnabled()) { - logger.trace("start(" + xid + ", " + flags + ")"); + logger.trace("start({}, {})", xid, flags); } managedConnection.lock(); @@ -104,7 +102,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { @Override public void end(final Xid xid, final int flags) throws XAException { if (logger.isTraceEnabled()) { - logger.trace("end(" + xid + ", " + flags + ")"); + logger.trace("end({}, {})", xid, flags); } managedConnection.lock(); @@ -125,9 +123,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { */ @Override public int prepare(final Xid xid) throws XAException { - if (logger.isTraceEnabled()) { - logger.trace("prepare(" + xid + ")"); - } + logger.trace("prepare({})", xid); return xaResource.prepare(xid); } @@ -142,7 +138,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { @Override public void commit(final Xid xid, final boolean onePhase) throws XAException { if (logger.isTraceEnabled()) { - logger.trace("commit(" + xid + ", " + onePhase + ")"); + logger.trace("commit({}, {})", xid, onePhase); } xaResource.commit(xid, onePhase); @@ -156,9 +152,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { */ @Override public void rollback(final Xid xid) throws XAException { - if (logger.isTraceEnabled()) { - logger.trace("rollback(" + xid + ")"); - } + logger.trace("rollback({})", xid); xaResource.rollback(xid); } @@ -171,9 +165,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { */ @Override public void forget(final Xid xid) throws XAException { - if (logger.isTraceEnabled()) { - logger.trace("forget(" + xid + ")"); - } + logger.trace("forget({})", xid); managedConnection.lock(); try { @@ -194,9 +186,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { */ @Override public boolean isSameRM(final XAResource xaRes) throws XAException { - if (logger.isTraceEnabled()) { - logger.trace("isSameRM(" + xaRes + ")"); - } + logger.trace("isSameRM({})", xaRes); return xaResource.isSameRM(xaRes); } @@ -211,7 +201,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { @Override public Xid[] recover(final int flag) throws XAException { if (logger.isTraceEnabled()) { - logger.trace("recover(" + flag + ")"); + logger.trace("recover({})", flag); } return xaResource.recover(flag); @@ -225,9 +215,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { */ @Override public int getTransactionTimeout() throws XAException { - if (logger.isTraceEnabled()) { - logger.trace("getTransactionTimeout()"); - } + logger.trace("getTransactionTimeout()"); return xaResource.getTransactionTimeout(); } @@ -242,7 +230,7 @@ public class ActiveMQRAXAResource implements ActiveMQXAResource { @Override public boolean setTransactionTimeout(final int seconds) throws XAException { if (logger.isTraceEnabled()) { - logger.trace("setTransactionTimeout(" + seconds + ")"); + logger.trace("setTransactionTimeout({})", seconds); } return xaResource.setTransactionTimeout(seconds); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java index 580c12c5c7..75ff1cf61f 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQResourceAdapter.java @@ -139,9 +139,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * Constructor */ public ActiveMQResourceAdapter() { - if (logger.isTraceEnabled()) { - logger.trace("constructor()"); - } + logger.trace("constructor()"); raProperties = new ActiveMQRAProperties(); configured = new AtomicBoolean(false); @@ -173,9 +171,8 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { throw new ResourceException("Unable to create activation", e); } } - if (logger.isTraceEnabled()) { - logger.trace("endpointActivation(" + endpointFactory + ", " + spec + ")"); - } + + logger.trace("endpointActivation({}, {})", endpointFactory, spec); ActiveMQActivation activation = new ActiveMQActivation(this, endpointFactory, (ActiveMQActivationSpec) spec); activations.put(spec, activation); @@ -190,9 +187,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { */ @Override public void endpointDeactivation(final MessageEndpointFactory endpointFactory, final ActivationSpec spec) { - if (logger.isTraceEnabled()) { - logger.trace("endpointDeactivation(" + endpointFactory + ", " + spec + ")"); - } + logger.trace("endpointDeactivation({}, {})", endpointFactory, spec); ActiveMQActivation activation = activations.remove(spec); if (activation != null) { @@ -210,7 +205,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { @Override public XAResource[] getXAResources(final ActivationSpec[] specs) throws ResourceException { if (logger.isTraceEnabled()) { - logger.trace("getXAResources(" + Arrays.toString(specs) + ")"); + logger.trace("getXAResources({})", Arrays.toString(specs)); } if (useAutoRecovery) { @@ -236,9 +231,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { */ @Override public void start(final BootstrapContext ctx) throws ResourceAdapterInternalException { - if (logger.isTraceEnabled()) { - logger.trace("start(" + ctx + ")"); - } + logger.trace("start({})", ctx); tm = ServiceUtils.getTransactionManager(); @@ -262,9 +255,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { */ @Override public void stop() { - if (logger.isTraceEnabled()) { - logger.trace("stop()"); - } + logger.trace("stop()"); for (Map.Entry entry : activations.entrySet()) { try { @@ -325,9 +316,8 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { } public void setConnectorClassName(final String connectorClassName) { - if (logger.isTraceEnabled()) { - logger.trace("setTransportType(" + connectorClassName + ")"); - } + logger.trace("setTransportType({})", connectorClassName); + unparsedConnectors = connectorClassName; raProperties.setParsedConnectorClassNames(ActiveMQRaUtils.parseConnectorConnectorConfig(connectorClassName)); @@ -380,9 +370,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public String getDiscoveryAddress() { - if (logger.isTraceEnabled()) { - logger.trace("getDiscoveryGroupAddress()"); - } + logger.trace("getDiscoveryGroupAddress()"); return raProperties.getDiscoveryAddress(); } @@ -409,9 +397,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param dgn The value */ public void setDiscoveryAddress(final String dgn) { - if (logger.isTraceEnabled()) { - logger.trace("setDiscoveryGroupAddress(" + dgn + ")"); - } + logger.trace("setDiscoveryGroupAddress({})", dgn); raProperties.setDiscoveryAddress(dgn); } @@ -422,9 +408,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getDiscoveryPort() { - if (logger.isTraceEnabled()) { - logger.trace("getDiscoveryGroupPort()"); - } + logger.trace("getDiscoveryGroupPort()"); return raProperties.getDiscoveryPort(); } @@ -435,9 +419,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param discoveryLocalBindAddress the address value */ public void setDiscoveryLocalBindAddress(final String discoveryLocalBindAddress) { - if (logger.isTraceEnabled()) { - logger.trace("setDiscoveryLocalBindAddress(" + discoveryLocalBindAddress + ")"); - } + logger.trace("setDiscoveryLocalBindAddress({})", discoveryLocalBindAddress); raProperties.setDiscoveryLocalBindAddress(discoveryLocalBindAddress); } @@ -448,9 +430,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return the address value */ public String getDiscoveryLocalBindAddress() { - if (logger.isTraceEnabled()) { - logger.trace("getDiscoveryLocalBindAddress()"); - } + logger.trace("getDiscoveryLocalBindAddress()"); return raProperties.getDiscoveryLocalBindAddress(); } @@ -461,9 +441,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param dgp The value */ public void setDiscoveryPort(final Integer dgp) { - if (logger.isTraceEnabled()) { - logger.trace("setDiscoveryGroupPort(" + dgp + ")"); - } + logger.trace("setDiscoveryGroupPort({})", dgp); raProperties.setDiscoveryPort(dgp); } @@ -474,9 +452,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Long getDiscoveryRefreshTimeout() { - if (logger.isTraceEnabled()) { - logger.trace("getDiscoveryRefreshTimeout()"); - } + logger.trace("getDiscoveryRefreshTimeout()"); return raProperties.getDiscoveryRefreshTimeout(); } @@ -487,9 +463,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param discoveryRefreshTimeout The value */ public void setDiscoveryRefreshTimeout(final Long discoveryRefreshTimeout) { - if (logger.isTraceEnabled()) { - logger.trace("setDiscoveryRefreshTimeout(" + discoveryRefreshTimeout + ")"); - } + logger.trace("setDiscoveryRefreshTimeout({})", discoveryRefreshTimeout); raProperties.setDiscoveryRefreshTimeout(discoveryRefreshTimeout); } @@ -500,9 +474,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Long getDiscoveryInitialWaitTimeout() { - if (logger.isTraceEnabled()) { - logger.trace("getDiscoveryInitialWaitTimeout()"); - } + logger.trace("getDiscoveryInitialWaitTimeout()"); return raProperties.getDiscoveryInitialWaitTimeout(); } @@ -513,9 +485,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param discoveryInitialWaitTimeout The value */ public void setDiscoveryInitialWaitTimeout(final Long discoveryInitialWaitTimeout) { - if (logger.isTraceEnabled()) { - logger.trace("setDiscoveryInitialWaitTimeout(" + discoveryInitialWaitTimeout + ")"); - } + logger.trace("setDiscoveryInitialWaitTimeout({})", discoveryInitialWaitTimeout); raProperties.setDiscoveryInitialWaitTimeout(discoveryInitialWaitTimeout); } @@ -526,9 +496,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Long getClientFailureCheckPeriod() { - if (logger.isTraceEnabled()) { - logger.trace("getClientFailureCheckPeriod()"); - } + logger.trace("getClientFailureCheckPeriod()"); return raProperties.getClientFailureCheckPeriod(); } @@ -539,9 +507,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param clientFailureCheckPeriod The value */ public void setClientFailureCheckPeriod(final Long clientFailureCheckPeriod) { - if (logger.isTraceEnabled()) { - logger.trace("setClientFailureCheckPeriod(" + clientFailureCheckPeriod + ")"); - } + logger.trace("setClientFailureCheckPeriod({})", clientFailureCheckPeriod); raProperties.setClientFailureCheckPeriod(clientFailureCheckPeriod); } @@ -552,9 +518,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Long getConnectionTTL() { - if (logger.isTraceEnabled()) { - logger.trace("getConnectionTTL()"); - } + logger.trace("getConnectionTTL()"); return raProperties.getConnectionTTL(); } @@ -565,9 +529,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param connectionTTL The value */ public void setConnectionTTL(final Long connectionTTL) { - if (logger.isTraceEnabled()) { - logger.trace("setConnectionTTL(" + connectionTTL + ")"); - } + logger.trace("setConnectionTTL({})", connectionTTL); raProperties.setConnectionTTL(connectionTTL); } @@ -578,9 +540,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Boolean isCacheLargeMessagesClient() { - if (logger.isTraceEnabled()) { - logger.trace("isCacheLargeMessagesClient()"); - } + logger.trace("isCacheLargeMessagesClient()"); return raProperties.isCacheLargeMessagesClient(); } @@ -591,9 +551,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param cacheLargeMessagesClient The value */ public void setCacheLargeMessagesClient(final Boolean cacheLargeMessagesClient) { - if (logger.isTraceEnabled()) { - logger.trace("setCacheLargeMessagesClient(" + cacheLargeMessagesClient + ")"); - } + logger.trace("setCacheLargeMessagesClient({})", cacheLargeMessagesClient); raProperties.setCacheLargeMessagesClient(cacheLargeMessagesClient); } @@ -604,9 +562,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Boolean isCompressLargeMessage() { - if (logger.isTraceEnabled()) { - logger.trace("isCompressLargeMessage()"); - } + logger.trace("isCompressLargeMessage()"); return raProperties.isCompressLargeMessage(); } @@ -636,9 +592,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param cacheDestinations The value */ public void setCacheDestinations(final Boolean cacheDestinations) { - if (logger.isTraceEnabled()) { - logger.trace("setCacheDestinations(" + cacheDestinations + ")"); - } + logger.trace("setCacheDestinations({})", cacheDestinations); raProperties.setCacheDestinations(cacheDestinations); } @@ -649,9 +603,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Boolean isCacheDestinations() { - if (logger.isTraceEnabled()) { - logger.trace("isCacheDestinations()"); - } + logger.trace("isCacheDestinations()"); return raProperties.isCacheDestinations(); } @@ -662,9 +614,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param enable1xPrefixes The value */ public void setEnable1xPrefixes(final Boolean enable1xPrefixes) { - if (logger.isTraceEnabled()) { - logger.trace("setEnable1xPrefixes(" + enable1xPrefixes + ")"); - } + logger.trace("setEnable1xPrefixes({})", enable1xPrefixes); raProperties.setEnable1xPrefixes(enable1xPrefixes); } @@ -675,9 +625,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Boolean isEnable1xPrefixes() { - if (logger.isTraceEnabled()) { - logger.trace("isEnable1xPrefixes()"); - } + logger.trace("isEnable1xPrefixes()"); return raProperties.isEnable1xPrefixes(); } @@ -688,9 +636,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param compressLargeMessage The value */ public void setCompressLargeMessage(final Boolean compressLargeMessage) { - if (logger.isTraceEnabled()) { - logger.trace("setCompressLargeMessage(" + compressLargeMessage + ")"); - } + logger.trace("setCompressLargeMessage({})", compressLargeMessage); raProperties.setCompressLargeMessage(compressLargeMessage); } @@ -701,9 +647,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Long getCallTimeout() { - if (logger.isTraceEnabled()) { - logger.trace("getCallTimeout()"); - } + logger.trace("getCallTimeout()"); return raProperties.getCallTimeout(); } @@ -714,9 +658,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param callTimeout The value */ public void setCallTimeout(final Long callTimeout) { - if (logger.isTraceEnabled()) { - logger.trace("setCallTimeout(" + callTimeout + ")"); - } + logger.trace("setCallTimeout({})", callTimeout); raProperties.setCallTimeout(callTimeout); } @@ -727,9 +669,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Long getCallFailoverTimeout() { - if (logger.isTraceEnabled()) { - logger.trace("getCallFailoverTimeout()"); - } + logger.trace("getCallFailoverTimeout()"); return raProperties.getCallFailoverTimeout(); } @@ -740,9 +680,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param callFailoverTimeout The value */ public void setCallFailoverTimeout(final Long callFailoverTimeout) { - if (logger.isTraceEnabled()) { - logger.trace("setCallFailoverTimeout(" + callFailoverTimeout + ")"); - } + logger.trace("setCallFailoverTimeout({})", callFailoverTimeout); raProperties.setCallFailoverTimeout(callFailoverTimeout); } @@ -753,9 +691,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getDupsOKBatchSize() { - if (logger.isTraceEnabled()) { - logger.trace("getDupsOKBatchSize()"); - } + logger.trace("getDupsOKBatchSize()"); return raProperties.getDupsOKBatchSize(); } @@ -766,9 +702,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param dupsOKBatchSize The value */ public void setDupsOKBatchSize(final Integer dupsOKBatchSize) { - if (logger.isTraceEnabled()) { - logger.trace("setDupsOKBatchSize(" + dupsOKBatchSize + ")"); - } + logger.trace("setDupsOKBatchSize({})", dupsOKBatchSize); raProperties.setDupsOKBatchSize(dupsOKBatchSize); } @@ -779,9 +713,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getTransactionBatchSize() { - if (logger.isTraceEnabled()) { - logger.trace("getTransactionBatchSize()"); - } + logger.trace("getTransactionBatchSize()"); return raProperties.getTransactionBatchSize(); } @@ -792,9 +724,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param transactionBatchSize The value */ public void setTransactionBatchSize(final Integer transactionBatchSize) { - if (logger.isTraceEnabled()) { - logger.trace("setTransactionBatchSize(" + transactionBatchSize + ")"); - } + logger.trace("setTransactionBatchSize({})", transactionBatchSize); raProperties.setTransactionBatchSize(transactionBatchSize); } @@ -805,9 +735,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getConsumerWindowSize() { - if (logger.isTraceEnabled()) { - logger.trace("getConsumerWindowSize()"); - } + logger.trace("getConsumerWindowSize()"); return raProperties.getConsumerWindowSize(); } @@ -818,9 +746,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param consumerWindowSize The value */ public void setConsumerWindowSize(final Integer consumerWindowSize) { - if (logger.isTraceEnabled()) { - logger.trace("setConsumerWindowSize(" + consumerWindowSize + ")"); - } + logger.trace("setConsumerWindowSize({})", consumerWindowSize); raProperties.setConsumerWindowSize(consumerWindowSize); } @@ -831,9 +757,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getConsumerMaxRate() { - if (logger.isTraceEnabled()) { - logger.trace("getConsumerMaxRate()"); - } + logger.trace("getConsumerMaxRate()"); return raProperties.getConsumerMaxRate(); } @@ -844,9 +768,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param consumerMaxRate The value */ public void setConsumerMaxRate(final Integer consumerMaxRate) { - if (logger.isTraceEnabled()) { - logger.trace("setConsumerMaxRate(" + consumerMaxRate + ")"); - } + logger.trace("setConsumerMaxRate({})", consumerMaxRate); raProperties.setConsumerMaxRate(consumerMaxRate); } @@ -857,9 +779,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getConfirmationWindowSize() { - if (logger.isTraceEnabled()) { - logger.trace("getConfirmationWindowSize()"); - } + logger.trace("getConfirmationWindowSize()"); return raProperties.getConfirmationWindowSize(); } @@ -870,9 +790,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param confirmationWindowSize The value */ public void setConfirmationWindowSize(final Integer confirmationWindowSize) { - if (logger.isTraceEnabled()) { - logger.trace("setConfirmationWindowSize(" + confirmationWindowSize + ")"); - } + logger.trace("setConfirmationWindowSize({})", confirmationWindowSize); raProperties.setConfirmationWindowSize(confirmationWindowSize); } @@ -883,9 +801,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getProducerMaxRate() { - if (logger.isTraceEnabled()) { - logger.trace("getProducerMaxRate()"); - } + logger.trace("getProducerMaxRate()"); return raProperties.getProducerMaxRate(); } @@ -896,9 +812,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param producerMaxRate The value */ public void setProducerMaxRate(final Integer producerMaxRate) { - if (logger.isTraceEnabled()) { - logger.trace("setProducerMaxRate(" + producerMaxRate + ")"); - } + logger.trace("setProducerMaxRate({})", producerMaxRate); raProperties.setProducerMaxRate(producerMaxRate); } @@ -917,9 +831,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getProducerWindowSize() { - if (logger.isTraceEnabled()) { - logger.trace("getProducerWindowSize()"); - } + logger.trace("getProducerWindowSize()"); return raProperties.getProducerWindowSize(); } @@ -930,55 +842,43 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param producerWindowSize The value */ public void setProducerWindowSize(final Integer producerWindowSize) { - if (logger.isTraceEnabled()) { - logger.trace("setProducerWindowSize(" + producerWindowSize + ")"); - } + logger.trace("setProducerWindowSize({})", producerWindowSize); raProperties.setProducerWindowSize(producerWindowSize); } public String getProtocolManagerFactoryStr() { - if (logger.isTraceEnabled()) { - logger.trace("getProtocolManagerFactoryStr()"); - } + logger.trace("getProtocolManagerFactoryStr()"); return raProperties.getProtocolManagerFactoryStr(); } public void setProtocolManagerFactoryStr(final String protocolManagerFactoryStr) { - if (logger.isTraceEnabled()) { - logger.trace("setProtocolManagerFactoryStr(" + protocolManagerFactoryStr + ")"); - } + logger.trace("setProtocolManagerFactoryStr({})", protocolManagerFactoryStr); raProperties.setProtocolManagerFactoryStr(protocolManagerFactoryStr); } public String getDeserializationBlackList() { - if (logger.isTraceEnabled()) { - logger.trace("getDeserializationBlackList()"); - } + logger.trace("getDeserializationBlackList()"); + return raProperties.getDeserializationBlackList(); } public void setDeserializationBlackList(String deserializationBlackList) { - if (logger.isTraceEnabled()) { - logger.trace("setDeserializationBlackList(" + deserializationBlackList + ")"); - } + logger.trace("setDeserializationBlackList({})", deserializationBlackList); raProperties.setDeserializationBlackList(deserializationBlackList); } public String getDeserializationWhiteList() { - if (logger.isTraceEnabled()) { - logger.trace("getDeserializationWhiteList()"); - } + logger.trace("getDeserializationWhiteList()"); + return raProperties.getDeserializationWhiteList(); } public void setDeserializationWhiteList(String deserializationWhiteList) { - if (logger.isTraceEnabled()) { - logger.trace("setDeserializationWhiteList(" + deserializationWhiteList + ")"); - } + logger.trace("setDeserializationWhiteList({})", deserializationWhiteList); raProperties.setDeserializationWhiteList(deserializationWhiteList); } @@ -989,9 +889,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getMinLargeMessageSize() { - if (logger.isTraceEnabled()) { - logger.trace("getMinLargeMessageSize()"); - } + logger.trace("getMinLargeMessageSize()"); return raProperties.getMinLargeMessageSize(); } @@ -1002,9 +900,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param minLargeMessageSize The value */ public void setMinLargeMessageSize(final Integer minLargeMessageSize) { - if (logger.isTraceEnabled()) { - logger.trace("setMinLargeMessageSize(" + minLargeMessageSize + ")"); - } + logger.trace("setMinLargeMessageSize({})", minLargeMessageSize); raProperties.setMinLargeMessageSize(minLargeMessageSize); } @@ -1015,9 +911,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Boolean getBlockOnAcknowledge() { - if (logger.isTraceEnabled()) { - logger.trace("getBlockOnAcknowledge()"); - } + logger.trace("getBlockOnAcknowledge()"); return raProperties.isBlockOnAcknowledge(); } @@ -1028,9 +922,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param blockOnAcknowledge The value */ public void setBlockOnAcknowledge(final Boolean blockOnAcknowledge) { - if (logger.isTraceEnabled()) { - logger.trace("setBlockOnAcknowledge(" + blockOnAcknowledge + ")"); - } + logger.trace("setBlockOnAcknowledge({})", blockOnAcknowledge); raProperties.setBlockOnAcknowledge(blockOnAcknowledge); } @@ -1041,9 +933,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Boolean getBlockOnNonDurableSend() { - if (logger.isTraceEnabled()) { - logger.trace("getBlockOnNonDurableSend()"); - } + logger.trace("getBlockOnNonDurableSend()"); return raProperties.isBlockOnNonDurableSend(); } @@ -1054,9 +944,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param blockOnNonDurableSend The value */ public void setBlockOnNonDurableSend(final Boolean blockOnNonDurableSend) { - if (logger.isTraceEnabled()) { - logger.trace("setBlockOnNonDurableSend(" + blockOnNonDurableSend + ")"); - } + logger.trace("setBlockOnNonDurableSend({})", blockOnNonDurableSend); raProperties.setBlockOnNonDurableSend(blockOnNonDurableSend); } @@ -1067,9 +955,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Boolean getBlockOnDurableSend() { - if (logger.isTraceEnabled()) { - logger.trace("getBlockOnDurableSend()"); - } + logger.trace("getBlockOnDurableSend()"); return raProperties.isBlockOnDurableSend(); } @@ -1080,9 +966,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param blockOnDurableSend The value */ public void setBlockOnDurableSend(final Boolean blockOnDurableSend) { - if (logger.isTraceEnabled()) { - logger.trace("setBlockOnDurableSend(" + blockOnDurableSend + ")"); - } + logger.trace("setBlockOnDurableSend({})", blockOnDurableSend); raProperties.setBlockOnDurableSend(blockOnDurableSend); } @@ -1093,9 +977,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Boolean getAutoGroup() { - if (logger.isTraceEnabled()) { - logger.trace("getAutoGroup()"); - } + logger.trace("getAutoGroup()"); return raProperties.isAutoGroup(); } @@ -1106,9 +988,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param autoGroup The value */ public void setAutoGroup(final Boolean autoGroup) { - if (logger.isTraceEnabled()) { - logger.trace("setAutoGroup(" + autoGroup + ")"); - } + logger.trace("setAutoGroup({})", autoGroup); raProperties.setAutoGroup(autoGroup); } @@ -1119,9 +999,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Boolean getPreAcknowledge() { - if (logger.isTraceEnabled()) { - logger.trace("getPreAcknowledge()"); - } + logger.trace("getPreAcknowledge()"); return raProperties.isPreAcknowledge(); } @@ -1132,9 +1010,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param preAcknowledge The value */ public void setPreAcknowledge(final Boolean preAcknowledge) { - if (logger.isTraceEnabled()) { - logger.trace("setPreAcknowledge(" + preAcknowledge + ")"); - } + logger.trace("setPreAcknowledge({})", preAcknowledge); raProperties.setPreAcknowledge(preAcknowledge); } @@ -1145,9 +1021,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getInitialConnectAttempts() { - if (logger.isTraceEnabled()) { - logger.trace("getInitialConnectAttempts()"); - } + logger.trace("getInitialConnectAttempts()"); return raProperties.getInitialConnectAttempts(); } @@ -1158,9 +1032,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param initialConnectAttempts The value */ public void setInitialConnectAttempts(final Integer initialConnectAttempts) { - if (logger.isTraceEnabled()) { - logger.trace("setInitialConnectionAttempts(" + initialConnectAttempts + ")"); - } + logger.trace("setInitialConnectionAttempts({})", initialConnectAttempts); raProperties.setInitialConnectAttempts(initialConnectAttempts); } @@ -1171,9 +1043,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getInitialMessagePacketSize() { - if (logger.isTraceEnabled()) { - logger.trace("getInitialMessagePacketSize()"); - } + logger.trace("getInitialMessagePacketSize()"); return raProperties.getInitialMessagePacketSize(); } @@ -1184,9 +1054,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param initialMessagePacketSize The value */ public void setInitialMessagePacketSize(final Integer initialMessagePacketSize) { - if (logger.isTraceEnabled()) { - logger.trace("setInitialMessagePacketSize(" + initialMessagePacketSize + ")"); - } + logger.trace("setInitialMessagePacketSize({})", initialMessagePacketSize); raProperties.setInitialMessagePacketSize(initialMessagePacketSize); } @@ -1197,9 +1065,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Long getRetryInterval() { - if (logger.isTraceEnabled()) { - logger.trace("getRetryInterval()"); - } + logger.trace("getRetryInterval()"); return raProperties.getRetryInterval(); } @@ -1210,9 +1076,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param retryInterval The value */ public void setRetryInterval(final Long retryInterval) { - if (logger.isTraceEnabled()) { - logger.trace("setRetryInterval(" + retryInterval + ")"); - } + logger.trace("setRetryInterval({})", retryInterval); raProperties.setRetryInterval(retryInterval); } @@ -1223,9 +1087,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Double getRetryIntervalMultiplier() { - if (logger.isTraceEnabled()) { - logger.trace("getRetryIntervalMultiplier()"); - } + logger.trace("getRetryIntervalMultiplier()"); return raProperties.getRetryIntervalMultiplier(); } @@ -1236,9 +1098,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param retryIntervalMultiplier The value */ public void setRetryIntervalMultiplier(final Double retryIntervalMultiplier) { - if (logger.isTraceEnabled()) { - logger.trace("setRetryIntervalMultiplier(" + retryIntervalMultiplier + ")"); - } + logger.trace("setRetryIntervalMultiplier({})", retryIntervalMultiplier); raProperties.setRetryIntervalMultiplier(retryIntervalMultiplier); } @@ -1249,9 +1109,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Long getMaxRetryInterval() { - if (logger.isTraceEnabled()) { - logger.trace("getMaxRetryInterval()"); - } + logger.trace("getMaxRetryInterval()"); return raProperties.getMaxRetryInterval(); } @@ -1262,9 +1120,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param maxRetryInterval The value */ public void setMaxRetryInterval(final Long maxRetryInterval) { - if (logger.isTraceEnabled()) { - logger.trace("setMaxRetryInterval(" + maxRetryInterval + ")"); - } + logger.trace("setMaxRetryInterval({})", maxRetryInterval); raProperties.setMaxRetryInterval(maxRetryInterval); } @@ -1275,9 +1131,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Integer getReconnectAttempts() { - if (logger.isTraceEnabled()) { - logger.trace("getReconnectAttempts()"); - } + logger.trace("getReconnectAttempts()"); return raProperties.getReconnectAttempts(); } @@ -1288,9 +1142,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param reconnectAttempts The value */ public void setReconnectAttempts(final Integer reconnectAttempts) { - if (logger.isTraceEnabled()) { - logger.trace("setReconnectAttempts(" + reconnectAttempts + ")"); - } + logger.trace("setReconnectAttempts({})", reconnectAttempts); raProperties.setReconnectAttempts(reconnectAttempts); } @@ -1300,9 +1152,8 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { } public void setConnectionLoadBalancingPolicyClassName(final String connectionLoadBalancingPolicyClassName) { - if (logger.isTraceEnabled()) { - logger.trace("setFailoverOnServerShutdown(" + connectionLoadBalancingPolicyClassName + ")"); - } + logger.trace("setFailoverOnServerShutdown({})", connectionLoadBalancingPolicyClassName); + raProperties.setConnectionLoadBalancingPolicyClassName(connectionLoadBalancingPolicyClassName); } @@ -1311,9 +1162,8 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { } public void setScheduledThreadPoolMaxSize(final Integer scheduledThreadPoolMaxSize) { - if (logger.isTraceEnabled()) { - logger.trace("setFailoverOnServerShutdown(" + scheduledThreadPoolMaxSize + ")"); - } + logger.trace("setFailoverOnServerShutdown({})", scheduledThreadPoolMaxSize); + raProperties.setScheduledThreadPoolMaxSize(scheduledThreadPoolMaxSize); } @@ -1322,9 +1172,8 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { } public void setThreadPoolMaxSize(final Integer threadPoolMaxSize) { - if (logger.isTraceEnabled()) { - logger.trace("setFailoverOnServerShutdown(" + threadPoolMaxSize + ")"); - } + logger.trace("setFailoverOnServerShutdown({})", threadPoolMaxSize); + raProperties.setThreadPoolMaxSize(threadPoolMaxSize); } @@ -1333,9 +1182,8 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { } public void setUseGlobalPools(final Boolean useGlobalPools) { - if (logger.isTraceEnabled()) { - logger.trace("setFailoverOnServerShutdown(" + useGlobalPools + ")"); - } + logger.trace("setFailoverOnServerShutdown({})", useGlobalPools); + raProperties.setUseGlobalPools(useGlobalPools); } @@ -1345,9 +1193,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public String getUserName() { - if (logger.isTraceEnabled()) { - logger.trace("getUserName()"); - } + logger.trace("getUserName()"); return raProperties.getUserName(); } @@ -1358,9 +1204,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param userName The value */ public void setUserName(final String userName) { - if (logger.isTraceEnabled()) { - logger.trace("setUserName(" + userName + ")"); - } + logger.trace("setUserName({})", userName); raProperties.setUserName(userName); } @@ -1371,9 +1215,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public String getPassword() { - if (logger.isTraceEnabled()) { - logger.trace("getPassword()"); - } + logger.trace("getPassword()"); return raProperties.getPassword(); } @@ -1427,9 +1269,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public String getClientID() { - if (logger.isTraceEnabled()) { - logger.trace("getClientID()"); - } + logger.trace("getClientID()"); return raProperties.getClientID(); } @@ -1440,9 +1280,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param clientID The client id */ public void setClientID(final String clientID) { - if (logger.isTraceEnabled()) { - logger.trace("setClientID(" + clientID + ")"); - } + logger.trace("setClientID({})", clientID); raProperties.setClientID(clientID); } @@ -1453,9 +1291,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public String getGroupID() { - if (logger.isTraceEnabled()) { - logger.trace("getGroupID()"); - } + logger.trace("getGroupID()"); return raProperties.getGroupID(); } @@ -1466,9 +1302,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param groupID The group id */ public void setGroupID(final String groupID) { - if (logger.isTraceEnabled()) { - logger.trace("setGroupID(" + groupID + ")"); - } + logger.trace("setGroupID({})", groupID); raProperties.setGroupID(groupID); } @@ -1479,9 +1313,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The value */ public Boolean getUseLocalTx() { - if (logger.isTraceEnabled()) { - logger.trace("getUseLocalTx()"); - } + logger.trace("getUseLocalTx()"); return raProperties.getUseLocalTx(); } @@ -1492,38 +1324,32 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @param localTx The value */ public void setUseLocalTx(final Boolean localTx) { - if (logger.isTraceEnabled()) { - logger.trace("setUseXA(" + localTx + ")"); - } + logger.trace("setUseXA({})", localTx); raProperties.setUseLocalTx(localTx); } public int getSetupAttempts() { - if (logger.isTraceEnabled()) { - logger.trace("getSetupAttempts()"); - } + logger.trace("getSetupAttempts()"); + return raProperties.getSetupAttempts(); } public void setSetupAttempts(Integer setupAttempts) { - if (logger.isTraceEnabled()) { - logger.trace("setSetupAttempts(" + setupAttempts + ")"); - } + logger.trace("setSetupAttempts({})", setupAttempts); + raProperties.setSetupAttempts(setupAttempts); } public long getSetupInterval() { - if (logger.isTraceEnabled()) { - logger.trace("getSetupInterval()"); - } + logger.trace("getSetupInterval()"); + return raProperties.getSetupInterval(); } public void setSetupInterval(Long interval) { - if (logger.isTraceEnabled()) { - logger.trace("setSetupInterval(" + interval + ")"); - } + logger.trace("setSetupInterval({})", interval); + raProperties.setSetupInterval(interval); } @@ -1535,9 +1361,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { */ @Override public boolean equals(final Object obj) { - if (logger.isTraceEnabled()) { - logger.trace("equals(" + obj + ")"); - } + logger.trace("equals({})", obj); if (obj == null) { return false; @@ -1556,9 +1380,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { */ @Override public int hashCode() { - if (logger.isTraceEnabled()) { - logger.trace("hashCode()"); - } + logger.trace("hashCode()"); return raProperties.hashCode(); } @@ -1569,9 +1391,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The manager */ public WorkManager getWorkManager() { - if (logger.isTraceEnabled()) { - logger.trace("getWorkManager()"); - } + logger.trace("getWorkManager()"); if (ctx == null) { return null; @@ -1622,7 +1442,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { } } - logger.debug("Using queue connection " + result); + logger.debug("Using queue connection {}", result); return result; @@ -1638,9 +1458,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { * @return The properties */ public ActiveMQRAProperties getProperties() { - if (logger.isTraceEnabled()) { - logger.trace("getProperties()"); - } + logger.trace("getProperties()"); return raProperties; } @@ -1751,9 +1569,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { DiscoveryGroupConfiguration groupConfiguration = new DiscoveryGroupConfiguration().setRefreshTimeout(refreshTimeout).setDiscoveryInitialWaitTimeout(initialTimeout).setBroadcastEndpointFactory(endpointFactory); - if (logger.isDebugEnabled()) { - logger.debug("Creating Connection Factory on the resource adapter for discovery=" + groupConfiguration + " with ha=" + ha); - } + logger.debug("Creating Connection Factory on the resource adapter for discovery={} with ha={}", groupConfiguration, ha); if (ha) { cf = ActiveMQJMSClient.createConnectionFactoryWithHA(groupConfiguration, JMSFactoryType.XA_CF); @@ -1783,7 +1599,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { } if (logger.isDebugEnabled()) { - logger.debug("Creating Connection Factory on the resource adapter for transport=" + Arrays.toString(transportConfigurations) + " with ha=" + ha); + logger.debug("Creating Connection Factory on the resource adapter for transport={} with ha={}", Arrays.toString(transportConfigurations), ha); } if (ha) { @@ -1826,9 +1642,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { groupConfiguration.setRefreshTimeout(refreshTimeout); - if (logger.isDebugEnabled()) { - logger.debug("Creating Recovery Connection Factory on the resource adapter for discovery=" + groupConfiguration); - } + logger.debug("Creating Recovery Connection Factory on the resource adapter for discovery={}", groupConfiguration); cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(groupConfiguration, JMSFactoryType.XA_CF); } else { @@ -1854,7 +1668,7 @@ public class ActiveMQResourceAdapter implements ResourceAdapter, Serializable { } if (logger.isDebugEnabled()) { - logger.debug("Creating Recovery Connection Factory on the resource adapter for transport=" + Arrays.toString(transportConfigurations)); + logger.debug("Creating Recovery Connection Factory on the resource adapter for transport={}", Arrays.toString(transportConfigurations)); } cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF, transportConfigurations); diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java index aaf57f606b..b370a34064 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ConnectionFactoryProperties.java @@ -179,241 +179,209 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public String getConnectionLoadBalancingPolicyClassName() { - if (logger.isTraceEnabled()) { - logger.trace("getConnectionLoadBalancingPolicyClassName()"); - } + logger.trace("getConnectionLoadBalancingPolicyClassName()"); + return connectionLoadBalancingPolicyClassName; } public void setConnectionLoadBalancingPolicyClassName(final String connectionLoadBalancingPolicyClassName) { - if (logger.isTraceEnabled()) { - logger.trace("setSessionDefaultType(" + connectionLoadBalancingPolicyClassName + ")"); - } + logger.trace("setSessionDefaultType({})", connectionLoadBalancingPolicyClassName); + hasBeenUpdated = true; this.connectionLoadBalancingPolicyClassName = connectionLoadBalancingPolicyClassName; } public String getDiscoveryAddress() { - if (logger.isTraceEnabled()) { - logger.trace("getDiscoveryAddress()"); - } + logger.trace("getDiscoveryAddress()"); + return discoveryAddress; } public void setDiscoveryAddress(final String discoveryAddress) { - if (logger.isTraceEnabled()) { - logger.trace("setDiscoveryAddress(" + discoveryAddress + ")"); - } + logger.trace("setDiscoveryAddress({})", discoveryAddress); + hasBeenUpdated = true; this.discoveryAddress = discoveryAddress; } public Integer getDiscoveryPort() { - if (logger.isTraceEnabled()) { - logger.trace("getDiscoveryPort()"); - } + logger.trace("getDiscoveryPort()"); + return discoveryPort; } public void setDiscoveryLocalBindAddress(final String discoveryLocalBindAddress) { - if (logger.isTraceEnabled()) { - logger.trace("setDiscoveryLocalBindAddress(" + discoveryLocalBindAddress + ")"); - } + logger.trace("setDiscoveryLocalBindAddress({})", discoveryLocalBindAddress); + hasBeenUpdated = true; this.discoveryLocalBindAddress = discoveryLocalBindAddress; } public String getDiscoveryLocalBindAddress() { - if (logger.isTraceEnabled()) { - logger.trace("getDiscoveryLocalBindAddress()"); - } + logger.trace("getDiscoveryLocalBindAddress()"); + return discoveryLocalBindAddress; } public void setDiscoveryPort(final Integer discoveryPort) { - if (logger.isTraceEnabled()) { - logger.trace("setDiscoveryPort(" + discoveryPort + ")"); - } + logger.trace("setDiscoveryPort({})", discoveryPort); + hasBeenUpdated = true; this.discoveryPort = discoveryPort; } public Long getDiscoveryRefreshTimeout() { - if (logger.isTraceEnabled()) { - logger.trace("getDiscoveryRefreshTimeout()"); - } + logger.trace("getDiscoveryRefreshTimeout()"); + return discoveryRefreshTimeout; } public void setDiscoveryRefreshTimeout(final Long discoveryRefreshTimeout) { - if (logger.isTraceEnabled()) { - logger.trace("setDiscoveryRefreshTimeout(" + discoveryRefreshTimeout + ")"); - } + logger.trace("setDiscoveryRefreshTimeout({})", discoveryRefreshTimeout); + hasBeenUpdated = true; this.discoveryRefreshTimeout = discoveryRefreshTimeout; } public Long getDiscoveryInitialWaitTimeout() { - if (logger.isTraceEnabled()) { - logger.trace("getDiscoveryInitialWaitTimeout()"); - } + logger.trace("getDiscoveryInitialWaitTimeout()"); + return discoveryInitialWaitTimeout; } public void setDiscoveryInitialWaitTimeout(final Long discoveryInitialWaitTimeout) { - if (logger.isTraceEnabled()) { - logger.trace("setDiscoveryInitialWaitTimeout(" + discoveryInitialWaitTimeout + ")"); - } + logger.trace("setDiscoveryInitialWaitTimeout({})", discoveryInitialWaitTimeout); + hasBeenUpdated = true; this.discoveryInitialWaitTimeout = discoveryInitialWaitTimeout; } public String getClientID() { - if (logger.isTraceEnabled()) { - logger.trace("getClientID()"); - } + logger.trace("getClientID()"); + return clientID; } public void setClientID(final String clientID) { - if (logger.isTraceEnabled()) { - logger.trace("setClientID(" + clientID + ")"); - } + logger.trace("setClientID({})", clientID); + hasBeenUpdated = true; this.clientID = clientID; } public Integer getDupsOKBatchSize() { - if (logger.isTraceEnabled()) { - logger.trace("getDupsOKBatchSize()"); - } + logger.trace("getDupsOKBatchSize()"); + return dupsOKBatchSize; } public void setDupsOKBatchSize(final Integer dupsOKBatchSize) { - if (logger.isTraceEnabled()) { - logger.trace("setDupsOKBatchSize(" + dupsOKBatchSize + ")"); - } + logger.trace("setDupsOKBatchSize({})", dupsOKBatchSize); + hasBeenUpdated = true; this.dupsOKBatchSize = dupsOKBatchSize; } public Integer getTransactionBatchSize() { - if (logger.isTraceEnabled()) { - logger.trace("getTransactionBatchSize()"); - } + logger.trace("getTransactionBatchSize()"); + return transactionBatchSize; } public void setTransactionBatchSize(final Integer transactionBatchSize) { - if (logger.isTraceEnabled()) { - logger.trace("setTransactionBatchSize(" + transactionBatchSize + ")"); - } + logger.trace("setTransactionBatchSize({})", transactionBatchSize); + hasBeenUpdated = true; this.transactionBatchSize = transactionBatchSize; } public Long getClientFailureCheckPeriod() { - if (logger.isTraceEnabled()) { - logger.trace("getClientFailureCheckPeriod()"); - } + logger.trace("getClientFailureCheckPeriod()"); + return clientFailureCheckPeriod; } public void setClientFailureCheckPeriod(final Long clientFailureCheckPeriod) { - if (logger.isTraceEnabled()) { - logger.trace("setClientFailureCheckPeriod(" + clientFailureCheckPeriod + ")"); - } + logger.trace("setClientFailureCheckPeriod({})", clientFailureCheckPeriod); + hasBeenUpdated = true; this.clientFailureCheckPeriod = clientFailureCheckPeriod; } public Long getConnectionTTL() { - if (logger.isTraceEnabled()) { - logger.trace("getConnectionTTL()"); - } + logger.trace("getConnectionTTL()"); + return connectionTTL; } public void setConnectionTTL(final Long connectionTTL) { - if (logger.isTraceEnabled()) { - logger.trace("setConnectionTTL(" + connectionTTL + ")"); - } + logger.trace("setConnectionTTL({})", connectionTTL); + hasBeenUpdated = true; this.connectionTTL = connectionTTL; } public Long getCallTimeout() { - if (logger.isTraceEnabled()) { - logger.trace("getCallTimeout()"); - } + logger.trace("getCallTimeout()"); + return callTimeout; } public void setCallTimeout(final Long callTimeout) { - if (logger.isTraceEnabled()) { - logger.trace("setCallTimeout(" + callTimeout + ")"); - } + logger.trace("setCallTimeout({})", callTimeout); + hasBeenUpdated = true; this.callTimeout = callTimeout; } public Long getCallFailoverTimeout() { - if (logger.isTraceEnabled()) { - logger.trace("getCallFailoverTimeout()"); - } + logger.trace("getCallFailoverTimeout()"); + return callFailoverTimeout; } public void setCallFailoverTimeout(final Long callFailoverTimeout) { - if (logger.isTraceEnabled()) { - logger.trace("setCallFailoverTimeout(" + callFailoverTimeout + ")"); - } + logger.trace("setCallFailoverTimeout({})", callFailoverTimeout); + hasBeenUpdated = true; this.callFailoverTimeout = callFailoverTimeout; } public Integer getConsumerWindowSize() { - if (logger.isTraceEnabled()) { - logger.trace("getConsumerWindowSize()"); - } + logger.trace("getConsumerWindowSize()"); + return consumerWindowSize; } public void setConsumerWindowSize(final Integer consumerWindowSize) { - if (logger.isTraceEnabled()) { - logger.trace("setConsumerWindowSize(" + consumerWindowSize + ")"); - } + logger.trace("setConsumerWindowSize({})", consumerWindowSize); + hasBeenUpdated = true; this.consumerWindowSize = consumerWindowSize; } public Integer getConsumerMaxRate() { - if (logger.isTraceEnabled()) { - logger.trace("getConsumerMaxRate()"); - } + logger.trace("getConsumerMaxRate()"); + return consumerMaxRate; } public void setConsumerMaxRate(final Integer consumerMaxRate) { - if (logger.isTraceEnabled()) { - logger.trace("setConsumerMaxRate(" + consumerMaxRate + ")"); - } + logger.trace("setConsumerMaxRate({})", consumerMaxRate); + hasBeenUpdated = true; this.consumerMaxRate = consumerMaxRate; } public Integer getConfirmationWindowSize() { - if (logger.isTraceEnabled()) { - logger.trace("getConfirmationWindowSize()"); - } + logger.trace("getConfirmationWindowSize()"); + return confirmationWindowSize; } public void setConfirmationWindowSize(final Integer confirmationWindowSize) { - if (logger.isTraceEnabled()) { - logger.trace("setConfirmationWindowSize(" + confirmationWindowSize + ")"); - } + logger.trace("setConfirmationWindowSize({})", confirmationWindowSize); + hasBeenUpdated = true; this.confirmationWindowSize = confirmationWindowSize; } @@ -428,151 +396,131 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getProducerMaxRate() { - if (logger.isTraceEnabled()) { - logger.trace("getProducerMaxRate()"); - } + logger.trace("getProducerMaxRate()"); + return producerMaxRate; } public void setProducerMaxRate(final Integer producerMaxRate) { - if (logger.isTraceEnabled()) { - logger.trace("setProducerMaxRate(" + producerMaxRate + ")"); - } + logger.trace("setProducerMaxRate({})", producerMaxRate); + hasBeenUpdated = true; this.producerMaxRate = producerMaxRate; } public Integer getProducerWindowSize() { - if (logger.isTraceEnabled()) { - logger.trace("getProducerWindowSize()"); - } + logger.trace("getProducerWindowSize()"); + return producerWindowSize; } public void setProducerWindowSize(final Integer producerWindowSize) { - if (logger.isTraceEnabled()) { - logger.trace("setProducerWindowSize(" + producerWindowSize + ")"); - } + logger.trace("setProducerWindowSize({})", producerWindowSize); + hasBeenUpdated = true; this.producerWindowSize = producerWindowSize; } public Integer getMinLargeMessageSize() { - if (logger.isTraceEnabled()) { - logger.trace("getMinLargeMessageSize()"); - } + logger.trace("getMinLargeMessageSize()"); + return minLargeMessageSize; } public void setMinLargeMessageSize(final Integer minLargeMessageSize) { - if (logger.isTraceEnabled()) { - logger.trace("setMinLargeMessageSize(" + minLargeMessageSize + ")"); - } + logger.trace("setMinLargeMessageSize({})", minLargeMessageSize); + hasBeenUpdated = true; this.minLargeMessageSize = minLargeMessageSize; } public Boolean isBlockOnAcknowledge() { - if (logger.isTraceEnabled()) { - logger.trace("isBlockOnAcknowledge()"); - } + logger.trace("isBlockOnAcknowledge()"); + return blockOnAcknowledge; } public void setBlockOnAcknowledge(final Boolean blockOnAcknowledge) { - if (logger.isTraceEnabled()) { - logger.trace("setBlockOnAcknowledge(" + blockOnAcknowledge + ")"); - } + logger.trace("setBlockOnAcknowledge({})", blockOnAcknowledge); + hasBeenUpdated = true; this.blockOnAcknowledge = blockOnAcknowledge; } public Boolean isBlockOnNonDurableSend() { - if (logger.isTraceEnabled()) { - logger.trace("isBlockOnNonDurableSend()"); - } + logger.trace("isBlockOnNonDurableSend()"); + return blockOnNonDurableSend; } public void setBlockOnNonDurableSend(final Boolean blockOnNonDurableSend) { - if (logger.isTraceEnabled()) { - logger.trace("setBlockOnNonDurableSend(" + blockOnNonDurableSend + ")"); - } + logger.trace("setBlockOnNonDurableSend({})", blockOnNonDurableSend); + hasBeenUpdated = true; this.blockOnNonDurableSend = blockOnNonDurableSend; } public Boolean isBlockOnDurableSend() { - if (logger.isTraceEnabled()) { - logger.trace("isBlockOnDurableSend()"); - } + logger.trace("isBlockOnDurableSend()"); + return blockOnDurableSend; } public void setBlockOnDurableSend(final Boolean blockOnDurableSend) { - if (logger.isTraceEnabled()) { - logger.trace("setBlockOnDurableSend(" + blockOnDurableSend + ")"); - } + logger.trace("setBlockOnDurableSend({})", blockOnDurableSend); + hasBeenUpdated = true; this.blockOnDurableSend = blockOnDurableSend; } public Boolean isAutoGroup() { - if (logger.isTraceEnabled()) { - logger.trace("isAutoGroup()"); - } + logger.trace("isAutoGroup()"); + return autoGroup; } public void setAutoGroup(final Boolean autoGroup) { - if (logger.isTraceEnabled()) { - logger.trace("setAutoGroup(" + autoGroup + ")"); - } + logger.trace("setAutoGroup({})", autoGroup); + hasBeenUpdated = true; this.autoGroup = autoGroup; } public Boolean isPreAcknowledge() { - if (logger.isTraceEnabled()) { - logger.trace("isPreAcknowledge()"); - } + logger.trace("isPreAcknowledge()"); + return preAcknowledge; } public void setPreAcknowledge(final Boolean preAcknowledge) { - if (logger.isTraceEnabled()) { - logger.trace("setPreAcknowledge(" + preAcknowledge + ")"); - } + logger.trace("setPreAcknowledge({})", preAcknowledge); + hasBeenUpdated = true; this.preAcknowledge = preAcknowledge; } public Long getRetryInterval() { - if (logger.isTraceEnabled()) { - logger.trace("getRetryInterval()"); - } + logger.trace("getRetryInterval()"); + return retryInterval; } public void setRetryInterval(final Long retryInterval) { - if (logger.isTraceEnabled()) { - logger.trace("setRetryInterval(" + retryInterval + ")"); - } + logger.trace("setRetryInterval({})", retryInterval); + hasBeenUpdated = true; this.retryInterval = retryInterval; } public Double getRetryIntervalMultiplier() { - if (logger.isTraceEnabled()) { - logger.trace("getRetryIntervalMultiplier()"); - } + logger.trace("getRetryIntervalMultiplier()"); + return retryIntervalMultiplier; } public void setRetryIntervalMultiplier(final Double retryIntervalMultiplier) { - if (logger.isTraceEnabled()) { - logger.trace("setRetryIntervalMultiplier(" + retryIntervalMultiplier + ")"); - } + logger.trace("setRetryIntervalMultiplier({})", retryIntervalMultiplier); + hasBeenUpdated = true; this.retryIntervalMultiplier = retryIntervalMultiplier; } @@ -587,91 +535,79 @@ public class ConnectionFactoryProperties implements ConnectionFactoryOptions { } public Integer getReconnectAttempts() { - if (logger.isTraceEnabled()) { - logger.trace("getReconnectAttempts()"); - } + logger.trace("getReconnectAttempts()"); + return reconnectAttempts; } public void setReconnectAttempts(final Integer reconnectAttempts) { - if (logger.isTraceEnabled()) { - logger.trace("setReconnectAttempts(" + reconnectAttempts + ")"); - } + logger.trace("setReconnectAttempts({})", reconnectAttempts); + hasBeenUpdated = true; this.reconnectAttempts = reconnectAttempts; } public Boolean isUseGlobalPools() { - if (logger.isTraceEnabled()) { - logger.trace("isUseGlobalPools()"); - } + logger.trace("isUseGlobalPools()"); + return useGlobalPools; } public void setUseGlobalPools(final Boolean useGlobalPools) { - if (logger.isTraceEnabled()) { - logger.trace("setUseGlobalPools(" + useGlobalPools + ")"); - } + logger.trace("setUseGlobalPools({})", useGlobalPools); + hasBeenUpdated = true; this.useGlobalPools = useGlobalPools; } public Boolean isCacheDestinations() { - if (logger.isTraceEnabled()) { - logger.trace("isCacheDestinations()"); - } + logger.trace("isCacheDestinations()"); + return cacheDestinations; } public void setCacheDestinations(final Boolean cacheDestinations) { - if (logger.isTraceEnabled()) { - logger.trace("setCacheDestinations(" + cacheDestinations + ")"); - } + logger.trace("setCacheDestinations({})", cacheDestinations); + hasBeenUpdated = true; this.cacheDestinations = cacheDestinations; } public Boolean isEnable1xPrefixes() { - if (logger.isTraceEnabled()) { - logger.trace("isEnable1xPrefixes()"); - } + logger.trace("isEnable1xPrefixes()"); + return enable1xPrefixes; } public void setEnable1xPrefixes(final Boolean enable1xPrefixes) { - if (logger.isTraceEnabled()) { - logger.trace("setEnable1xPrefixes(" + enable1xPrefixes + ")"); - } + logger.trace("setEnable1xPrefixes({})", enable1xPrefixes); + hasBeenUpdated = true; this.enable1xPrefixes = enable1xPrefixes; } public Integer getScheduledThreadPoolMaxSize() { - if (logger.isTraceEnabled()) { - logger.trace("getScheduledThreadPoolMaxSize()"); - } + logger.trace("getScheduledThreadPoolMaxSize()"); + return scheduledThreadPoolMaxSize; } public void setScheduledThreadPoolMaxSize(final Integer scheduledThreadPoolMaxSize) { - if (logger.isTraceEnabled()) { - logger.trace("setScheduledThreadPoolMaxSize(" + scheduledThreadPoolMaxSize + ")"); - } + logger.trace("setScheduledThreadPoolMaxSize({})", scheduledThreadPoolMaxSize); + hasBeenUpdated = true; this.scheduledThreadPoolMaxSize = scheduledThreadPoolMaxSize; } public Integer getThreadPoolMaxSize() { - if (logger.isTraceEnabled()) { - logger.trace("getThreadPoolMaxSize()"); - } + logger.trace("getThreadPoolMaxSize()"); + return threadPoolMaxSize; } public void setThreadPoolMaxSize(final Integer threadPoolMaxSize) { - if (logger.isTraceEnabled()) { - logger.trace("setThreadPoolMaxSize(" + threadPoolMaxSize + ")"); - } + logger.trace("setThreadPoolMaxSize({})", threadPoolMaxSize); + hasBeenUpdated = true; this.threadPoolMaxSize = threadPoolMaxSize; } diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java index 9eac12d2a5..e9b67cd2da 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java @@ -154,7 +154,7 @@ public class ActiveMQActivation { spec.validate(); if (logger.isTraceEnabled()) { - logger.trace("constructor(" + ra + ", " + endpointFactory + ", " + spec + ")"); + logger.trace("constructor({}, {}, {})", ra, endpointFactory, spec); } String pass = spec.getOwnPassword(); @@ -182,9 +182,7 @@ public class ActiveMQActivation { * @return The value */ public ActiveMQActivationSpec getActivationSpec() { - if (logger.isTraceEnabled()) { - logger.trace("getActivationSpec()"); - } + logger.trace("getActivationSpec()"); return spec; } @@ -195,9 +193,7 @@ public class ActiveMQActivation { * @return The value */ public MessageEndpointFactory getMessageEndpointFactory() { - if (logger.isTraceEnabled()) { - logger.trace("getMessageEndpointFactory()"); - } + logger.trace("getMessageEndpointFactory()"); return endpointFactory; } @@ -208,9 +204,7 @@ public class ActiveMQActivation { * @return The value */ public boolean isDeliveryTransacted() { - if (logger.isTraceEnabled()) { - logger.trace("isDeliveryTransacted()"); - } + logger.trace("isDeliveryTransacted()"); return isDeliveryTransacted; } @@ -221,9 +215,7 @@ public class ActiveMQActivation { * @return The value */ public WorkManager getWorkManager() { - if (logger.isTraceEnabled()) { - logger.trace("getWorkManager()"); - } + logger.trace("getWorkManager()"); return ra.getWorkManager(); } @@ -234,9 +226,7 @@ public class ActiveMQActivation { * @return The value */ public boolean isTopic() { - if (logger.isTraceEnabled()) { - logger.trace("isTopic()"); - } + logger.trace("isTopic()"); return isTopic; } @@ -247,9 +237,8 @@ public class ActiveMQActivation { * @throws ResourceException Thrown if an error occurs */ public void start() throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("start()"); - } + logger.trace("start()"); + deliveryActive.set(true); scheduleWork(new SetupActivation()); } @@ -286,9 +275,7 @@ public class ActiveMQActivation { * Stop the activation */ public void stop() { - if (logger.isTraceEnabled()) { - logger.trace("stop()"); - } + logger.trace("stop()"); deliveryActive.set(false); teardown(true); @@ -300,7 +287,7 @@ public class ActiveMQActivation { * @throws Exception Thrown if an error occurs */ protected synchronized void setup() throws Exception { - logger.debug("Setting up " + spec); + logger.debug("Setting up {}", spec); setupCF(); @@ -360,7 +347,7 @@ public class ActiveMQActivation { factory.getServerLocator().addClusterTopologyListener(new RebalancingListener()); } - logger.debug("Setup complete " + this); + logger.debug("Setup complete {}", this); } /** @@ -370,7 +357,7 @@ public class ActiveMQActivation { synchronized (teardownLock) { - logger.debug("Tearing down " + spec); + logger.debug("Tearing down {}", spec); long timeout = factory == null ? ActiveMQClient.DEFAULT_CALL_TIMEOUT : factory.getCallTimeout(); @@ -460,7 +447,7 @@ public class ActiveMQActivation { nodes.clear(); lastReceived = false; - logger.debug("Tearing down complete " + this); + logger.debug("Tearing down complete {}", this); } } @@ -507,7 +494,7 @@ public class ActiveMQActivation { result.addMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID); } - logger.debug("Using queue connection " + result); + logger.debug("Using queue connection {}", result); return result; } catch (Throwable t) { @@ -540,14 +527,12 @@ public class ActiveMQActivation { } else { ctx = new InitialContext(spec.getParsedJndiParams()); } - logger.debug("Using context " + ctx.getEnvironment() + " for " + spec); - if (logger.isTraceEnabled()) { - logger.trace("setupDestination(" + ctx + ")"); - } + logger.debug("Using context {} for {}", ctx.getEnvironment(), spec); + logger.trace("setupDestination({})", ctx); String destinationTypeString = spec.getDestinationType(); if (destinationTypeString != null && !destinationTypeString.trim().equals("")) { - logger.debug("Destination type defined as " + destinationTypeString); + logger.debug("Destination type defined as {}", destinationTypeString); Class destinationType; if (Topic.class.getName().equals(destinationTypeString)) { @@ -557,7 +542,7 @@ public class ActiveMQActivation { destinationType = Queue.class; } - logger.debug("Retrieving " + destinationType.getName() + " \"" + destinationName + "\" from JNDI"); + logger.debug("Retrieving {} \"{}\" from JNDI", destinationType.getName(), destinationName); try { destination = (ActiveMQDestination) ActiveMQRaUtils.lookup(ctx, destinationName, destinationType); @@ -584,7 +569,7 @@ public class ActiveMQActivation { } } else { logger.debug("Destination type not defined in MDB activation configuration."); - logger.debug("Retrieving " + Destination.class.getName() + " \"" + destinationName + "\" from JNDI"); + logger.debug("Retrieving {} \"{}\" from JNDI", Destination.class.getName(), destinationName); destination = (ActiveMQDestination) ActiveMQRaUtils.lookup(ctx, destinationName, Destination.class); if (destination instanceof Topic) { @@ -656,9 +641,8 @@ public class ActiveMQActivation { } public void startReconnectThread(final String cause) { - if (logger.isTraceEnabled()) { - logger.trace("Starting reconnect Thread " + cause + " on MDB activation " + this); - } + logger.trace("Starting reconnect Thread {} on MDB activation {}", cause, this); + try { // We have to use the worker otherwise we may get the wrong classLoader scheduleWork(new ReconnectWork(cause)); @@ -698,9 +682,8 @@ public class ActiveMQActivation { * @param failure if reconnecting in the event of a failure */ public void reconnect(Throwable failure, boolean useInterrupt) { - if (logger.isTraceEnabled()) { - logger.trace("reconnecting activation " + this); - } + logger.trace("reconnecting activation {}", this); + if (failure != null) { if (failure instanceof ActiveMQException && ((ActiveMQException) failure).getType() == ActiveMQExceptionType.QUEUE_DOES_NOT_EXIST) { ActiveMQRALogger.LOGGER.awaitingTopicQueueCreation(getActivationSpec().getDestination()); @@ -725,7 +708,7 @@ public class ActiveMQActivation { try { Thread.sleep(setupInterval); } catch (InterruptedException e) { - logger.debug("Interrupted trying to reconnect " + spec, e); + logger.debug("Interrupted trying to reconnect {}", spec, e); break; } 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 0bbf61bd57..ad29c1147a 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 @@ -148,9 +148,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * Constructor */ public ActiveMQActivationSpec() { - if (logger.isTraceEnabled()) { - logger.trace("constructor()"); - } + logger.trace("constructor()"); // we create an Adapter here but only for Application Servers that do introspection on loading to avoid an NPE ra = new ActiveMQResourceAdapter(); @@ -173,9 +171,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen */ @Override public ResourceAdapter getResourceAdapter() { - if (logger.isTraceEnabled()) { - logger.trace("getResourceAdapter()"); - } + logger.trace("getResourceAdapter()"); return ra; } @@ -227,9 +223,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen */ @Override public void setResourceAdapter(final ResourceAdapter ra) throws ResourceException { - if (logger.isTraceEnabled()) { - logger.trace("setResourceAdapter(" + ra + ")"); - } + logger.trace("setResourceAdapter({})", ra); if (ra == null || !(ra instanceof ActiveMQResourceAdapter)) { throw new ResourceException("Resource adapter is " + ra); @@ -244,9 +238,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public String getConnectionFactoryLookup() { - if (logger.isTraceEnabled()) { - logger.trace("getConnectionFactoryLookup() ->" + connectionFactoryLookup); - } + logger.trace("getConnectionFactoryLookup() ->{}", connectionFactoryLookup); return connectionFactoryLookup; } @@ -257,9 +249,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setConnectionFactoryLookup(final String value) { - if (logger.isTraceEnabled()) { - logger.trace("setConnectionFactoryLookup(" + value + ")"); - } + logger.trace("setConnectionFactoryLookup({})", value); connectionFactoryLookup = value; } @@ -270,9 +260,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public String getDestination() { - if (logger.isTraceEnabled()) { - logger.trace("getDestination()"); - } + logger.trace("getDestination()"); return destination; } @@ -283,9 +271,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setDestination(final String value) { - if (logger.isTraceEnabled()) { - logger.trace("setDestination(" + value + ")"); - } + logger.trace("setDestination({})", value); destination = value; } @@ -315,9 +301,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public String getDestinationType() { - if (logger.isTraceEnabled()) { - logger.trace("getDestinationType()"); - } + logger.trace("getDestinationType()"); return destinationType; } @@ -328,9 +312,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setDestinationType(final String value) { - if (logger.isTraceEnabled()) { - logger.trace("setDestinationType(" + value + ")"); - } + logger.trace("setDestinationType({})", value); destinationType = value; } @@ -341,9 +323,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public String getMessageSelector() { - if (logger.isTraceEnabled()) { - logger.trace("getMessageSelector()"); - } + logger.trace("getMessageSelector()"); return messageSelector; } @@ -354,9 +334,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setMessageSelector(final String value) { - if (logger.isTraceEnabled()) { - logger.trace("setMessageSelector(" + value + ")"); - } + logger.trace("setMessageSelector({})", value); messageSelector = value; } @@ -367,9 +345,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public String getAcknowledgeMode() { - if (logger.isTraceEnabled()) { - logger.trace("getAcknowledgeMode()"); - } + logger.trace("getAcknowledgeMode()"); if (Session.DUPS_OK_ACKNOWLEDGE == acknowledgeMode) { return "Dups-ok-acknowledge"; @@ -401,9 +377,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setAcknowledgeMode(final String value) { - if (logger.isTraceEnabled()) { - logger.trace("setAcknowledgeMode(" + value + ")"); - } + logger.trace("setAcknowledgeMode({})", value); try { this.acknowledgeMode = ActiveMQActivationValidationUtils.validateAcknowledgeMode(value); @@ -417,9 +391,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return the acknowledgement mode */ public Integer getAcknowledgeModeInt() { - if (logger.isTraceEnabled()) { - logger.trace("getAcknowledgeMode()"); - } + logger.trace("getAcknowledgeMode()"); return acknowledgeMode; } @@ -430,9 +402,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public String getSubscriptionDurability() { - if (logger.isTraceEnabled()) { - logger.trace("getSubscriptionDurability()"); - } + logger.trace("getSubscriptionDurability()"); if (subscriptionDurability) { return "Durable"; @@ -447,9 +417,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setSubscriptionDurability(final String value) { - if (logger.isTraceEnabled()) { - logger.trace("setSubscriptionDurability(" + value + ")"); - } + logger.trace("setSubscriptionDurability({})", value); subscriptionDurability = "Durable".equals(value); } @@ -460,9 +428,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public Boolean isSubscriptionDurable() { - if (logger.isTraceEnabled()) { - logger.trace("isSubscriptionDurable()"); - } + logger.trace("isSubscriptionDurable()"); return subscriptionDurability; } @@ -473,9 +439,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public String getSubscriptionName() { - if (logger.isTraceEnabled()) { - logger.trace("getSubscriptionName()"); - } + logger.trace("getSubscriptionName()"); return subscriptionName; } @@ -486,9 +450,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setSubscriptionName(final String value) { - if (logger.isTraceEnabled()) { - logger.trace("setSubscriptionName(" + value + ")"); - } + logger.trace("setSubscriptionName({})", value); subscriptionName = value; } @@ -497,9 +459,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return the shareDurableSubscriptions */ public Boolean isShareSubscriptions() { - if (logger.isTraceEnabled()) { - logger.trace("isShareSubscriptions() = " + shareSubscriptions); - } + logger.trace("isShareSubscriptions() = {}", shareSubscriptions); return shareSubscriptions; } @@ -508,9 +468,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param shareSubscriptions the shareDurableSubscriptions to set */ public void setShareSubscriptions(final Boolean shareSubscriptions) { - if (logger.isTraceEnabled()) { - logger.trace("setShareSubscriptions(" + shareSubscriptions + ")"); - } + logger.trace("setShareSubscriptions({})", shareSubscriptions); this.shareSubscriptions = shareSubscriptions; } @@ -521,9 +479,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public String getUser() { - if (logger.isTraceEnabled()) { - logger.trace("getUser()"); - } + logger.trace("getUser()"); if (user == null) { return ra.getUserName(); @@ -538,9 +494,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setUser(final String value) { - if (logger.isTraceEnabled()) { - logger.trace("setUser(" + value + ")"); - } + logger.trace("setUser()", value); user = value; } @@ -551,9 +505,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public String getPassword() { - if (logger.isTraceEnabled()) { - logger.trace("getPassword()"); - } + logger.trace("getPassword()"); if (password == null) { return ra.getPassword(); @@ -572,9 +524,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setPassword(final String value) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("setPassword(****)"); - } + logger.trace("setPassword(****)"); password = value; } @@ -585,9 +535,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public Integer getMaxSession() { - if (logger.isTraceEnabled()) { - logger.trace("getMaxSession()"); - } + logger.trace("getMaxSession()"); if (maxSession == null) { return DEFAULT_MAX_SESSION; @@ -602,9 +550,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setMaxSession(final Integer value) { - if (logger.isTraceEnabled()) { - logger.trace("setMaxSession(" + value + ")"); - } + logger.trace("setMaxSession({})", value); if ( value < 1 ) { maxSession = 1; @@ -619,9 +565,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public Boolean isSingleConnection() { - if (logger.isTraceEnabled()) { - logger.trace("getSingleConnection()"); - } + logger.trace("getSingleConnection()"); if (singleConnection == null) { return DEFAULT_SINGLE_CONNECTION; @@ -636,9 +580,8 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setSingleConnection(final Boolean value) { - if (logger.isTraceEnabled()) { - logger.trace("setSingleConnection(" + value + ")"); - } + logger.trace("setSingleConnection({})", value); + singleConnection = value; } @@ -648,9 +591,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @return The value */ public Integer getTransactionTimeout() { - if (logger.isTraceEnabled()) { - logger.trace("getTransactionTimeout()"); - } + logger.trace("getTransactionTimeout()"); return transactionTimeout; } @@ -661,9 +602,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen * @param value The value */ public void setTransactionTimeout(final Integer value) { - if (logger.isTraceEnabled()) { - logger.trace("setTransactionTimeout(" + value + ")"); - } + logger.trace("setTransactionTimeout({})", value); transactionTimeout = value; } @@ -689,9 +628,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen } public Integer getSetupAttempts() { - if (logger.isTraceEnabled()) { - logger.trace("getSetupAttempts()"); - } + logger.trace("getSetupAttempts()"); if (setupAttempts == null) { return ra.getSetupAttempts(); @@ -701,17 +638,13 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen } public void setSetupAttempts(final Integer setupAttempts) { - if (logger.isTraceEnabled()) { - logger.trace("setSetupAttempts(" + setupAttempts + ")"); - } + logger.trace("setSetupAttempts({})", setupAttempts); this.setupAttempts = setupAttempts; } public Long getSetupInterval() { - if (logger.isTraceEnabled()) { - logger.trace("getSetupInterval()"); - } + logger.trace("getSetupInterval()"); if (setupInterval == null) { return ra.getSetupInterval(); @@ -721,9 +654,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen } public void setSetupInterval(final Long setupInterval) { - if (logger.isTraceEnabled()) { - logger.trace("setSetupInterval(" + setupInterval + ")"); - } + logger.trace("setSetupInterval({})", setupInterval); this.setupInterval = setupInterval; } @@ -740,9 +671,8 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen */ @Override public void validate() throws InvalidPropertyException { - if (logger.isTraceEnabled()) { - logger.trace("validate()"); - } + logger.trace("validate()"); + ActiveMQActivationValidationUtils.validate(destination, destinationType, isSubscriptionDurable(), subscriptionName); } @@ -751,9 +681,7 @@ public class ActiveMQActivationSpec extends ConnectionFactoryProperties implemen } public void setConnectorClassName(final String connectorClassName) { - if (logger.isTraceEnabled()) { - logger.trace("setConnectorClassName(" + connectorClassName + ")"); - } + logger.trace("setConnectorClassName({})", connectorClassName); strConnectorClassName = connectorClassName; diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java index 80beaa5108..92acf94f0a 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java @@ -111,9 +111,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList } public void setup() throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("setup()"); - } + logger.trace("setup()"); this.enable1XPrefix = activation.getConnectionFactory().isEnable1xPrefixes(); @@ -136,7 +134,8 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList if (!spec.isShareSubscriptions()) { throw ActiveMQRALogger.LOGGER.canNotCreatedNonSharedSubscriber(); } else if (logger.isDebugEnabled()) { - logger.debug("the mdb on destination " + queueName + " already had " + subResponse.getConsumerCount() + " consumers but the MDB is configured to share subscriptions, so no exceptions are thrown"); + logger.debug("the mdb on destination {} already had {} consumers but the MDB is configured to share subscriptions, so no exceptions are thrown", + queueName, subResponse.getConsumerCount()); } } @@ -230,9 +229,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList * Stop the handler */ public void teardown() { - if (logger.isTraceEnabled()) { - logger.trace("teardown()"); - } + logger.trace("teardown()"); try { if (endpoint != null) { @@ -240,7 +237,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList endpoint = null; } } catch (Throwable t) { - logger.debug("Error releasing endpoint " + endpoint, t); + logger.debug("Error releasing endpoint {}", endpoint, t); } //only do this if we haven't been disconnected at some point whilst failing over @@ -266,14 +263,14 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList session.close(); } } catch (Throwable t) { - logger.debug("Error releasing session " + session, t); + logger.debug("Error releasing session {}", session, t); } try { if (cf != null) { cf.close(); } } catch (Throwable t) { - logger.debug("Error releasing session factory " + session, t); + logger.debug("Error releasing session factory {}", session, t); } } else { //otherwise we just clean up @@ -282,7 +279,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList cf.cleanup(); } } catch (Throwable t) { - logger.debug("Error releasing session factory " + session, t); + logger.debug("Error releasing session factory {}", session, t); } } @@ -290,9 +287,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList @Override public void onMessage(final ClientMessage message) { - if (logger.isTraceEnabled()) { - logger.trace("onMessage(" + message + ")"); - } + logger.trace("onMessage({})", message); ActiveMQMessage msg; if (enable1XPrefix) { @@ -308,9 +303,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList tm.setTransactionTimeout(activation.getActivationSpec().getTransactionTimeout()); } - if (logger.isTraceEnabled()) { - logger.trace("ActiveMQMessageHandler::calling beforeDelivery on message " + message); - } + logger.trace("ActiveMQMessageHandler::calling beforeDelivery on message {}", message); endpoint.beforeDelivery(ActiveMQActivation.ONMESSAGE); beforeDelivery = true; @@ -328,9 +321,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList message.individualAcknowledge(); } - if (logger.isTraceEnabled()) { - logger.trace("ActiveMQMessageHandler::calling afterDelivery on message " + message); - } + logger.trace("ActiveMQMessageHandler::calling afterDelivery on message {}", message); try { endpoint.afterDelivery(); @@ -346,9 +337,7 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList session.commit(); } - if (logger.isTraceEnabled()) { - logger.trace("finished onMessage on " + message); - } + logger.trace("finished onMessage on {}", message); } catch (Throwable e) { ActiveMQRALogger.LOGGER.errorDeliveringMessage(e); // we need to call before/afterDelivery as a pair diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java index 00047feac3..9548d82670 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/recovery/RecoveryManager.java @@ -51,7 +51,7 @@ public final class RecoveryManager { String userName, String password, Map properties) { - logger.debug("registering recovery for factory : " + factory); + logger.debug("registering recovery for factory : {}", factory); XARecoveryConfig config = XARecoveryConfig.newConfig(factory, userName, password, properties); resources.add(config); @@ -90,7 +90,7 @@ public final class RecoveryManager { registry = ActiveMQRegistryImpl.getInstance(); } } catch (Throwable e) { - logger.debug("unable to load recovery registry " + locatorClasse, e); + logger.debug("unable to load recovery registry {}", locatorClasse, e); } if (registry != null) { break; @@ -98,7 +98,7 @@ public final class RecoveryManager { } if (registry != null) { - logger.debug("Recovery Registry located = " + registry); + logger.debug("Recovery Registry located = {}", registry); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java index 5f1793554f..b67f42242b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java @@ -526,7 +526,7 @@ public class ConfigurationImpl implements Configuration, Serializable { String value = XMLUtil.replaceSystemPropsInString(entry.getValue().toString()); value = PasswordMaskingUtil.resolveMask(isMaskPassword(), value, getPasswordCodec()); key = XMLUtil.replaceSystemPropsInString(key); - logger.debug("Property config, " + key + "=" + value); + logger.debug("Property config, {}={}", key, value); beanProperties.put(key, value); } } @@ -3024,7 +3024,9 @@ public class ConfigurationImpl implements Configuration, Serializable { return instance; } catch (Exception e) { - logger.debug("Failed to add entry for " + name + " with method: " + candidate, e); + if (logger.isDebugEnabled()) { + logger.debug("Failed to add entry for {} with method: {}", name, candidate, e); + } throw new IllegalArgumentException("failed to add entry for collection key " + name, e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/LegacyJMSConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/LegacyJMSConfiguration.java index 43c58a7175..ec25936f99 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/LegacyJMSConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/LegacyJMSConfiguration.java @@ -125,7 +125,7 @@ public class LegacyJMSConfiguration implements Deployable { Node node = children.item(i); Node keyNode = node.getAttributes().getNamedItem(NAME_ATTR); if (keyNode == null) { - logger.warn("Configuration missing jms key " + node); + logger.warn("Configuration missing jms key {}", node); continue; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java index abc2478d35..4abeda8ab1 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java @@ -2077,9 +2077,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { ClusterConnectionConfiguration config = mainConfig.addClusterConfiguration(name, uri); - if (logger.isDebugEnabled()) { - logger.debug("Adding cluster connection :: " + config); - } + logger.debug("Adding cluster connection :: {}", config); } private void parseAMQPBrokerConnections(final Element e, @@ -2139,9 +2137,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { } } - if (logger.isDebugEnabled()) { - logger.debug("Adding AMQP connection :: " + config); - } + logger.debug("Adding AMQP connection :: {}", config); } private void parseClusterConnectionConfiguration(final Element e, final Configuration mainConfig) throws Exception { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java index 29d8b1d623..5448e28222 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/filter/impl/FilterImpl.java @@ -86,9 +86,7 @@ public class FilterImpl implements Filter { booleanExpression = SelectorParser.parse(filterStr.toString()); } catch (Throwable e) { ActiveMQServerLogger.LOGGER.invalidFilter(filterStr); - if (logger.isDebugEnabled()) { - logger.debug("Invalid filter", e); - } + logger.debug("Invalid filter", e); throw ActiveMQMessageBundle.BUNDLE.invalidFilter(filterStr, e); } return new FilterImpl(filterStr, booleanExpression); @@ -123,9 +121,7 @@ public class FilterImpl implements Filter { return booleanExpression.matches(filterable); } catch (Exception e) { ActiveMQServerLogger.LOGGER.invalidFilter(sfilterString); - if (logger.isDebugEnabled()) { - logger.debug("Invalid filter", e); - } + logger.debug("Invalid filter", e); return false; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java index d50016fd8b..de0066dcd1 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java @@ -4612,9 +4612,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active try { return getEmbeddedWebServerComponent().isStarted(); } catch (Exception e) { - if (logger.isTraceEnabled()) { - logger.trace(e.getMessage()); - } + logger.trace(e.getMessage()); return false; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java index e4ee0bfd78..55c38c820a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/PagedReferenceImpl.java @@ -225,7 +225,7 @@ public class PagedReferenceImpl extends LinkedListImpl.Node public void incrementDeliveryCount() { DELIVERY_COUNT_UPDATER.incrementAndGet(this); if (logger.isTraceEnabled()) { - logger.trace("++deliveryCount = " + deliveryCount + " for " + this, new Exception("trace")); + logger.trace("++deliveryCount = {} for {}", deliveryCount, this, new Exception("trace")); } } @@ -233,7 +233,7 @@ public class PagedReferenceImpl extends LinkedListImpl.Node public void decrementDeliveryCount() { DELIVERY_COUNT_UPDATER.decrementAndGet(this); if (logger.isTraceEnabled()) { - logger.trace("--deliveryCount = " + deliveryCount + " for " + this, new Exception("trace")); + logger.trace("--deliveryCount = {} for {}", deliveryCount, this, new Exception("trace")); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java index 7d784792d1..deeb3ee27e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageCursorProviderImpl.java @@ -45,10 +45,8 @@ import java.lang.invoke.MethodHandles; public class PageCursorProviderImpl implements PageCursorProvider { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - /** * As an optimization, avoid subsequent schedules as they are unnecessary */ @@ -71,18 +69,16 @@ public class PageCursorProviderImpl implements PageCursorProvider { //storageManager.beforePageRead will be attempted in a loop, printing at intervals a warn message private static final long PAGE_READ_PERMISSION_TIMEOUT_NS = TimeUnit.SECONDS.toNanos(10); - public PageCursorProviderImpl(final PagingStore pagingStore, final StorageManager storageManager) { this.pagingStore = pagingStore; this.storageManager = storageManager; } - @Override public synchronized PageSubscription createSubscription(long cursorID, Filter filter, boolean persistent) { if (logger.isTraceEnabled()) { - logger.trace(this.pagingStore.getAddress() + " creating subscription " + cursorID + " with filter " + filter); + logger.trace("{} creating subscription {} {} with filter {}", this.pagingStore.getAddress(), cursorID, filter); } if (activeCursors.containsKey(cursorID)) { @@ -261,7 +257,9 @@ public class PageCursorProviderImpl implements PageCursorProvider { final long firstPage = pagingStore.getFirstPage(); deliverIfNecessary(cursorList, minPage); - logger.trace("firstPage={}, minPage={}, currentWritingPage={}", firstPage, minPage, pagingStore.getCurrentWritingPage()); + if (logger.isTraceEnabled()) { + logger.trace("firstPage={}, minPage={}, currentWritingPage={}", firstPage, minPage, pagingStore.getCurrentWritingPage()); + } // First we cleanup regular streaming, at the beginning of set of files cleanupRegularStream(depagedPages, depagedPagesSet, cursorList, minPage, firstPage); @@ -276,7 +274,8 @@ public class PageCursorProviderImpl implements PageCursorProvider { pagingStore.stopPaging(); } else { if (logger.isTraceEnabled()) { - logger.trace("Couldn't cleanup page on address " + this.pagingStore.getAddress() + " as numberOfPages == " + pagingStore.getNumberOfPages() + " and currentPage.numberOfMessages = " + pagingStore.getCurrentPage().getNumberOfMessages()); + logger.trace("Couldn't cleanup page on address {} as numberOfPages == {} and currentPage.numberOfMessages = {}", + pagingStore.getAddress(), pagingStore.getNumberOfPages(), pagingStore.getCurrentPage().getNumberOfMessages()); } } } catch (Throwable ex) { @@ -329,9 +328,11 @@ public class PageCursorProviderImpl implements PageCursorProvider { if (page == null) { break; } + if (logger.isDebugEnabled()) { - logger.debug("Depaging page " + page.getPageId()); + logger.debug("Depaging page {}", page.getPageId()); } + depagedPagesSet.add(page.getPageId()); depagedPages.add(page); } @@ -374,7 +375,9 @@ public class PageCursorProviderImpl implements PageCursorProvider { if (counter.get() >= subscriptions) { if (!depagedPagesSet.contains(pageID.longValue())) { Page page = pagingStore.removePage(pageID.intValue()); - logger.debug("Removing page {}", pageID); + if (logger.isDebugEnabled()) { + logger.debug("Removing page {}", pageID); + } if (page != null) { depagedPages.add(page); depagedPagesSet.add(page.getPageId()); @@ -383,18 +386,15 @@ public class PageCursorProviderImpl implements PageCursorProvider { } } } catch (Throwable e) { - logger.warn("Error while Issuing cleanupMiddlePages with " + pageID + ", counter = " + counter, e); - depagedPages.forEach(p -> logger.warn("page " + p)); + logger.warn("Error while Issuing cleanupMiddlePages with {}, counter = {}", pageID, counter, e); + depagedPages.forEach(p -> logger.warn("page {}", p)); } }); } // Protected as a way to inject testing protected void cleanupComplete(ArrayList cursorList) throws Exception { - if (logger.isDebugEnabled()) { - logger.debug("Address " + pagingStore.getAddress() + - " is leaving page mode as all messages are consumed and acknowledged from the page store"); - } + logger.debug("Address {} is leaving page mode as all messages are consumed and acknowledged from the page store", pagingStore.getAddress()); pagingStore.forceAnotherPage(); @@ -445,14 +445,14 @@ public class PageCursorProviderImpl implements PageCursorProvider { for (PageSubscription cursor : cursorList) { if (!cursor.isComplete(minPage)) { if (logger.isTraceEnabled()) { - logger.trace("Cursor " + cursor + " was considered incomplete at pageNr=" + minPage); + logger.trace("Cursor {} was considered incomplete at pageNr={}", cursor, minPage); } complete = false; break; } else { if (logger.isTraceEnabled()) { - logger.trace("Cursor " + cursor + " was considered **complete** at pageNr=" + minPage); + logger.trace("Cursor {} was considered **complete** at pageNr={}", cursor, minPage); } } } @@ -508,7 +508,7 @@ public class PageCursorProviderImpl implements PageCursorProvider { for (PageSubscription cursor : cursorList) { long firstPage = cursor.getFirstPage(); if (logger.isTraceEnabled()) { - logger.trace(this.pagingStore.getAddress() + " has a cursor " + cursor + " with first page=" + firstPage); + logger.trace("{} has a cursor {} with first page={}", pagingStore.getAddress(), cursor, firstPage); } // the cursor will return -1 if the cursor is empty @@ -517,7 +517,9 @@ public class PageCursorProviderImpl implements PageCursorProvider { } } - logger.trace("checkMinPage({}) will have minPage={}", pagingStore.getAddress(), minPage); + if (logger.isTraceEnabled()) { + logger.trace("checkMinPage({}) will have minPage={}", pagingStore.getAddress(), minPage); + } return minPage; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java index 1cd294c5c8..0e7ab26dd0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionCounterImpl.java @@ -351,7 +351,8 @@ public class PageSubscriptionCounterImpl implements PageSubscriptionCounter { newRecordID = storage.storePageCounter(txCleanup, subscriptionID, valueReplace, sizeReplace); if (logger.isTraceEnabled()) { - logger.trace("Replacing page-counter record = " + recordID + " by record = " + newRecordID + " on subscriptionID = " + this.subscriptionID + " for queue = " + this.subscription.getQueue().getName()); + logger.trace("Replacing page-counter record = {} by record = {} on subscriptionID = {} for queue = {}", + recordID, newRecordID, subscriptionID, subscription.getQueue().getName()); } storage.commit(txCleanup); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java index 2e9bd25443..424e2e795b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java @@ -832,9 +832,8 @@ public final class PageSubscriptionImpl implements PageSubscription { @Override public void processReload() throws Exception { if (recoveredACK != null) { - if (logger.isTraceEnabled()) { - logger.trace("********** processing reload!!!!!!!"); - } + logger.trace("********** processing reload!!!!!!!"); + Collections.sort(recoveredACK); long txDeleteCursorOnReload = -1; @@ -937,13 +936,10 @@ public final class PageSubscriptionImpl implements PageSubscription { // The only exception is on non storage events such as not matching messages private PageCursorInfo processACK(final PagePosition pos) { if (lastAckedPosition == null || pos.compareTo(lastAckedPosition) > 0) { - if (logger.isTraceEnabled()) { - logger.trace("a new position is being processed as ACK"); - } + logger.trace("a new position is being processed as ACK"); + if (lastAckedPosition != null && lastAckedPosition.getPageNr() != pos.getPageNr()) { - if (logger.isTraceEnabled()) { - logger.trace("Scheduling cleanup on pageSubscription for address = " + pageStore.getAddress() + " queue = " + this.getQueue().getName()); - } + logger.trace("Scheduling cleanup on pageSubscription for address = {} queue = {}", pageStore.getAddress(), getQueue().getName()); // there's a different page being acked, we will do the check right away if (autoCleanup) { @@ -1090,7 +1086,9 @@ public final class PageSubscriptionImpl implements PageSubscription { } this.pageId = pageId; this.numberOfMessages = numberOfMessages; - logger.trace("Created PageCursorInfo for pageNr={}, numberOfMessages={}, not live", pageId, numberOfMessages); + if (logger.isTraceEnabled()) { + logger.trace("Created PageCursorInfo for pageNr={}, numberOfMessages={}, not live", pageId, numberOfMessages); + } } private PageCursorInfo(long pageId) { @@ -1103,7 +1101,10 @@ public final class PageSubscriptionImpl implements PageSubscription { * @param completePage */ public void setCompleteInfo(final PagePosition completePage) { - logger.trace("Setting up complete page {} on cursor {} on subscription {}", completePage, this, PageSubscriptionImpl.this); + if (logger.isTraceEnabled()) { + logger.trace("Setting up complete page {} on cursor {} on subscription {}", completePage, this, PageSubscriptionImpl.this); + } + this.completePage = completePage; } @@ -1114,9 +1115,10 @@ public final class PageSubscriptionImpl implements PageSubscription { @Override public boolean isDone() { if (logger.isTraceEnabled()) { - logger.trace(PageSubscriptionImpl.this + "::PageCursorInfo(" + pageId + ")::isDone checking with completePage!=null->" + (completePage != null) + " getNumberOfMessages=" + getNumberOfMessages() + ", confirmed=" + confirmed.get() + " and pendingTX=" + pendingTX.get()); - + logger.trace("{}::PageCursorInfo({})::isDone checking with completePage!=null->{} getNumberOfMessages={}, confirmed={} and pendingTX={}", + PageSubscriptionImpl.this, pageId, completePage != null, getNumberOfMessages(), confirmed.get(), pendingTX.get()); } + // in cases where the file was damaged it is possible to get more confirmed records than we actually had messages // for that case we set confirmed.get() >= getNumberOfMessages instead of == return completePage != null || (confirmed.get() >= getNumberOfMessages() && pendingTX.get() == 0); @@ -1162,12 +1164,8 @@ public final class PageSubscriptionImpl implements PageSubscription { if (logger.isTraceEnabled()) { try { - logger.trace("numberOfMessages = " + getNumberOfMessages() + - " confirmed = " + - (confirmed.get() + 1) + - " pendingTX = " + pendingTX + - ", pageNr = " + - pageId + " posACK = " + posACK); + logger.trace("numberOfMessages = {} confirmed = {} pendingTX = {}, pageNr = {} posACK = {}", + getNumberOfMessages(), (confirmed.get() + 1), pendingTX, pageId, posACK); } catch (Throwable ignored) { logger.debug(ignored.getMessage(), ignored); } @@ -1289,7 +1287,7 @@ public final class PageSubscriptionImpl implements PageSubscription { } currentPage = pageStore.usePage(page); if (logger.isTraceEnabled()) { - logger.trace("CursorIterator: getting page " + page + " which will contain " + currentPage.getNumberOfMessages()); + logger.trace("CursorIterator: getting page {} which will contain {}", page, currentPage.getNumberOfMessages()); } currentPageIterator = currentPage.iterator(); } catch (Exception e) { @@ -1401,7 +1399,7 @@ public final class PageSubscriptionImpl implements PageSubscription { if (!browsing && info != null && (info.isRemoved(message.getPagedMessage().getMessageNumber()) || info.getCompleteInfo() != null)) { if (logger.isTraceEnabled()) { boolean removed = info.isRemoved(message.getPagedMessage().getMessageNumber()); - logger.trace("CursorIterator::Message from page {} # {} isRemoved={}", message.getPagedMessage().getPageNumber(), message.getPagedMessage().getMessageNumber(), (Boolean)removed); + logger.trace("CursorIterator::Message from page {} # {} isRemoved={}", message.getPagedMessage().getPageNumber(), message.getPagedMessage().getMessageNumber(), removed); } continue; } @@ -1559,7 +1557,7 @@ public final class PageSubscriptionImpl implements PageSubscription { try { return msg != null && msg.getPersistentSize() > 0 ? msg.getPersistentSize() : 0; } catch (ActiveMQException e) { - logger.warn("Error computing persistent size of message: " + msg, e); + logger.warn("Error computing persistent size of message: {}", msg, e); return 0; } } @@ -1568,7 +1566,7 @@ public final class PageSubscriptionImpl implements PageSubscription { try { return ref != null && ref.getPersistentSize() > 0 ? ref.getPersistentSize() : 0; } catch (ActiveMQException e) { - logger.warn("Error computing persistent size of message: " + ref, e); + logger.warn("Error computing persistent size of message: {}", ref, e); return 0; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java index b9d7b8e09b..bb307968bf 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/Page.java @@ -313,7 +313,7 @@ public final class Page { null, null); if (logger.isDebugEnabled()) { - logger.debug(">>> Reading numberOfMessages page " + this.pageId + ", returning " + numberOfMessages); + logger.debug(">>> Reading numberOfMessages page {}, returning {}", this.pageId, numberOfMessages); } return numberOfMessages; } finally { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageCache.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageCache.java index 4ddf57bf12..3072753502 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageCache.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageCache.java @@ -52,7 +52,7 @@ public class PageCache { public synchronized void injectPage(Page page) { if (logger.isDebugEnabled()) { - logger.debug("+++ Injecting page " + page.getPageId() + " on UsedPages for destination " + owner.getAddress()); + logger.debug("+++ Injecting page {} on UsedPages for destination {}", page.getPageId(), owner.getAddress()); } page.releaseTask(this::removePage); usedPages.put(page.getPageId(), page); @@ -62,7 +62,7 @@ public class PageCache { public synchronized void removePage(Page page) { if (usedPages.remove(page.getPageId()) != null) { if (logger.isDebugEnabled()) { - logger.debug("--- Releasing page " + page.getPageId() + " on UsedPages for destination " + owner.getAddress()); + logger.debug("--- Releasing page {} on UsedPages for destination {}", page.getPageId(), owner.getAddress()); } } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java index cf8536cf3e..bd538ef028 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PageTransactionInfoImpl.java @@ -258,34 +258,27 @@ public final class PageTransactionInfoImpl implements PageTransactionInfo { public synchronized boolean deliverAfterCommit(PageIterator iterator, PageSubscription cursor, PagedReference pagedReference) { - - if (logger.isTraceEnabled()) { - logger.trace("deliver after commit on " + cursor + ", pagedReference=" + pagedReference); - } + logger.trace("deliver after commit on {}, pagedReference={}", cursor, pagedReference); if (committed && useRedelivery) { - if (logger.isTraceEnabled()) { - logger.trace("commit & useRedelivery on " + cursor + ", pagedReference=" + pagedReference); - } + logger.trace("commit & useRedelivery on {}, pagedReference={}", cursor, pagedReference); + cursor.addPendingDelivery(pagedReference.getPagedMessage()); cursor.redeliver(iterator, pagedReference); return true; } else if (committed) { - if (logger.isTraceEnabled()) { - logger.trace("committed on " + cursor + ", position=" + pagedReference + ", ignoring position"); - } + logger.trace("committed on {}, position={}, ignoring position", cursor, pagedReference); + return false; } else if (rolledback) { - if (logger.isTraceEnabled()) { - logger.trace("rolled back, position ignored on " + cursor + ", position=" + pagedReference); - } + logger.trace("rolled back, position ignored on {}, position={}", cursor, pagedReference); + cursor.positionIgnored(pagedReference.getPagedMessage().newPositionObject()); onUpdate(1, null, cursor.getPagingStore().getPagingManager()); return true; } else { - if (logger.isTraceEnabled()) { - logger.trace("deliverAftercommit/else, marking useRedelivery on " + cursor + ", position " + pagedReference); - } + logger.trace("deliverAftercommit/else, marking useRedelivery on {}, position {}", cursor, pagedReference); + useRedelivery = true; if (lateDeliveries == null) { lateDeliveries = new LinkedList<>(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java index 35bd40b938..6f59f42f96 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingManagerImpl.java @@ -229,7 +229,9 @@ public final class PagingManagerImpl implements PagingManager { public void tick(long usableSpace, long totalSpace) { diskUsableSpace = usableSpace; diskTotalSpace = totalSpace; - logger.trace("Tick:: usable space at {}, total space at {}", ByteUtil.getHumanReadableByteCount(usableSpace), ByteUtil.getHumanReadableByteCount(totalSpace)); + if (logger.isTraceEnabled()) { + logger.trace("Tick:: usable space at {}, total space at {}", ByteUtil.getHumanReadableByteCount(usableSpace), ByteUtil.getHumanReadableByteCount(totalSpace)); + } } @Override @@ -421,7 +423,7 @@ public final class PagingManagerImpl implements PagingManager { @Override public void addTransaction(final PageTransactionInfo pageTransaction) { if (logger.isTraceEnabled()) { - logger.trace("Adding pageTransaction " + pageTransaction.getTransactionID()); + logger.trace("Adding pageTransaction {}", pageTransaction.getTransactionID()); } transactions.put(pageTransaction.getTransactionID(), pageTransaction); } @@ -429,7 +431,7 @@ public final class PagingManagerImpl implements PagingManager { @Override public void removeTransaction(final long id) { if (logger.isTraceEnabled()) { - logger.trace("Removing pageTransaction " + id); + logger.trace("Removing pageTransaction {}", id); } transactions.remove(id); } @@ -437,7 +439,7 @@ public final class PagingManagerImpl implements PagingManager { @Override public PageTransactionInfo getTransaction(final long id) { if (logger.isTraceEnabled()) { - logger.trace("looking up pageTX = " + id); + logger.trace("looking up pageTX = {}", id); } return transactions.get(id); } @@ -483,7 +485,7 @@ public final class PagingManagerImpl implements PagingManager { } public void debug() { - logger.info("size = " + globalSizeMetric.getSize() + " bytes, messages = " + globalSizeMetric.getElements()); + logger.info("size = {} bytes, messages = {}", globalSizeMetric.getSize(), globalSizeMetric.getElements()); } @Override diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java index f51fc4798c..51411df595 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/impl/PagingStoreImpl.java @@ -720,7 +720,9 @@ public class PagingStoreImpl implements PagingStore { } if (currentPageId == pageId) { - logger.debug("Ignoring remove({}) as this is the current writing page", pageId); + if (logger.isDebugEnabled()) { + logger.debug("Ignoring remove({}) as this is the current writing page", pageId); + } // we don't deal with the current page, we let that one to be cleared from the regular depage return null; } @@ -735,7 +737,9 @@ public class PagingStoreImpl implements PagingStore { numberOfPages--; } - logger.trace("Removing page {}, now containing numberOfPages={}", pageId, numberOfPages); + if (logger.isTraceEnabled()) { + logger.trace("Removing page {}, now containing numberOfPages={}", pageId, numberOfPages); + } if (numberOfPages == 0) { if (logger.isTraceEnabled()) { @@ -816,7 +820,9 @@ public class PagingStoreImpl implements PagingStore { openNewPage(); } } else { - logger.trace("firstPageId++ = beforeIncrement={}", firstPageId); + if (logger.isTraceEnabled()) { + logger.trace("firstPageId++ = beforeIncrement={}", firstPageId); + } long pageNR = firstPageId++; // first we look for the page on the used Pages cache @@ -1273,7 +1279,7 @@ public class PagingStoreImpl implements PagingStore { final long newPageId = currentPageId + 1; if (logger.isTraceEnabled()) { - logger.trace("new pageNr=" + newPageId); + logger.trace("new pageNr={}", newPageId); } final Page oldPage = currentPage; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java index e34840e8d7..f18b9c2512 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java @@ -464,7 +464,7 @@ public abstract class AbstractJournalStorageManager extends CriticalComponentImp private void recordNotFoundCallback(long id, boolean found) { if (!found) { if (logger.isDebugEnabled()) { - logger.debug("Record " + id + " not found"); + logger.debug("Record {} not found", id); } } } @@ -639,7 +639,8 @@ public abstract class AbstractJournalStorageManager extends CriticalComponentImp messageJournal.appendCommitRecord(txID, syncTransactional, getContext(syncTransactional), lineUpContext); if (!lineUpContext && !syncTransactional) { if (logger.isTraceEnabled()) { - logger.trace("calling getContext(true).done() for txID=" + txID + ",lineupContext=" + lineUpContext + " syncTransactional=" + syncTransactional + "... forcing call on getContext(true).done"); + logger.trace("calling getContext(true).done() for txID={}, lineupContext={} syncTransactional={}... forcing call on getContext(true).done", + txID, lineUpContext, syncTransactional); } /** * If {@code lineUpContext == false}, it means that we have previously lined up a @@ -1197,7 +1198,7 @@ public abstract class AbstractJournalStorageManager extends CriticalComponentImp if (sub != null) { if (!sub.reloadPageCompletion(encoding.position)) { if (logger.isDebugEnabled()) { - logger.debug("Complete page " + encoding.position.getPageNr() + " doesn't exist on page manager " + sub.getPagingStore().getAddress()); + logger.debug("Complete page {} doesn't exist on page manager {}", encoding.position.getPageNr(), sub.getPagingStore().getAddress()); } messageJournal.tryAppendDeleteRecord(record.id, this::recordNotFoundCallback, false); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java index 22d7a529e4..fcd4f19bdc 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/BatchingIDGenerator.java @@ -129,7 +129,7 @@ public final class BatchingIDGenerator implements IDGenerator { // while notifications are being sent and ID generated. // If the ID is intended to the journal you would know soon enough // so we just ignore this for now - logger.debug("The journalStorageManager is not loaded. " + "This is probably ok as long as it's a notification being sent after shutdown"); + logger.debug("The journalStorageManager is not loaded. This is probably ok as long as it's a notification being sent after shutdown"); } else { storeID(counter.getAndIncrement(), nextID); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java index e5cf76b8ea..cc645cb285 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java @@ -562,9 +562,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { if (messageEncodeSize > maxRecordSize) { ActiveMQServerLogger.LOGGER.messageWithHeaderTooLarge(largeMessage.getMessageID(), logger.getName()); - if (logger.isDebugEnabled()) { - logger.debug("Message header too large for " + largeMessage); - } + logger.debug("Message header too large for {}", largeMessage); throw ActiveMQJournalBundle.BUNDLE.recordLargerThanStoreMax(messageEncodeSize, maxRecordSize); } @@ -882,7 +880,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager { try { messageJournal.appendAddEvent(messageId, JournalRecordIds.ADD_MESSAGE_BODY, EncoderPersister.getInstance(), partialBuffer, true, null); } catch (Exception e) { - logger.warn("Error processing history large message body for " + messageId + " - " + e.getMessage(), e); + logger.warn("Error processing history large message body for {}", messageId, e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeBody.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeBody.java index 8f81e52bb5..ac4637da9a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeBody.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeBody.java @@ -239,7 +239,7 @@ public class LargeBody { if (message.toMessage().getRefCount() <= 0 && message.toMessage().getUsage() <= 0 && message.toMessage().getDurableCount() <= 0) { if (logger.isTraceEnabled()) { try { - logger.trace("Deleting file " + getAppendFile() + " as the usage was complete"); + logger.trace("Deleting file {} as the usage was complete", getAppendFile()); } catch (Exception e) { // this is only after a trace, no need to do any special logging handling here logger.warn(e.getMessage(), e); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageInSync.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageInSync.java index 5ad6805470..a766666fcb 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageInSync.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageInSync.java @@ -60,22 +60,20 @@ public final class LargeServerMessageInSync implements ReplicatedLargeMessage { try { if (appendFile != null) { if (logger.isTraceEnabled()) { - logger.trace("joinSyncedData on " + mainLM + ", currentSize on mainMessage=" + mainSeqFile.size() + ", appendFile size = " + appendFile.size()); + logger.trace("joinSyncedData on {}, currentSize on mainMessage={}, appendFile size = {}", mainLM, mainSeqFile.size(), appendFile.size()); } FileIOUtil.copyData(appendFile, mainSeqFile, buffer); deleteAppendFile(); } else { - if (logger.isTraceEnabled()) { - logger.trace("joinSyncedData, appendFile is null, ignoring joinSyncedData on " + mainLM); - } + logger.trace("joinSyncedData, appendFile is null, ignoring joinSyncedData on {}", mainLM); } } catch (Throwable e) { ActiveMQServerLogger.LOGGER.errorWhileSyncingData(mainLM.toString(), e); } if (logger.isTraceEnabled()) { - logger.trace("joinedSyncData on " + mainLM + " finished with " + mainSeqFile.size()); + logger.trace("joinedSyncData on {} finished with {}", mainLM, mainSeqFile.size()); } syncDone = true; @@ -100,7 +98,7 @@ public final class LargeServerMessageInSync implements ReplicatedLargeMessage { @Override public synchronized void releaseResources(boolean sync, boolean sendEvent) { if (logger.isTraceEnabled()) { - logger.trace("release resources called on " + mainLM, new Exception("trace")); + logger.trace("release resources called on {}", mainLM, new Exception("trace")); } mainLM.releaseResources(sync, sendEvent); if (appendFile != null && appendFile.isOpen()) { @@ -140,14 +138,14 @@ public final class LargeServerMessageInSync implements ReplicatedLargeMessage { if (syncDone) { if (logger.isTraceEnabled()) { - logger.trace("Adding " + bytes.length + " towards sync message::" + mainLM); + logger.trace("Adding {} towards sync message::{}", bytes.length, mainLM); } mainLM.addBytes(bytes); return; } if (logger.isTraceEnabled()) { - logger.trace("addBytes(bytes.length=" + bytes.length + ") on message=" + mainLM); + logger.trace("addBytes(bytes.length={}) on message={}", bytes.length, mainLM); } if (appendFile == null) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java index 15d95d3a24..bad83c59bd 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/BindingsImpl.java @@ -119,9 +119,8 @@ public final class BindingsImpl implements Bindings { @Override public void addBinding(final Binding binding) { try { - if (logger.isTraceEnabled()) { - logger.trace("addBinding(" + binding + ") being called"); - } + logger.trace("addBinding({}) being called", binding); + if (binding.isExclusive()) { exclusiveBindings.add(binding); } else { @@ -135,7 +134,7 @@ public final class BindingsImpl implements Bindings { setMessageLoadBalancingType(((RemoteQueueBinding) binding).getMessageLoadBalancingType()); } if (logger.isTraceEnabled()) { - logger.trace("Adding binding " + binding + " into " + this + " bindingTable: " + debugBindings()); + logger.trace("Adding binding {} into {} bindingTable: {}", binding, this, debugBindings()); } } finally { updated(); @@ -168,7 +167,7 @@ public final class BindingsImpl implements Bindings { assert !bindingsNameMap.containsKey(binding.getUniqueName()); if (logger.isTraceEnabled()) { - logger.trace("Removing binding " + binding + " from " + this + " bindingTable: " + debugBindings()); + logger.trace("Removing binding {} from {} bindingTable: {}", binding, this, debugBindings()); } return binding; } finally { @@ -190,9 +189,7 @@ public final class BindingsImpl implements Bindings { return false; } - if (logger.isTraceEnabled()) { - logger.trace("Redistributing message {}", message); - } + logger.trace("Redistributing message {}", message); final SimpleString routingName = CompositeAddress.isFullyQualified(message.getAddress()) && originatingQueue.getRoutingType() == RoutingType.ANYCAST ? CompositeAddress.extractAddressName(message.getAddressSimpleString()) : originatingQueue.getName(); @@ -338,7 +335,9 @@ public final class BindingsImpl implements Bindings { private void simpleRouting(final Message message, final RoutingContext context, final int currentVersion) throws Exception { - logger.trace("Routing message {} on binding={} current context::{}", message, this, context); + if (logger.isTraceEnabled()) { + logger.trace("Routing message {} on binding={} current context::{}", message, this, context); + } routingNameBindingMap.forEachBindings((bindings, nextPosition) -> { final Binding nextBinding = getNextBinding(message, bindings, nextPosition, getMessageLoadBalancingType(context)); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/InMemoryDuplicateIDCache.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/InMemoryDuplicateIDCache.java index dcb0cf4536..63c94d7123 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/InMemoryDuplicateIDCache.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/InMemoryDuplicateIDCache.java @@ -216,9 +216,8 @@ final class InMemoryDuplicateIDCache implements DuplicateIDCache { @Override public synchronized void clear() throws Exception { - if (logger.isDebugEnabled()) { - logger.debug("address = {} removing duplicate ID data", address); - } + logger.debug("address = {} removing duplicate ID data", address); + ids.clear(); cache.clear(); pos = 0; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/LocalQueueBinding.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/LocalQueueBinding.java index 755d863367..83bb940abc 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/LocalQueueBinding.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/LocalQueueBinding.java @@ -124,23 +124,17 @@ public class LocalQueueBinding implements QueueBinding { @Override public void route(final Message message, final RoutingContext context) throws Exception { if (isMatchRoutingType(context)) { - if (logger.isTraceEnabled()) { - logger.trace("adding routing " + queue.getID() + " on message " + message); - } + logger.trace("adding routing {} on message {}", queue.getID(), message); queue.route(message, context); } else { - if (logger.isTraceEnabled()) { - logger.trace("routing " + queue.getID() + " is ignored as routing type did not match"); - } + logger.trace("routing {} is ignored as routing type did not match", queue.getID()); } } @Override public void routeWithAck(Message message, RoutingContext context) throws Exception { if (isMatchRoutingType(context)) { - if (logger.isTraceEnabled()) { - logger.trace("Message " + message + " routed with ack on queue " + queue.getID()); - } + logger.trace("Message {} routed with ack on queue {}", message, queue.getID()); queue.routeWithAck(message, context); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PersistentDuplicateIDCache.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PersistentDuplicateIDCache.java index 95311e4f5c..dcaed7c2fe 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PersistentDuplicateIDCache.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PersistentDuplicateIDCache.java @@ -187,13 +187,13 @@ final class PersistentDuplicateIDCache implements DuplicateIDCache { } private boolean contains(final ByteArray duplID) { - boolean contains = cache.containsKey(duplID); - - if (logger.isTraceEnabled()) { - if (contains) { + final boolean contains = cache.containsKey(duplID); + if (contains) { + if (logger.isTraceEnabled()) { logger.trace("address = {} found a duplicate {}", address, describeID(duplID.bytes)); } } + return contains; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java index 4ef4bf8025..5949ad8448 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java @@ -269,9 +269,8 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding if (!(notification.getType() instanceof CoreNotificationType)) return; - if (logger.isTraceEnabled()) { - logger.trace("Receiving notification : " + notification + " on server " + this.server); - } + logger.trace("Receiving notification : {} on server {}", notification, server); + synchronized (notificationLock) { CoreNotificationType type = (CoreNotificationType) notification.getType(); @@ -363,7 +362,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding QueueInfo info = queueInfos.remove(clusterName); if (info == null) { - logger.debug("PostOffice notification / BINDING_REMOVED: Cannot find queue info for queue \" + clusterName"); + logger.debug("PostOffice notification / BINDING_REMOVED: Cannot find queue info for clusterName {}", clusterName); return; } @@ -384,7 +383,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding QueueInfo info = queueInfos.get(clusterName); if (info == null) { - logger.debug("PostOffice notification / CONSUMER_CREATED: Could not find queue created on clusterName = " + clusterName); + logger.debug("PostOffice notification / CONSUMER_CREATED: Could not find queue created on clusterName = {}", clusterName); return; } @@ -482,7 +481,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding Binding binding = getBinding(queueName); if (binding == null) { - logger.debug("PostOffice notification / CONSUMER_CLOSED: Could not find queue " + queueName); + logger.debug("PostOffice notification / CONSUMER_CLOSED: Could not find queue {}", queueName); return; } @@ -933,9 +932,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding String uid = UUIDGenerator.getInstance().generateStringUUID(); - if (logger.isDebugEnabled()) { - logger.debug("ClusterCommunication::Sending notification for addBinding " + binding + " from server " + server); - } + logger.debug("ClusterCommunication::Sending notification for addBinding {} from server {}", binding, server); managementService.sendNotification(new Notification(uid, CoreNotificationType.BINDING_ADDED, props)); @@ -1403,7 +1400,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding } if (logger.isDebugEnabled()) { - logger.debug("PostOffice.sendQueueInfoToQueue on server=" + this.server + ", queueName=" + queueName + " and address=" + address); + logger.debug("PostOffice.sendQueueInfoToQueue on server={}, queueName={} and address={}", server, queueName, address); } Queue queue = (Queue) binding.getBindable(); @@ -1419,9 +1416,8 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding routeQueueInfo(message, queue, false); for (QueueInfo info : queueInfos.values()) { - if (logger.isTraceEnabled()) { - logger.trace("QueueInfo on sendQueueInfoToQueue = " + info); - } + logger.trace("QueueInfo on sendQueueInfoToQueue = {}", info); + if (info.matchesAddress(address)) { message = createQueueInfoMessage(CoreNotificationType.BINDING_ADDED, queueName); @@ -1914,9 +1910,9 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding if (initialCheck || queue.isSwept()) { if (logger.isDebugEnabled()) { if (initialCheck) { - logger.debug("Removing queue " + queue.getName() + " during the reload check"); + logger.debug("Removing queue {} during the reload check", queue.getName()); } else { - logger.debug("Removing queue " + queue.getName() + " after it being swept twice on reaping process"); + logger.debug("Removing queue {} after it being swept twice on reaping process", queue.getName()); } } QueueManagerImpl.performAutoDeleteQueue(server, queue); @@ -1940,9 +1936,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding server.autoRemoveAddressInfo(address, null); } else { - if (logger.isDebugEnabled()) { - logger.debug("Sweeping address " + address); - } + logger.debug("Sweeping address {}", address); addressInfo.setSwept(true); } } else { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java index 4e8fe0ef29..bce068e930 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java @@ -95,7 +95,7 @@ public class SimpleAddressManager implements AddressManager { } if (logger.isTraceEnabled()) { - logger.trace("Adding binding " + binding + " with address = " + binding.getUniqueName(), new Exception("trace")); + logger.trace("Adding binding {} with address = {}", binding, binding.getUniqueName(), new Exception("trace")); } return addMappingInternal(binding.getAddress(), binding); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java index 2baf29f2ec..7f0a864452 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java @@ -270,9 +270,8 @@ public class ServerSessionPacketHandler implements ChannelHandler { } private void onMessagePacket(final Packet packet) { - if (logger.isTraceEnabled()) { - logger.trace("ServerSessionPacketHandler::handlePacket," + packet); - } + logger.trace("ServerSessionPacketHandler::handlePacket, {}", packet); + if (AuditLogger.isAnyLoggingEnabled()) { AuditLogger.setRemoteAddress(remotingConnection.getRemoteAddress()); AuditLogger.setCurrentCaller(remotingConnection.getSubject()); @@ -915,9 +914,7 @@ public class ServerSessionPacketHandler implements ChannelHandler { final Packet response, final boolean flush, final boolean closeChannel) { - if (logger.isTraceEnabled()) { - logger.trace("ServerSessionPacketHandler::scheduling response::" + response); - } + logger.trace("ServerSessionPacketHandler::scheduling response::{}", response); storageManager.afterCompleteOperations(new IOCallback() { @Override @@ -927,17 +924,12 @@ public class ServerSessionPacketHandler implements ChannelHandler { Packet exceptionPacket = convertToExceptionPacket(confirmPacket, ActiveMQExceptionType.createException(errorCode, errorMessage)); doConfirmAndResponse(confirmPacket, exceptionPacket, flush, closeChannel); - if (logger.isTraceEnabled()) { - logger.trace("ServerSessionPacketHandler::exception response sent::" + exceptionPacket); - } - + logger.trace("ServerSessionPacketHandler::exception response sent::{}", exceptionPacket); } @Override public void done() { - if (logger.isTraceEnabled()) { - logger.trace("ServerSessionPacketHandler::regular response sent::" + response); - } + logger.trace("ServerSessionPacketHandler::regular response sent::{}", response); doConfirmAndResponse(confirmPacket, response, flush, closeChannel); } @@ -1045,9 +1037,7 @@ public class ServerSessionPacketHandler implements ChannelHandler { LargeServerMessage largeMsg = storageManager.createLargeMessage(id, message); - if (logger.isTraceEnabled()) { - logger.trace("sendLarge::" + largeMsg); - } + logger.trace("sendLarge::{}", largeMsg); if (currentLargeMessage != null) { ActiveMQServerLogger.LOGGER.replacingIncompleteLargeMessage(currentLargeMessage.getMessageID()); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java index 03305509b1..64dd56d196 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/ActiveMQPacketHandler.java @@ -232,7 +232,7 @@ public class ActiveMQPacketHandler implements ChannelHandler { response = new ReattachSessionResponseMessage(-1, false); } - logger.debug("Reattaching request from " + connection.getRemoteAddress()); + logger.debug("Reattaching request from {}", connection.getRemoteAddress()); ServerSessionPacketHandler sessionHandler = protocolManager.getSessionHandler(request.getName()); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java index 6bfbeab9b8..a19fcb857a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/impl/CoreProtocolManager.java @@ -511,7 +511,7 @@ public class CoreProtocolManager implements ProtocolManager entry : connectionEntries.entrySet()) { RemotingConnection conn = entry.getValue().connection; - if (conn.equals(connectionToKeepOpen)) + if (conn.equals(connectionToKeepOpen)) { continue; - - if (logger.isTraceEnabled()) { - logger.trace("Sending connection.disconnection packet to " + conn); } + logger.trace("Sending connection.disconnection packet to {}", conn); + if (!conn.isClient()) { conn.disconnect(scaleDownNodeID, false); removeConnection(entry.getKey()); @@ -393,9 +392,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif // We need to stop them accepting first so no new connections are accepted after we send the disconnect message for (Acceptor acceptor : acceptors.values()) { - if (logger.isDebugEnabled()) { - logger.debug("Pausing acceptor " + acceptor); - } + logger.debug("Pausing acceptor {}", acceptor); try { acceptor.pause(); @@ -405,9 +402,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif } - if (logger.isDebugEnabled()) { - logger.debug("Sending disconnect on live connections"); - } + logger.debug("Sending disconnect on live connections"); HashSet connectionEntries = new HashSet<>(connections.values()); @@ -416,9 +411,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif for (ConnectionEntry entry : connectionEntries) { RemotingConnection conn = entry.connection; - if (logger.isTraceEnabled()) { - logger.trace("Sending connection.disconnection packet to " + conn); - } + logger.trace("Sending connection.disconnection packet to {}", conn); conn.disconnect(criticalError); } @@ -499,7 +492,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif connectionCountLatch.countDown(); return entry.connection; } else { - logger.debug("The connectionID::" + remotingConnectionID + " was already removed by some other module"); + logger.debug("The connectionID::{} was already removed by some other module", remotingConnectionID); return null; } @@ -573,9 +566,8 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif throw new IllegalStateException(t.getMessage(), t.getCause()); } - if (logger.isTraceEnabled()) { - logger.trace("Connection created " + connection); - } + + logger.trace("Connection created {}", connection); addConnectionEntry(connection, entry); connectionCountLatch.countUp(); @@ -592,9 +584,8 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif @Override public void connectionDestroyed(final Object connectionID) { - if (logger.isTraceEnabled()) { - logger.trace("Connection removed " + connectionID + " from server " + this.server, new Exception("trace")); + logger.trace("Connection removed {} from server {}", connectionID, this.server, new Exception("trace")); } issueFailure(connectionID, new ActiveMQRemoteDisconnectException()); @@ -703,9 +694,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif conn.connection.fail(new ActiveMQException(e.getMessage())); } } else { - if (logger.isTraceEnabled()) { - logger.trace("ConnectionID = " + connectionID + " was already closed, so ignoring packet"); - } + logger.trace("ConnectionID = {} was already closed, so ignoring packet", connectionID); } } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java index 54cc710486..9b5c98452b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicatedJournal.java @@ -104,7 +104,7 @@ public class ReplicatedJournal implements Journal { final Object record, final boolean sync) throws Exception { if (log.isTraceEnabled()) { - log.trace("Append record id = " + id + " recordType = " + recordType); + log.trace("Append record id = {} recordType = {}", id, recordType); } replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.ADD, id, recordType, persister, record); localJournal.appendAddRecord(id, recordType, persister, record, sync); @@ -126,7 +126,7 @@ public class ReplicatedJournal implements Journal { final boolean sync, final IOCompletion completionCallback) throws Exception { if (log.isTraceEnabled()) { - log.trace("Append record id = " + id + " recordType = " + recordType); + log.trace("Append record id = {} recordType = {}", id, recordType); } replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.ADD, id, recordType, persister, record); localJournal.appendAddRecord(id, recordType, persister, record, sync, completionCallback); @@ -140,7 +140,7 @@ public class ReplicatedJournal implements Journal { boolean sync, IOCompletion completionCallback) throws Exception { if (log.isTraceEnabled()) { - log.trace("Append record id = " + id + " recordType = " + recordType); + log.trace("Append record id = {} recordType = {}", id, recordType); } replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.EVENT, id, recordType, persister, record); localJournal.appendAddEvent(id, recordType, persister, record, sync, completionCallback); @@ -177,7 +177,7 @@ public class ReplicatedJournal implements Journal { final Persister persister, final Object record) throws Exception { if (log.isTraceEnabled()) { - log.trace("Append record txID=" + id + " recordType = " + recordType); + log.trace("Append record txID={} recordType = {}", id, recordType); } replicationManager.appendAddRecordTransactional(journalID, ADD_OPERATION_TYPE.ADD, txID, id, recordType, persister, record); localJournal.appendAddRecordTransactional(txID, id, recordType, persister, record); @@ -192,7 +192,7 @@ public class ReplicatedJournal implements Journal { @Override public void appendCommitRecord(final long txID, final boolean sync) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendCommit txID=" + txID); + log.trace("AppendCommit txID={}", txID); } replicationManager.appendCommitRecord(journalID, txID, sync, true); localJournal.appendCommitRecord(txID, sync); @@ -201,7 +201,7 @@ public class ReplicatedJournal implements Journal { @Override public void appendCommitRecord(final long txID, final boolean sync, final IOCompletion callback) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendCommit " + txID); + log.trace("AppendCommit {}", txID); } replicationManager.appendCommitRecord(journalID, txID, sync, true); localJournal.appendCommitRecord(txID, sync, callback); @@ -213,7 +213,7 @@ public class ReplicatedJournal implements Journal { IOCompletion callback, boolean lineUpContext) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendCommit " + txID); + log.trace("AppendCommit {}", txID); } replicationManager.appendCommitRecord(journalID, txID, sync, lineUpContext); localJournal.appendCommitRecord(txID, sync, callback, lineUpContext); @@ -228,7 +228,7 @@ public class ReplicatedJournal implements Journal { @Override public void appendDeleteRecord(final long id, final boolean sync) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendDelete " + id); + log.trace("AppendDelete {}", id); } replicationManager.appendDeleteRecord(journalID, id); localJournal.appendDeleteRecord(id, sync); @@ -243,7 +243,7 @@ public class ReplicatedJournal implements Journal { @Override public void tryAppendDeleteRecord(final long id, final JournalUpdateCallback updateCallback, final boolean sync) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendDelete " + id); + log.trace("AppendDelete {}", id); } replicationManager.appendDeleteRecord(journalID, id); localJournal.tryAppendDeleteRecord(id, updateCallback, sync); @@ -254,7 +254,7 @@ public class ReplicatedJournal implements Journal { final boolean sync, final IOCompletion completionCallback) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendDelete " + id); + log.trace("AppendDelete {}", id); } replicationManager.appendDeleteRecord(journalID, id); localJournal.appendDeleteRecord(id, sync, completionCallback); @@ -266,7 +266,7 @@ public class ReplicatedJournal implements Journal { final JournalUpdateCallback updateCallback, final IOCompletion completionCallback) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendDelete " + id); + log.trace("AppendDelete {}", id); } replicationManager.appendDeleteRecord(journalID, id); localJournal.tryAppendDeleteRecord(id, sync, updateCallback, completionCallback); @@ -295,7 +295,7 @@ public class ReplicatedJournal implements Journal { final long id, final EncodingSupport record) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendDelete txID=" + txID + " id=" + id); + log.trace("AppendDelete txID={} id={}", txID, id); } replicationManager.appendDeleteRecordTransactional(journalID, txID, id, record); localJournal.appendDeleteRecordTransactional(txID, id, record); @@ -310,7 +310,7 @@ public class ReplicatedJournal implements Journal { @Override public void appendDeleteRecordTransactional(final long txID, final long id) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendDelete (noencoding) txID=" + txID + " id=" + id); + log.trace("AppendDelete (noencoding) txID={} id={}", txID, id); } replicationManager.appendDeleteRecordTransactional(journalID, txID, id); localJournal.appendDeleteRecordTransactional(txID, id); @@ -340,7 +340,7 @@ public class ReplicatedJournal implements Journal { final EncodingSupport transactionData, final boolean sync) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendPrepare txID=" + txID); + log.trace("AppendPrepare txID={}", txID); } replicationManager.appendPrepareRecord(journalID, txID, transactionData); localJournal.appendPrepareRecord(txID, transactionData, sync); @@ -352,7 +352,7 @@ public class ReplicatedJournal implements Journal { final boolean sync, final IOCompletion callback) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendPrepare txID=" + txID); + log.trace("AppendPrepare txID={}", txID); } replicationManager.appendPrepareRecord(journalID, txID, transactionData); localJournal.appendPrepareRecord(txID, transactionData, sync, callback); @@ -367,7 +367,7 @@ public class ReplicatedJournal implements Journal { @Override public void appendRollbackRecord(final long txID, final boolean sync) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendRollback " + txID); + log.trace("AppendRollback {}", txID); } replicationManager.appendRollbackRecord(journalID, txID); localJournal.appendRollbackRecord(txID, sync); @@ -376,7 +376,7 @@ public class ReplicatedJournal implements Journal { @Override public void appendRollbackRecord(final long txID, final boolean sync, final IOCompletion callback) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendRollback " + txID); + log.trace("AppendRollback {}", txID); } replicationManager.appendRollbackRecord(journalID, txID); localJournal.appendRollbackRecord(txID, sync, callback); @@ -424,7 +424,7 @@ public class ReplicatedJournal implements Journal { final Object record, final boolean sync) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendUpdateRecord id = " + id + " , recordType = " + recordType); + log.trace("AppendUpdateRecord id = {} , recordType = {}", id, recordType); } replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.UPDATE, id, recordType, persister, record); localJournal.appendUpdateRecord(id, recordType, persister, record, sync); @@ -438,7 +438,7 @@ public class ReplicatedJournal implements Journal { final JournalUpdateCallback updateCallback, final boolean sync, final boolean replaceable) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendUpdateRecord id = " + id + " , recordType = " + recordType); + log.trace("AppendUpdateRecord id = {} , recordType = {}", id, recordType); } replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.UPDATE, id, recordType, persister, record); localJournal.tryAppendUpdateRecord(id, recordType, persister, record, updateCallback, sync, replaceable); @@ -452,7 +452,7 @@ public class ReplicatedJournal implements Journal { final boolean sync, final IOCompletion completionCallback) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendUpdateRecord id = " + id + " , recordType = " + journalRecordType); + log.trace("AppendUpdateRecord id = {} , recordType = {}", id, journalRecordType); } replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.UPDATE, id, journalRecordType, persister, record); localJournal.appendUpdateRecord(id, journalRecordType, persister, record, sync, completionCallback); @@ -468,7 +468,7 @@ public class ReplicatedJournal implements Journal { final JournalUpdateCallback updateCallback, final IOCompletion completionCallback) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendUpdateRecord id = " + id + " , recordType = " + journalRecordType); + log.trace("AppendUpdateRecord id = {} , recordType = {}", id, journalRecordType); } replicationManager.appendUpdateRecord(journalID, ADD_OPERATION_TYPE.UPDATE, id, journalRecordType, persister, record); localJournal.tryAppendUpdateRecord(id, journalRecordType, persister, record, sync, replaceableUpdate, updateCallback, completionCallback); @@ -505,7 +505,7 @@ public class ReplicatedJournal implements Journal { final Persister persister, final Object record) throws Exception { if (log.isTraceEnabled()) { - log.trace("AppendUpdateRecord txid=" + txID + " id = " + id + " , recordType = " + recordType); + log.trace("AppendUpdateRecord txid={} id = {} , recordType = {}", txID, id, recordType); } replicationManager.appendAddRecordTransactional(journalID, ADD_OPERATION_TYPE.UPDATE, txID, id, recordType, persister, record); localJournal.appendUpdateRecordTransactional(txID, id, recordType, persister, record); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java index 5eda1b009a..5248772cc2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationEndpoint.java @@ -192,17 +192,14 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon @Override public void handlePacket(final Packet packet) { - if (logger.isTraceEnabled()) { - logger.trace("handlePacket::handling " + packet); - } + logger.trace("handlePacket::handling {}", packet); + PacketImpl response = new ReplicationResponseMessage(); final byte type = packet.getType(); try { if (!started) { - if (logger.isTraceEnabled()) { - logger.trace("handlePacket::ignoring " + packet); - } + logger.trace("handlePacket::ignoring {}", packet); return; } @@ -251,9 +248,8 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon } if (response != null) { - if (logger.isTraceEnabled()) { - logger.trace("Returning " + response); - } + logger.trace("Returning {}", response); + if (supportResponseBatching) { pendingPackets.add(response); } else { @@ -422,66 +418,57 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon private synchronized void finishSynchronization(String liveID, long activationSequence) throws Exception { if (logger.isTraceEnabled()) { - logger.trace("BACKUP-SYNC-START: finishSynchronization::" + liveID + " activationSequence = " + activationSequence); + logger.trace("BACKUP-SYNC-START: finishSynchronization::{} activationSequence = {}", liveID, activationSequence); } for (JournalContent jc : EnumSet.allOf(JournalContent.class)) { Journal journal = journalsHolder.remove(jc); - if (logger.isTraceEnabled()) { - logger.trace("getting lock on " + jc + ", journal = " + journal); - } + logger.trace("getting lock on {}, journal = {}", jc, journal); + registerJournal(jc.typeByte, journal); journal.synchronizationLock(); try { - if (logger.isTraceEnabled()) { - logger.trace("lock acquired on " + jc); - } + logger.trace("lock acquired on {}", jc); + // files should be already in place. filesReservedForSync.remove(jc); - if (logger.isTraceEnabled()) { - logger.trace("stopping journal for " + jc); - } + + logger.trace("stopping journal for {}", jc); + journal.stop(); - if (logger.isTraceEnabled()) { - logger.trace("starting journal for " + jc); - } + + logger.trace("starting journal for {}", jc); + journal.start(); - if (logger.isTraceEnabled()) { - logger.trace("loadAndSync " + jc); - } + + logger.trace("loadAndSync {}", jc); + journal.loadSyncOnly(JournalState.SYNCING_UP_TO_DATE); } finally { - if (logger.isTraceEnabled()) { - logger.trace("unlocking " + jc); - } + logger.trace("unlocking {}", jc); + journal.synchronizationUnlock(); } } - if (logger.isTraceEnabled()) { - logger.trace("Sync on large messages..."); - } + logger.trace("Sync on large messages..."); + ByteBuffer buffer = ByteBuffer.allocate(4 * 1024); for (Entry entry : largeMessages.entrySet()) { ReplicatedLargeMessage lm = entry.getValue(); if (lm instanceof LargeServerMessageInSync) { LargeServerMessageInSync lmSync = (LargeServerMessageInSync) lm; - if (logger.isTraceEnabled()) { - logger.trace("lmSync on " + lmSync.toString()); - } + logger.trace("lmSync on {}", lmSync); + lmSync.joinSyncedData(buffer); } } - if (logger.isTraceEnabled()) { - logger.trace("setRemoteBackupUpToDate and liveIDSet for " + liveID); - } + logger.trace("setRemoteBackupUpToDate and liveIDSet for {}", liveID); journalsHolder = null; eventListener.onRemoteBackupUpToDate(liveID, activationSequence); - if (logger.isTraceEnabled()) { - logger.trace("Backup is synchronized / BACKUP-SYNC-DONE"); - } + logger.trace("Backup is synchronized / BACKUP-SYNC-DONE"); ActiveMQServerLogger.LOGGER.backupServerSynchronized(server, liveID); return; @@ -551,10 +538,8 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon * @throws Exception */ private ReplicationResponseMessageV2 handleStartReplicationSynchronization(final ReplicationStartSyncMessage packet) throws Exception { + logger.trace("handleStartReplicationSynchronization:: nodeID = {}", packet); - if (logger.isTraceEnabled()) { - logger.trace("handleStartReplicationSynchronization:: nodeID = " + packet); - } ReplicationResponseMessageV2 replicationResponseMessage = new ReplicationResponseMessageV2(); if (!started) return replicationResponseMessage; @@ -618,14 +603,14 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon private void handleLargeMessageEnd(final ReplicationLargeMessageEndMessage packet) { if (logger.isTraceEnabled()) { - logger.trace("handleLargeMessageEnd on " + packet.getMessageId()); + logger.trace("handleLargeMessageEnd on {}", packet.getMessageId()); } final ReplicatedLargeMessage message = lookupLargeMessage(packet.getMessageId(), packet.isDelete(), false); if (message != null) { message.setPendingRecordID(packet.getPendingRecordId()); if (!packet.isDelete()) { if (logger.isTraceEnabled()) { - logger.trace("Closing LargeMessage " + packet.getMessageId() + " on the executor @ handleLargeMessageEnd"); + logger.trace("Closing LargeMessage {} on the executor @ handleLargeMessageEnd", packet.getMessageId()); } message.releaseResources(true, false); } else { @@ -634,7 +619,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon public void run() { try { if (logger.isTraceEnabled()) { - logger.trace("Deleting LargeMessage " + packet.getMessageId() + " on the executor @ handleLargeMessageEnd"); + logger.trace("Deleting LargeMessage {} on the executor @ handleLargeMessageEnd", packet.getMessageId()); } message.deleteFile(); } catch (Exception e) { @@ -687,7 +672,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon final long id = packet.getMessageId(); createLargeMessage(id, false); if (logger.isTraceEnabled()) { - logger.trace("Receiving Large Message Begin " + id + " on backup"); + logger.trace("Receiving Large Message Begin {} on backup", id); } } @@ -763,19 +748,19 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon switch (packet.getRecord()) { case UPDATE: if (logger.isTraceEnabled()) { - logger.trace("Endpoint appendUpdate id = " + packet.getId()); + logger.trace("Endpoint appendUpdate id = {}", packet.getId()); } journalToUse.appendUpdateRecord(packet.getId(), packet.getJournalRecordType(), packet.getRecordData(), noSync); break; case ADD: if (logger.isTraceEnabled()) { - logger.trace("Endpoint append id = " + packet.getId()); + logger.trace("Endpoint append id = {}", packet.getId()); } journalToUse.appendAddRecord(packet.getId(), packet.getJournalRecordType(), packet.getRecordData(), noSync); break; case EVENT: if (logger.isTraceEnabled()) { - logger.trace("Endpoint append id = " + packet.getId()); + logger.trace("Endpoint append id = {}", packet.getId()); } journalToUse.appendAddEvent(packet.getId(), packet.getJournalRecordType(), EncoderPersister.getInstance(), new ByteArrayEncoding(packet.getRecordData()), noSync, null); break; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java index 34f4b3a961..c978e2ab6b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/replication/ReplicationManager.java @@ -389,7 +389,7 @@ public final class ReplicationManager implements ActiveMQComponent { } if (logger.isTraceEnabled()) { - logger.trace("stop(clearTokens=" + clearTokens + ")", new Exception("Trace")); + logger.trace("stop(clearTokens={})", clearTokens, new Exception("Trace")); } // This is to avoid the write holding a lock while we are trying to close it @@ -818,7 +818,7 @@ public final class ReplicationManager implements ActiveMQComponent { if (enabled) { if (logger.isTraceEnabled()) { - logger.trace("sendSynchronizationDone ::" + nodeID + ", " + initialReplicationSyncTimeout); + logger.trace("sendSynchronizationDone ::{}, {}", nodeID, initialReplicationSyncTimeout); } synchronizationIsFinishedAcknowledgement.countUp(); @@ -879,9 +879,9 @@ public final class ReplicationManager implements ActiveMQComponent { * @return */ public OperationContext sendLiveIsStopping(final LiveStopping finalMessage) { - logger.debug("LIVE IS STOPPING?!? message=" + finalMessage + " enabled=" + enabled); + logger.debug("LIVE IS STOPPING?!? message={} enabled={}", finalMessage, enabled); if (enabled) { - logger.debug("LIVE IS STOPPING?!? message=" + finalMessage + " " + enabled); + logger.debug("LIVE IS STOPPING?!? message={} {}", finalMessage, enabled); return sendReplicatePacket(new ReplicationLiveIsStoppingMessage(finalMessage)); } return null; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java index a68efe3679..197594b03a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/security/impl/SecurityStoreImpl.java @@ -137,9 +137,7 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC if (securityEnabled) { if (managementClusterUser.equals(user)) { - if (logger.isTraceEnabled()) { - logger.trace("Authenticating cluster admin user"); - } + logger.trace("Authenticating cluster admin user"); /* * The special user cluster user is used for creating sessions that replicate management @@ -220,9 +218,7 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC SimpleString bareAddress = CompositeAddress.extractAddressName(address); SimpleString bareQueue = CompositeAddress.extractQueueName(queue); - if (logger.isTraceEnabled()) { - logger.trace("checking access permissions to " + bareAddress); - } + logger.trace("checking access permissions to {}", bareAddress); // bypass permission checks for management cluster user String user = session.getUsername(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MemoryManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MemoryManager.java index 72998c325a..d573970847 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MemoryManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/MemoryManager.java @@ -62,9 +62,9 @@ public class MemoryManager implements ActiveMQComponent { @Override public synchronized void start() { - logger.debug("Starting MemoryManager with MEASURE_INTERVAL: " + measureInterval + - " FREE_MEMORY_PERCENT: " + - memoryWarningThreshold); + if (logger.isDebugEnabled()) { + logger.debug("Starting MemoryManager with MEASURE_INTERVAL: {} FREE_MEMORY_PERCENT: {}", measureInterval, memoryWarningThreshold); + } if (started) { // Already started @@ -124,17 +124,22 @@ public class MemoryManager implements ActiveMQComponent { double availableMemoryPercent = 100.0 * availableMemory / maxMemory; - StringBuilder info = new StringBuilder(); - info.append(String.format("free memory: %s%n", SizeFormatterUtil.sizeof(freeMemory))); - info.append(String.format("max memory: %s%n", SizeFormatterUtil.sizeof(maxMemory))); - info.append(String.format("total memory: %s%n", SizeFormatterUtil.sizeof(totalMemory))); - info.append(String.format("available memory: %.2f%%%n", availableMemoryPercent)); + final boolean availableBelowThreshold = availableMemoryPercent <= memoryWarningThreshold; + final boolean prepareInfo = availableBelowThreshold || logger.isDebugEnabled(); - if (logger.isDebugEnabled()) { + final StringBuilder info = prepareInfo ? new StringBuilder() : null; + if (prepareInfo) { + info.append(String.format("free memory: %s%n", SizeFormatterUtil.sizeof(freeMemory))); + info.append(String.format("max memory: %s%n", SizeFormatterUtil.sizeof(maxMemory))); + info.append(String.format("total memory: %s%n", SizeFormatterUtil.sizeof(totalMemory))); + info.append(String.format("available memory: %.2f%%%n", availableMemoryPercent)); + } + + if (prepareInfo && logger.isDebugEnabled()) { logger.debug(info.toString()); } - if (availableMemoryPercent <= memoryWarningThreshold) { + if (availableBelowThreshold) { ActiveMQServerLogger.LOGGER.memoryError(memoryWarningThreshold, info.toString()); low = true; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/BackupManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/BackupManager.java index 6c7a5db968..00dc629152 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/BackupManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/BackupManager.java @@ -90,15 +90,14 @@ public class BackupManager implements ActiveMQComponent { return; //deploy the backup connectors using the cluster configuration for (ClusterConnectionConfiguration config : configuration.getClusterConfigurations()) { - logger.debug("deploy backup config " + config); + logger.debug("deploy backup config {}", config); deployBackupConnector(config); } //start each connector and if we are backup and shared store announce ourselves. NB with replication we don't do this //as we wait for replication to start and be notified by the replication manager. for (BackupConnector conn : backupConnectors) { - if (logger.isDebugEnabled()) { - logger.debug("****** BackupManager connecting to {}", conn); - } + logger.debug("****** BackupManager connecting to {}", conn); + conn.start(); if (server.getHAPolicy().isBackup() && server.getHAPolicy().isSharedStore()) { conn.informTopology(); @@ -251,11 +250,12 @@ public class BackupManager implements ActiveMQComponent { public void announceBackup() { //this has to be done in a separate thread executor.execute(new Runnable() { - @Override public void run() { - if (stopping) + if (stopping) { return; + } + try { //make a copy to avoid npe if we are nulled on close ServerLocatorInternal localBackupLocator = backupServerLocator; @@ -265,8 +265,9 @@ public class BackupManager implements ActiveMQComponent { return; } if (logger.isDebugEnabled()) { - logger.debug(BackupConnector.this + ":: announcing " + connector + " to " + backupServerLocator); + logger.debug("{}:: announcing {} to {}", BackupConnector.this, connector, backupServerLocator); } + announcingBackup = true; //connect to the cluster ClientSessionFactoryInternal backupSessionFactory = localBackupLocator.connect(); @@ -367,7 +368,7 @@ public class BackupManager implements ActiveMQComponent { public ServerLocatorInternal createServerLocator(Topology topology) { if (tcConfigs != null && tcConfigs.length > 0) { if (logger.isDebugEnabled()) { - logger.debug(BackupManager.this + "Creating a serverLocator for " + Arrays.toString(tcConfigs)); + logger.debug("{} Creating a serverLocator for {}", BackupManager.this, Arrays.toString(tcConfigs)); } ServerLocatorImpl locator = new ServerLocatorImpl(topology, true, tcConfigs); locator.setClusterConnection(true); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java index b7064457f1..3cb15cca11 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/ClusterController.java @@ -102,10 +102,12 @@ public class ClusterController implements ActiveMQComponent { @Override public void start() throws Exception { if (logger.isDebugEnabled()) { - logger.debug("Starting Cluster Controller " + System.identityHashCode(this) + " for server " + server); + logger.debug("Starting Cluster Controller {} for server {}", System.identityHashCode(this), server); } - if (started) + if (started) { return; + } + //set the default locator that will be used to connecting to the default cluster. defaultLocator = locators.get(defaultClusterConnectionName); //create a locator for replication, either the default or the specified if not set @@ -162,8 +164,7 @@ public class ClusterController implements ActiveMQComponent { @Override public void stop() throws Exception { if (logger.isDebugEnabled()) { - - logger.debug("Stopping Cluster Controller " + System.identityHashCode(this) + " for server " + this.server); + logger.debug("Stopping Cluster Controller {} for server {}", System.identityHashCode(this), server); } started = false; //close all the locators @@ -446,8 +447,9 @@ public class ClusterController implements ActiveMQComponent { } else { pair = new Pair<>(msg.getConnector(), msg.getBackupConnector()); } + if (logger.isTraceEnabled()) { - logger.trace("Server " + server + " receiving nodeUp from NodeID=" + msg.getNodeID() + ", pair=" + pair); + logger.trace("Server {} receiving nodeUp from NodeID={}, pair={}", server, msg.getNodeID(), pair); } if (acceptorUsed != null) { @@ -456,10 +458,10 @@ public class ClusterController implements ActiveMQComponent { String scaleDownGroupName = msg.getScaleDownGroupName(); clusterConn.nodeAnnounced(msg.getCurrentEventID(), msg.getNodeID(), msg.getBackupGroupName(), scaleDownGroupName, pair, msg.isBackup()); } else { - logger.debug("Cluster connection is null on acceptor = " + acceptorUsed); + logger.debug("Cluster connection is null on acceptor = {}", acceptorUsed); } } else { - logger.debug("there is no acceptor used configured at the CoreProtocolManager " + this); + logger.debug("there is no acceptor used configured at the CoreProtocolManager {}", this); } } else if (packet.getType() == PacketImpl.QUORUM_VOTE) { if (quorumManager != null) { @@ -506,8 +508,7 @@ public class ClusterController implements ActiveMQComponent { return; } if (logger.isDebugEnabled()) { - - logger.debug("retry on Cluster Controller " + System.identityHashCode(ClusterController.this) + " server = " + server); + logger.debug("retry on Cluster Controller {} server = {}", System.identityHashCode(ClusterController.this), server); } server.getScheduledPool().schedule(this, serverLocator.getRetryInterval(), TimeUnit.MILLISECONDS); } 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 3109e62496..2ffe42d44e 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 @@ -473,8 +473,7 @@ public class ClusterManager implements ActiveMQComponent { serverLocator.addIncomingInterceptor(new IncomingInterceptorLookingForExceptionMessage(this, executor)); if (!config.isUseDuplicateDetection()) { - logger.debug("Bridge " + config.getName() + - " is configured to not use duplicate detecion, it will send messages synchronously"); + logger.debug("Bridge {} is configured to not use duplicate detecion, it will send messages synchronously", config.getName()); } clusterLocators.add(serverLocator); @@ -620,14 +619,12 @@ public class ClusterManager implements ActiveMQComponent { if (config.getDiscoveryGroupName() != null) { DiscoveryGroupConfiguration dg = config.getDiscoveryGroupConfiguration(configuration); - if (dg == null) + if (dg == null) { return; + } if (logger.isDebugEnabled()) { - logger.debug(this + " Starting a Discovery Group Cluster Connection, name=" + - config.getDiscoveryGroupName() + - ", dg=" + - dg); + logger.debug("{} Starting a Discovery Group Cluster Connection, name={}, dg={}", this, config.getDiscoveryGroupName(), dg); } clusterConnection = new ClusterConnectionImpl(this, dg, connector, new SimpleString(config.getName()), new SimpleString(config.getAddress() != null ? config.getAddress() : ""), config.getMinLargeMessageSize(), config.getClientFailureCheckPeriod(), config.getConnectionTTL(), config.getRetryInterval(), config.getRetryIntervalMultiplier(), config.getMaxRetryInterval(), config.getInitialConnectAttempts(), config.getReconnectAttempts(), config.getCallTimeout(), config.getCallFailoverTimeout(), config.isDuplicateDetection(), config.getMessageLoadBalancingType(), config.getConfirmationWindowSize(), config.getProducerWindowSize(), executorFactory, server, postOffice, managementService, scheduledExecutor, config.getMaxHops(), nodeManager, server.getConfiguration().getClusterUser(), server.getConfiguration().getClusterPassword(), config.isAllowDirectConnectionsOnly(), config.getClusterNotificationInterval(), config.getClusterNotificationAttempts()); @@ -637,7 +634,7 @@ public class ClusterManager implements ActiveMQComponent { TransportConfiguration[] tcConfigs = config.getTransportConfigurations(configuration); if (logger.isDebugEnabled()) { - logger.debug(this + " defining cluster connection towards " + Arrays.toString(tcConfigs)); + logger.debug("{} defining cluster connection towards {}", this, Arrays.toString(tcConfigs)); } clusterConnection = new ClusterConnectionImpl(this, tcConfigs, connector, new SimpleString(config.getName()), new SimpleString(config.getAddress()), config.getMinLargeMessageSize(), config.getClientFailureCheckPeriod(), config.getConnectionTTL(), config.getRetryInterval(), config.getRetryIntervalMultiplier(), config.getMaxRetryInterval(), config.getInitialConnectAttempts(), config.getReconnectAttempts(), config.getCallTimeout(), config.getCallFailoverTimeout(), config.isDuplicateDetection(), config.getMessageLoadBalancingType(), config.getConfirmationWindowSize(), config.getProducerWindowSize(), executorFactory, server, postOffice, managementService, scheduledExecutor, config.getMaxHops(), nodeManager, server.getConfiguration().getClusterUser(), server.getConfiguration().getClusterPassword(), config.isAllowDirectConnectionsOnly(), config.getClusterNotificationInterval(), config.getClusterNotificationAttempts()); @@ -655,7 +652,7 @@ public class ClusterManager implements ActiveMQComponent { clusterConnections.put(config.getName(), clusterConnection); if (logger.isTraceEnabled()) { - logger.trace("ClusterConnection.start at " + clusterConnection, new Exception("trace")); + logger.trace("ClusterConnection.start at {}", clusterConnection, new Exception("trace")); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java index 7bfd2600f3..38027ac06d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/BridgeImpl.java @@ -238,7 +238,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled @Override public void onCreditsFail(ClientProducerCredits producerCredits) { - ActiveMQServerLogger.LOGGER.bridgeAddressFull("" + producerCredits.getAddress(), "" + this.getName()); + ActiveMQServerLogger.LOGGER.bridgeAddressFull(String.valueOf(producerCredits.getAddress()), String.valueOf(this.getName())); disconnect(); } @@ -281,11 +281,11 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled } if (logger.isTraceEnabled()) { - logger.trace("BridgeImpl::cancelRefs cancelling " + list.size() + " references"); + logger.trace("BridgeImpl::cancelRefs cancelling {} references", list.size()); } if (logger.isTraceEnabled() && list.isEmpty()) { - logger.trace("didn't have any references to cancel on bridge " + this); + logger.trace("didn't have any references to cancel on bridge {}", this); return; } @@ -298,9 +298,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled while (listIterator.hasPrevious()) { MessageReference ref = listIterator.previous(); - if (logger.isTraceEnabled()) { - logger.trace("BridgeImpl::cancelRefs Cancelling reference " + ref + " on bridge " + this); - } + logger.trace("BridgeImpl::cancelRefs Cancelling reference {} on bridge {}", ref, this); refqueue = ref.getQueue(); @@ -373,9 +371,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled stopping = true; - if (logger.isDebugEnabled()) { - logger.debug("Bridge " + this.configuration.getName() + " being stopped"); - } + logger.debug("Bridge {} being stopped", configuration.getName()); if (futureScheduledReconnection != null) { futureScheduledReconnection.cancel(true); @@ -397,9 +393,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled @Override public void pause() throws Exception { - if (logger.isDebugEnabled()) { - logger.debug("Bridge " + this.configuration.getName() + " being paused"); - } + logger.debug("Bridge {} being paused", configuration.getName()); executor.execute(new PauseRunnable()); @@ -466,9 +460,8 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled @Override public void sendAcknowledged(final Message message) { - if (logger.isTraceEnabled()) { - logger.trace("BridgeImpl::sendAcknowledged received confirmation for message " + message); - } + logger.trace("BridgeImpl::sendAcknowledged received confirmation for message {}", message); + if (active) { try { @@ -480,7 +473,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (ref != null) { if (logger.isTraceEnabled()) { - logger.trace("BridgeImpl::sendAcknowledged bridge " + this + " Acking " + ref + " on queue " + ref.getQueue()); + logger.trace("BridgeImpl::sendAcknowledged bridge {} Acking {} on queue {}", this, ref, ref.getQueue()); } ref.getQueue().acknowledge(ref); pendingAcks.countDown(); @@ -490,9 +483,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled server.callBrokerBridgePlugins(plugin -> plugin.afterAcknowledgeBridge(this, ref)); } } else { - if (logger.isTraceEnabled()) { - logger.trace("BridgeImpl::sendAcknowledged bridge " + this + " could not find reference for message " + message); - } + logger.trace("BridgeImpl::sendAcknowledged bridge {} could not find reference for message {}", this, message); } } catch (Exception e) { ActiveMQServerLogger.LOGGER.bridgeFailedToAck(e); @@ -542,12 +533,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled if (transformer != null) { final Message transformedMessage = transformer.transform(message); if (transformedMessage != message) { - if (logger.isDebugEnabled()) { - logger.debug("The transformer " + transformer + - " made a copy of the message " + - message + - " as transformedMessage"); - } + logger.debug("The transformer {} made a copy of the message {} as transformedMessage", transformer, message); } return EmbedMessageUtil.embedAsCoreMessage(transformedMessage); } else { @@ -564,33 +550,29 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled @Override public HandleStatus handle(final MessageReference ref) throws Exception { if (filter != null && !filter.match(ref.getMessage())) { - if (logger.isTraceEnabled()) { - logger.trace("message reference {} is no match for bridge {}", ref, this.getName()); - } + logger.trace("message reference {} is no match for bridge {}", ref, configuration.getName()); return HandleStatus.NO_MATCH; } synchronized (this) { if (!active || !session.isWritable(this)) { if (logger.isDebugEnabled()) { - logger.debug(this + "::Ignoring reference on bridge as it is set to inactive ref {}, active = {}", ref, active); + logger.debug("{}::Ignoring reference on bridge as it is set to inactive ref {}, active = {}", this, ref, active); } return HandleStatus.BUSY; } if (blockedOnFlowControl) { - logger.debug("Bridge {} is blocked on flow control, cannot receive {}", getName(), ref); + logger.debug("Bridge {} is blocked on flow control, cannot receive {}", configuration.getName(), ref); return HandleStatus.BUSY; } if (deliveringLargeMessage) { - logger.trace("Bridge {} is busy delivering a large message", this.getName()); + logger.trace("Bridge {} is busy delivering a large message", configuration.getName()); return HandleStatus.BUSY; } - if (logger.isTraceEnabled()) { - logger.trace("Bridge {} is handling reference {} ", ref); - } + logger.trace("Bridge {} is handling reference {} ", ref); ref.handled(); @@ -683,10 +665,10 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled scaleDown(scaleDownTargetNodeID); } else if (scaleDownTargetNodeID != null) { // the disconnected node is scaling down to me, no need to reconnect to it - logger.debug("Received scaleDownTargetNodeID: " + scaleDownTargetNodeID + "; cancelling reconnect."); + logger.debug("Received scaleDownTargetNodeID: {}; cancelling reconnect.", scaleDownTargetNodeID); fail(true, true); } else { - logger.debug("Received invalid scaleDownTargetNodeID: " + scaleDownTargetNodeID); + logger.debug("Received invalid scaleDownTargetNodeID: {}", scaleDownTargetNodeID); fail(me.getType() == ActiveMQExceptionType.DISCONNECTED, false); } @@ -697,7 +679,9 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled protected void scaleDown(String scaleDownTargetNodeID) { synchronized (this) { try { - logger.debug("Moving " + queue.getMessageCount() + " messages from " + queue.getName() + " to " + scaleDownTargetNodeID); + if (logger.isDebugEnabled()) { + logger.debug("Moving {} messages from {} to {}", queue.getMessageCount(), queue.getName(), scaleDownTargetNodeID); + } ((QueueImpl) queue).moveReferencesBetweenSnFQueues(SimpleString.toSimpleString(scaleDownTargetNodeID)); // stop the bridge from trying to reconnect and clean up all the bindings @@ -715,7 +699,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled @Override public void beforeReconnect(final ActiveMQException exception) { - // log.warn(name + "::Connection failed before reconnect ", exception); + // log.warn("{}::Connection failed before reconnect ", name, exception); // fail(false); } @@ -758,9 +742,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled // from the acks so it will get resent, duplicate detection will cope // with any messages resent - if (logger.isTraceEnabled()) { - logger.trace("going to send message: " + message + " from " + this.getQueue()); - } + logger.trace("going to send message: {} from {}", message, queue); try { producer.send(dest, message); @@ -836,7 +818,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled } protected void fail(final boolean permanently, boolean scaleDown) { - logger.debug(this + "\n\t::fail being called, permanently=" + permanently); + logger.debug("{}\n\t::fail being called, permanently={}", this, permanently); //we need to make sure we remove the node from the topology so any incoming quorum requests are voted correctly if (targetNodeID != null) { this.disconnectedAndDown = true; @@ -844,9 +826,8 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled } if (queue != null) { try { - if (logger.isTraceEnabled()) { - logger.trace("Removing consumer on fail " + this + " from queue " + queue); - } + logger.trace("Removing consumer on fail {} from queue {}", this, queue); + queue.removeConsumer(this); } catch (Exception dontcare) { logger.debug(dontcare.getMessage(), dontcare); @@ -926,11 +907,13 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled return; synchronized (connectionGuard) { - if (!keepConnecting) + if (!keepConnecting) { return; + } - logger.debug("Connecting " + this + " to its destination [" + nodeUUID.toString() + "], csf=" + this.csf); - + if (logger.isDebugEnabled()) { + logger.debug("Connecting {} to its destination [{}], csf={}", this, nodeUUID, csf); + } retryCount++; try { @@ -1004,9 +987,8 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled return; } else { ActiveMQServerLogger.LOGGER.errorConnectingBridgeRetry(this); - if (logger.isDebugEnabled()) { - logger.debug("Underlying bridge connection failure", e); - } + logger.debug("Underlying bridge connection failure", e); + scheduleRetryConnect(); } } catch (ActiveMQInterruptedException | InterruptedException e) { @@ -1051,13 +1033,9 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled timeout = configuration.getMaxRetryInterval(); } - logger.debug("Bridge " + this + - " retrying connection #" + - retryCount + - ", maxRetry=" + - reconnectAttemptsInUse + - ", timeout=" + - timeout); + if (logger.isDebugEnabled()) { + logger.debug("Bridge {} retrying connection #{}, maxRetry={}, timeout={}", this, retryCount, reconnectAttemptsInUse, timeout); + } scheduleRetryConnectFixedTimeout(timeout); } @@ -1095,7 +1073,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled return; if (logger.isDebugEnabled()) { - logger.debug("Scheduling retry for bridge " + this.configuration.getName() + " in " + milliseconds + " milliseconds"); + logger.debug("Scheduling retry for bridge {} in {} milliseconds", configuration.getName(), milliseconds); } futureScheduledReconnection = scheduledExecutor.schedule(new FutureConnectRunnable(executor, this), milliseconds, TimeUnit.MILLISECONDS); @@ -1153,20 +1131,17 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled @Override public void run() { - logger.debug("stopping bridge " + BridgeImpl.this); + logger.debug("stopping bridge {}", BridgeImpl.this); queue.removeConsumer(BridgeImpl.this); synchronized (BridgeImpl.this) { - logger.debug("Closing Session for bridge " + BridgeImpl.this.configuration.getName()); - + logger.debug("Closing Session for bridge {}", configuration.getName()); started = false; - active = false; - } if (session != null) { - logger.debug("Cleaning up session " + session); + logger.debug("Cleaning up session {}", session); session.removeFailureListener(BridgeImpl.this); try { session.close(); @@ -1176,7 +1151,7 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled } if (sessionConsumer != null) { - logger.debug("Cleaning up session " + session); + logger.debug("Cleaning up session {}", session); try { sessionConsumer.close(); sessionConsumer = null; @@ -1194,9 +1169,8 @@ public class BridgeImpl implements Bridge, SessionFailureListener, SendAcknowled keepConnecting = true; } - if (logger.isTraceEnabled()) { - logger.trace("Removing consumer on stopRunnable " + this + " from queue " + queue); - } + logger.trace("Removing consumer on stopRunnable {} from queue {}", this, queue); + ActiveMQServerLogger.LOGGER.bridgeStopped(configuration.getName()); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java index 34653356fe..be596c4662 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/ClusterConnectionBridge.java @@ -153,7 +153,7 @@ public class ClusterConnectionBridge extends BridgeImpl { this.flowRecord = flowRecord; if (logger.isTraceEnabled()) { - logger.trace("Setting up bridge between " + clusterConnection.getConnector() + " and " + targetLocator, new Exception("trace")); + logger.trace("Setting up bridge between {} and {}", clusterConnection.getConnector(), targetLocator, new Exception("trace")); } this.storeAndForwardPrefix = storeAndForwardPrefix; @@ -191,9 +191,7 @@ public class ClusterConnectionBridge extends BridgeImpl { // Note we must copy since same message may get routed to other nodes which require different headers Message messageCopy = message.copy(); - if (logger.isTraceEnabled()) { - logger.trace("Clustered bridge copied message " + message + " as " + messageCopy + " before delivery"); - } + logger.trace("Clustered bridge copied message {} as {} before delivery", message, messageCopy); // TODO - we can optimise this @@ -223,21 +221,15 @@ public class ClusterConnectionBridge extends BridgeImpl { private void setupNotificationConsumer() throws Exception { if (flowRecord != null) { if (logger.isDebugEnabled()) { - logger.debug("Setting up notificationConsumer between " + this.clusterConnection.getConnector() + - " and " + - flowRecord.getBridge().getForwardingConnection() + - " clusterConnection = " + - this.clusterConnection.getName() + - " on server " + - clusterConnection.getServer()); + logger.debug("Setting up notificationConsumer between {} and {} clusterConnection = {} on server {}", + this.clusterConnection.getConnector(), flowRecord.getBridge().getForwardingConnection(), + this.clusterConnection.getName(), clusterConnection.getServer()); } flowRecord.reset(); if (notifConsumer != null) { try { - logger.debug("Closing notification Consumer for reopening " + notifConsumer + - " on bridge " + - this.getName()); + logger.debug("Closing notification Consumer for reopening {} on bridge {}", notifConsumer, this.getName()); notifConsumer.close(); notifConsumer = null; @@ -295,14 +287,12 @@ public class ClusterConnectionBridge extends BridgeImpl { ClientMessage message = sessionConsumer.createMessage(false); if (logger.isTraceEnabled()) { - logger.trace("Requesting sendQueueInfoToQueue through " + this, new Exception("trace")); + logger.trace("Requesting sendQueueInfoToQueue through {}", this, new Exception("trace")); } ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "sendQueueInfoToQueue", notifQueueName.toString(), flowRecord.getAddress()); try (ClientProducer prod = sessionConsumer.createProducer(managementAddress)) { - if (logger.isDebugEnabled()) { - logger.debug("Cluster connection bridge on " + clusterConnection + " requesting information on queues"); - } + logger.debug("Cluster connection bridge on {} requesting information on queues", clusterConnection); prod.send(message); } @@ -429,11 +419,11 @@ public class ClusterConnectionBridge extends BridgeImpl { @Override protected void fail(final boolean permanently, final boolean scaleDown) { - logger.debug("Cluster Bridge " + this.getName() + " failed, permanently=" + permanently); + logger.debug("Cluster Bridge {} failed, permanently={}", this.getName(), permanently); super.fail(permanently, scaleDown); if (permanently) { - logger.debug("cluster node for bridge " + this.getName() + " is permanently down"); + logger.debug("cluster node for bridge {} is permanently down", this.getName()); clusterConnection.removeRecord(targetNodeID); if (scaleDown) { 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 3b29ef9930..e71500fd17 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 @@ -434,19 +434,15 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn return; } stopping = true; - if (logger.isDebugEnabled()) { - logger.debug(this + "::stopping ClusterConnection"); - } + logger.debug("{}::stopping ClusterConnection", this); if (serverLocator != null) { serverLocator.removeClusterTopologyListener(this); } - logger.debug("Cluster connection being stopped for node" + nodeManager.getNodeId() + - ", server = " + - this.server + - " serverLocator = " + - serverLocator); + if (logger.isDebugEnabled()) { + logger.debug("Cluster connection being stopped for node{}, server = {} serverLocator = {}", nodeManager.getNodeId(), server, serverLocator); + } synchronized (this) { for (MessageFlowRecord record : records.values()) { @@ -515,7 +511,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn final Pair connectorPair, final boolean backup) { if (logger.isDebugEnabled()) { - logger.debug(this + "::NodeAnnounced, backup=" + backup + nodeID + connectorPair); + logger.debug("{}::NodeAnnounced, backup={}{}{}", this, backup, nodeID, connectorPair); } TransportConfiguration live = connectorPair.getA(); @@ -654,7 +650,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } if (logger.isDebugEnabled()) { - logger.debug("Activating cluster connection nodeID=" + nodeManager.getNodeId() + " for server=" + this.server); + logger.debug("Activating cluster connection nodeID={} for server={}", nodeManager.getNodeId(), server); } liveNotifier = new LiveNotifier(); @@ -707,7 +703,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn TypedProperties props = new TypedProperties(); props.putSimpleStringProperty(new SimpleString("name"), name); Notification notification = new Notification(nodeManager.getNodeId().toString(), CoreNotificationType.CLUSTER_CONNECTION_STARTED, props); - logger.debug("sending notification: " + notification); + logger.debug("sending notification: {}", notification); managementService.sendNotification(notification); } //we add as a listener after we have sent the cluster start notif as the listener may start sending notifs before @@ -735,16 +731,15 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn return; } final String nodeID = topologyMember.getNodeId(); - if (logger.isDebugEnabled()) { - String ClusterTestBase = "receiving nodeUP for nodeID="; - logger.debug(this + ClusterTestBase + nodeID + " connectionPair=" + topologyMember); - } - // discard notifications about ourselves unless its from our backup + if (logger.isDebugEnabled()) { + logger.debug("{}receiving nodeUP for nodeID={} connectionPair={}", this, nodeID, topologyMember); + } + + // discard notifications about ourselves unless its from our backup if (nodeID.equals(nodeManager.getNodeId().toString())) { if (logger.isTraceEnabled()) { - logger.trace(this + "::informing about backup to itself, nodeUUID=" + - nodeManager.getNodeId() + ", connectorPair=" + topologyMember + ", this = " + this); + logger.trace("{}::informing about backup to itself, nodeUUID={}, connectorPair={}, this = {}", this, nodeManager.getNodeId(), topologyMember, this); } return; } @@ -762,8 +757,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn /*we don't create bridges to backups*/ if (topologyMember.getLive() == null) { if (logger.isTraceEnabled()) { - logger.trace(this + " ignoring call with nodeID=" + nodeID + ", topologyMember=" + - topologyMember + ", last=" + last); + logger.trace("{} ignoring call with nodeID={}, topologyMember={}, last={}", this, nodeID, topologyMember, last); } return; } @@ -774,8 +768,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn if (record == null) { if (logger.isDebugEnabled()) { - logger.debug(this + "::Creating record for nodeID=" + nodeID + ", topologyMember=" + - topologyMember); + logger.debug("{}::Creating record for nodeID={}, topologyMember={}", this, nodeID, topologyMember); } // New node - create a new flow record @@ -801,8 +794,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn createNewRecord(topologyMember.getUniqueEventID(), nodeID, topologyMember.getLive(), queueName, queue, true); } else { if (logger.isTraceEnabled()) { - logger.trace(this + " ignored nodeUp record for " + topologyMember + " on nodeID=" + - nodeID + " as the record already existed"); + logger.trace("{} ignored nodeUp record for {} on nodeID={} as the record already existed", this, topologyMember, nodeID); } } } catch (Exception e) { @@ -906,7 +898,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn targetLocator.setIdentity("(Cluster-connection-bridge::" + bridge.toString() + "::" + this.toString() + ")"); if (logger.isDebugEnabled()) { - logger.debug("creating record between " + this.connector + " and " + connector + bridge); + logger.debug("creating record between {} and {}{}", this.connector, connector, bridge); } record.setBridge(bridge); @@ -1035,9 +1027,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn * */ @Override public void close() throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("Stopping bridge " + bridge); - } + logger.trace("Stopping bridge {}", bridge); isClosed = true; @@ -1086,9 +1076,8 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn @Override public synchronized void onMessage(final ClientMessage message) { - if (logger.isDebugEnabled()) { - logger.debug("ClusterCommunication::Flow record on " + clusterConnector + " Receiving message " + message); - } + logger.debug("ClusterCommunication::Flow record on {} Receiving message {}", clusterConnector, message); + try { // Reset the bindings if (message.containsProperty(PostOfficeImpl.HDR_RESET_QUEUE_DATA)) { @@ -1101,7 +1090,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } if (!reset) { - logger.debug("Notification being ignored since first reset wasn't received yet: " + message); + logger.debug("Notification being ignored since first reset wasn't received yet: {}", message); return; } @@ -1233,21 +1222,21 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } private synchronized void clearBindings() throws Exception { - logger.debug(ClusterConnectionImpl.this + " clearing bindings"); + logger.debug("{} clearing bindings", ClusterConnectionImpl.this); for (RemoteQueueBinding binding : new HashSet<>(bindings.values())) { removeBinding(binding.getClusterName()); } } private synchronized void resetBindings() throws Exception { - logger.debug(ClusterConnectionImpl.this + " reset bindings"); + logger.debug("{} reset bindings", ClusterConnectionImpl.this); for (RemoteQueueBinding binding : new HashSet<>(bindings.values())) { resetBinding(binding.getClusterName()); } } private synchronized void clearDisconnectedBindings() throws Exception { - logger.debug(ClusterConnectionImpl.this + " reset bindings"); + logger.debug("{} reset bindings", ClusterConnectionImpl.this); for (RemoteQueueBinding binding : new HashSet<>(bindings.values())) { if (!binding.isConnected()) { removeBinding(binding.getClusterName()); @@ -1257,7 +1246,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn @Override public synchronized void disconnectBindings() throws Exception { - logger.debug(ClusterConnectionImpl.this + " disconnect bindings"); + logger.debug("{} disconnect bindings", ClusterConnectionImpl.this); reset = false; for (RemoteQueueBinding binding : new HashSet<>(bindings.values())) { disconnectBinding(binding.getClusterName()); @@ -1265,9 +1254,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } private synchronized void doBindingAdded(final ClientMessage message) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace(ClusterConnectionImpl.this + " Adding binding " + message); - } + logger.trace("{} Adding binding {}", ClusterConnectionImpl.this, message); if (!message.containsProperty(ManagementHelper.HDR_DISTANCE)) { throw new IllegalStateException("distance is null"); } @@ -1319,16 +1306,14 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn //will be re-generated in backup. In that case a new remote binding will be created //and put it to the map and old binding removed. if (logger.isTraceEnabled()) { - logger.trace("Removing binding because qid changed " + queueID + " old: " + existingBinding.getRemoteQueueID()); + logger.trace("Removing binding because qid changed {} old: {}", queueID, existingBinding.getRemoteQueueID()); } removeBinding(clusterName); } RemoteQueueBinding binding = new RemoteQueueBindingImpl(server.getStorageManager().generateID(), queueAddress, clusterName, routingName, queueID, filterString, queue, bridge.getName(), distance + 1, messageLoadBalancingType); - if (logger.isTraceEnabled()) { - logger.trace("Adding binding " + clusterName + " into " + ClusterConnectionImpl.this); - } + logger.trace("Adding binding {} into {}", clusterName, ClusterConnectionImpl.this); bindings.put(clusterName, binding); @@ -1340,9 +1325,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } private void doBindingRemoved(final ClientMessage message) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace(ClusterConnectionImpl.this + " Removing binding " + message); - } + logger.trace("{} Removing binding {}", ClusterConnectionImpl.this, message); if (!message.containsProperty(ManagementHelper.HDR_CLUSTER_NAME)) { throw new IllegalStateException("clusterName is null"); } @@ -1356,7 +1339,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn RemoteQueueBinding binding = bindings.remove(clusterName); if (binding == null) { - logger.warn("Cannot remove binding, because cannot find binding for queue " + clusterName); + logger.warn("Cannot remove binding, because cannot find binding for queue {}", clusterName); return; } @@ -1382,9 +1365,8 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } private synchronized void doSessionCreated(final ClientMessage message) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace(ClusterConnectionImpl.this + " session created " + message); - } + logger.trace("{} session created {}", ClusterConnectionImpl.this, message); + TypedProperties props = new TypedProperties(); props.putSimpleStringProperty(ManagementHelper.HDR_CONNECTION_NAME, message.getSimpleStringProperty(ManagementHelper.HDR_CONNECTION_NAME)); props.putSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS, message.getSimpleStringProperty(ManagementHelper.HDR_REMOTE_ADDRESS)); @@ -1395,9 +1377,8 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } private synchronized void doConsumerCreated(final ClientMessage message) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace(ClusterConnectionImpl.this + " Consumer created " + message); - } + logger.trace("{} Consumer created {}", ClusterConnectionImpl.this, message); + if (!message.containsProperty(ManagementHelper.HDR_DISTANCE)) { throw new IllegalStateException("distance is null"); } @@ -1451,9 +1432,8 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn } private synchronized void doConsumerClosed(final ClientMessage message) throws Exception { - if (logger.isTraceEnabled()) { - logger.trace(ClusterConnectionImpl.this + " Consumer closed " + message); - } + logger.trace("{} Consumer closed {}", ClusterConnectionImpl.this, message); + if (!message.containsProperty(ManagementHelper.HDR_DISTANCE)) { throw new IllegalStateException("distance is null"); } @@ -1556,7 +1536,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn public ServerLocatorInternal createServerLocator() { if (tcConfigs != null && tcConfigs.length > 0) { if (logger.isDebugEnabled()) { - logger.debug(ClusterConnectionImpl.this + "Creating a serverLocator for " + Arrays.toString(tcConfigs)); + logger.debug("{} Creating a serverLocator for {}", ClusterConnectionImpl.this, Arrays.toString(tcConfigs)); } ServerLocatorImpl locator = new ServerLocatorImpl(topology, true, tcConfigs); locator.setClusterConnection(true); @@ -1594,7 +1574,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn @Override public void removeRecord(String targetNodeID) { - logger.debug("Removing record for: " + targetNodeID); + logger.debug("Removing record for: {}", targetNodeID); MessageFlowRecord record = records.remove(targetNodeID); try { if (record != null) { @@ -1607,7 +1587,7 @@ public final class ClusterConnectionImpl implements ClusterConnection, AfterConn @Override public void disconnectRecord(String targetNodeID) { - logger.debug("Disconnecting record for: " + targetNodeID); + logger.debug("Disconnecting record for: {}", targetNodeID); MessageFlowRecord record = records.get(targetNodeID); try { if (record != null) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java index b8ca80032d..5fcf947bbd 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/cluster/impl/RemoteQueueBindingImpl.java @@ -342,7 +342,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding { message.putExtraBytesProperty(idsHeaderName, ids); if (logger.isTraceEnabled()) { - logger.trace("Adding remoteQueue ID = " + remoteQueueID + " into message=" + message + " store-forward-queue=" + storeAndForwardQueue); + logger.trace("Adding remoteQueue ID = {} into message={} store-forward-queue={}", remoteQueueID, message, storeAndForwardQueue); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/AbstractFederationStream.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/AbstractFederationStream.java index 03a1cd73bd..90edb7c6ea 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/AbstractFederationStream.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/AbstractFederationStream.java @@ -28,14 +28,9 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.federation.address.FederatedAddress; import org.apache.activemq.artemis.core.server.federation.queue.FederatedQueue; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; public abstract class AbstractFederationStream implements FederationStream { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); protected final ActiveMQServer server; protected final Federation federation; protected final SimpleString name; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederatedAbstract.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederatedAbstract.java index 11964a5ae1..90f8d43247 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederatedAbstract.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederatedAbstract.java @@ -28,14 +28,9 @@ import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.federation.FederatedQueueConsumerImpl.ClientSessionCallback; import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerBasePlugin; import org.apache.activemq.artemis.core.server.transformer.Transformer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; public abstract class FederatedAbstract implements ActiveMQServerBasePlugin { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private static final WildcardConfiguration DEFAULT_WILDCARD_CONFIGURATION = new WildcardConfiguration(); protected final Federation federation; protected ActiveMQServer server; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederatedQueueConsumerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederatedQueueConsumerImpl.java index 8b3297053e..3b2c78a140 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederatedQueueConsumerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederatedQueueConsumerImpl.java @@ -35,15 +35,11 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.LargeServerMessage; import org.apache.activemq.artemis.core.server.transformer.Transformer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; import static org.apache.activemq.artemis.core.client.impl.LargeMessageControllerImpl.LargeData; public class FederatedQueueConsumerImpl implements FederatedQueueConsumer, SessionFailureListener { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final ActiveMQServer server; private final Federation federation; private final FederatedConsumerKey key; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederationDownstream.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederationDownstream.java index ae3bc80c99..b220e3cd52 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederationDownstream.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/FederationDownstream.java @@ -36,14 +36,9 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.Federation import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.FederationStreamConnectMessage; import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; public class FederationDownstream extends AbstractFederationStream implements SessionFailureListener { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private FederationDownstreamConfiguration config; private ClientSessionFactoryInternal clientSessionFactory; private ClientSessionInternal clientSession; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/queue/FederatedQueue.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/queue/FederatedQueue.java index d886f42f8f..485a28d988 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/queue/FederatedQueue.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/federation/queue/FederatedQueue.java @@ -43,9 +43,6 @@ import org.apache.activemq.artemis.core.server.federation.FederationUpstream; import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerConsumerPlugin; import org.apache.activemq.artemis.core.server.transformer.Transformer; import org.apache.activemq.artemis.core.settings.impl.Match; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; /** * Federated Queue, connect to upstream queues routing them to the local queue when a local consumer exist. @@ -56,8 +53,6 @@ import java.lang.invoke.MethodHandles; */ public class FederatedQueue extends FederatedAbstract implements ActiveMQServerConsumerPlugin, Serializable { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final Set includes; private final Set excludes; private final Filter metaDataFilter; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java index 5033c23336..bac2757a9b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitor.java @@ -75,7 +75,7 @@ public class FileStoreMonitor extends ActiveMQScheduledComponent { try { addStore(Files.getFileStore(file.toPath())); } catch (IOException e) { - logger.error("Error getting file store for " + file.getAbsolutePath(), e); + logger.error("Error getting file store for {}", file.getAbsolutePath(), e); throw e; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java index fc1054df64..40850d3cbb 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/group/impl/LocalGroupingHandler.java @@ -191,7 +191,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { @Override public Response receive(final Proposal proposal, final int distance) throws Exception { - logger.trace("received proposal " + proposal); + logger.trace("received proposal {}", proposal); return propose(proposal); } @@ -261,7 +261,7 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { expectedBindings.removeAll(bindingsAlreadyAdded); if (expectedBindings.size() > 0) { - logger.debug("Waiting remote group bindings to arrive before starting the server. timeout=" + timeout + " milliseconds"); + logger.debug("Waiting remote group bindings to arrive before starting the server. timeout={} milliseconds", timeout); //now we wait here for the rest to be received in onNotification, it will signal once all have been received. //if we aren't signaled then bindingsAdded still has some groupids we need to remove. if (!ConcurrentUtil.await(awaitCondition, timeout)) { @@ -292,18 +292,18 @@ public final class LocalGroupingHandler extends GroupHandlingAbstract { if (expectedBindings != null) { if (waitingForBindings) { if (expectedBindings.remove(clusterName)) { - logger.debug("OnNotification for waitForbindings::Removed clusterName=" + clusterName + " from lis succesffully"); + logger.debug("OnNotification for waitForbindings::Removed clusterName={} from list succesffully", clusterName); } else { - logger.debug("OnNotification for waitForbindings::Couldn't remove clusterName=" + clusterName + " as it wasn't on the original list"); + logger.debug("OnNotification for waitForbindings::Couldn't remove clusterName={} as it wasn't on the original list", clusterName); } } else { expectedBindings.add(clusterName); - logger.debug("Notification for waitForbindings::Adding previously known item clusterName=" + clusterName); + logger.debug("Notification for waitForbindings::Adding previously known item clusterName={}", clusterName); } if (logger.isDebugEnabled()) { for (SimpleString stillWaiting : expectedBindings) { - logger.debug("Notification for waitForbindings::Still waiting for clusterName=" + stillWaiting); + logger.debug("Notification for waitForbindings::Still waiting for clusterName={}", stillWaiting); } } 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 5227413526..32f74311c1 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 @@ -555,9 +555,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { final DatabaseStorageConfiguration dbConf = (DatabaseStorageConfiguration) configuration.getStoreConfiguration(); manager = JdbcNodeManager.with(dbConf, scheduledPool, executorFactory); } else if (haType == null || haType == HAPolicyConfiguration.TYPE.LIVE_ONLY) { - if (logger.isDebugEnabled()) { - logger.debug("Detected no Shared Store HA options on JDBC store"); - } + logger.debug("Detected no Shared Store HA options on JDBC store"); //LIVE_ONLY should be the default HA option when HA isn't configured manager = new FileLockNodeManager(directory, replicatingBackup, configuration.getJournalLockAcquisitionTimeout(), scheduledPool); } else { @@ -639,7 +637,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { activationLatch.setCount(1); - logger.debug("Starting server " + this); + logger.debug("Starting server {}", this); OperationContextImpl.clearContext(); @@ -672,9 +670,8 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (haPolicy.isWaitForActivation()) { activation.run(); } else { - if (logger.isTraceEnabled()) { - logger.trace("starting activation"); - } + logger.trace("starting activation"); + activationThread = new ActivationThread(activation, ActiveMQMessageBundle.BUNDLE.activationForServer(this)); activationThread.start(); } @@ -698,9 +695,8 @@ public class ActiveMQServerImpl implements ActiveMQServer { afterActivationCreated = null; } - if (logger.isTraceEnabled()) { - logger.trace("starting backupActivation"); - } + logger.trace("starting backupActivation"); + activationThread = new ActivationThread(activation, ActiveMQMessageBundle.BUNDLE.activationForServer(this)); activationThread.start(); } else { @@ -1210,10 +1206,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { boolean shutdownExternalComponents, boolean restarting, boolean isShutdown) { - - if (logger.isDebugEnabled()) { - logger.debug("Stopping server " + this); - } + logger.debug("Stopping server {}", this); synchronized (this) { if (state == SERVER_STATE.STOPPED || state == SERVER_STATE.STOPPING) { @@ -1478,7 +1471,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { if (!executorService.awaitTermination(10, TimeUnit.SECONDS)) { ActiveMQServerLogger.LOGGER.timedOutStoppingThreadpool(threadPool); for (Runnable r : executorService.shutdownNow()) { - logger.debug("Cancelled the execution of " + r); + logger.debug("Cancelled the execution of {}", r); } } } catch (InterruptedException e) { @@ -2298,10 +2291,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { throw ActiveMQMessageBundle.BUNDLE.queueSubscriptionBelongsToDifferentFilter(queueConfiguration.getName()); } - if (logger.isDebugEnabled()) { - logger.debug("Transient Queue " + queueConfiguration.getName() + " created on address " + queueConfiguration.getName() + " with filter=" + queueConfiguration.getFilterString()); - } - + logger.debug("Transient Queue {} created on address {} with filter={}", queueConfiguration.getName(), queueConfiguration.getAddress(), queueConfiguration.getFilterString()); } @Override @@ -2656,10 +2646,10 @@ public class ActiveMQServerImpl implements ActiveMQServer { } } catch (Throwable e) { if (e instanceof ActiveMQException) { - logger.debug("plugin " + plugin + " is throwing ActiveMQException"); + logger.debug("plugin {} is throwing ActiveMQException", plugin); throw (ActiveMQException) e; } else { - logger.warn("Internal error on plugin " + plugin, e.getMessage(), e); + logger.warn("Internal error on plugin {}", plugin, e); } } } @@ -2694,10 +2684,10 @@ public class ActiveMQServerImpl implements ActiveMQServer { pluginRun.run(plugin); } catch (Throwable e) { if (e instanceof ActiveMQException) { - logger.debug("plugin " + plugin + " is throwing ActiveMQException"); + logger.debug("plugin {} is throwing ActiveMQException", plugin); throw (ActiveMQException) e; } else { - logger.warn("Internal error on plugin " + pluginRun, e.getMessage(), e); + logger.warn("Internal error on plugin {}", pluginRun, e); } } } @@ -3744,11 +3734,9 @@ public class ActiveMQServerImpl implements ActiveMQServer { @Override public void autoRemoveAddressInfo(SimpleString address, SecurityAuth auth) throws Exception { - if (logger.isDebugEnabled()) { - logger.debug("deleting auto-created address \"" + address + ".\""); - } + logger.debug("deleting auto-created address \"{}.\"", address); - ActiveMQServerLogger.LOGGER.autoRemoveAddress("" + address); + ActiveMQServerLogger.LOGGER.autoRemoveAddress(String.valueOf(address)); removeAddressInfo(address, auth); } @@ -4457,7 +4445,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { try { destroyDivert(divertName); } catch (Throwable e) { - logger.warn("Divert " + divertName + " could not be removed", e); + logger.warn("Divert {} could not be removed", divertName, e); } } recoverStoredDiverts(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java index 2bfd3202c9..2add360694 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/AnyLiveNodeLocatorForScaleDown.java @@ -92,8 +92,7 @@ public class AnyLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (topologyMember.getNodeId().equals(myNodeID)) { if (logger.isTraceEnabled()) { - logger.trace(this + "::informing node about itself, nodeUUID=" + - server.getNodeID() + ", connectorPair=" + topologyMember + ", this = " + this); + logger.trace("{}::informing node about itself, nodeUUID={}, connectorPair={}, this = {}", this, server.getNodeID(), topologyMember, this); } return; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java index 148689787b..485cc911ba 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/DivertImpl.java @@ -97,7 +97,7 @@ public class DivertImpl implements Divert { for (SimpleString forwardAddress : forwardAddresses) { if (logger.isTraceEnabled()) { - logger.trace("Diverting message " + message + " into " + this); + logger.trace("Diverting message {} into {}", message, this); } context.setReusable(false); 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 659eca756d..2733672a94 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 @@ -190,7 +190,10 @@ public class FileLockNodeManager extends FileBasedNodeManager { do { byte state = getState(); while (state == FileLockNodeManager.NOT_STARTED || state == FIRST_TIME_START) { - logger.debug("awaiting live node startup state='" + state + "'"); + if (logger.isDebugEnabled()) { + logger.debug("awaiting live node startup state='{}'", state); + } + Thread.sleep(2000); state = getState(); } @@ -210,7 +213,9 @@ public class FileLockNodeManager extends FileBasedNodeManager { logger.debug("awaiting live node failing back"); Thread.sleep(2000); } else if (state == FileLockNodeManager.LIVE) { - logger.debug("acquired live node lock state = " + (char) state); + if (logger.isDebugEnabled()) { + logger.debug("acquired live node lock state = {}", (char) state); + } break; } } @@ -316,9 +321,13 @@ public class FileLockNodeManager extends FileBasedNodeManager { * @throws ActiveMQLockAcquisitionTimeoutException,IOException */ private void writeFileLockStatus(byte status) throws NodeManagerException { - if (replicatedBackup && channel == null) + if (replicatedBackup && channel == null) { return; - logger.debug("writing status: " + status); + } + + if (logger.isDebugEnabled()) { + logger.debug("writing status: {}", status); + } ByteBuffer bb = ByteBuffer.allocateDirect(1); bb.put(status); bb.position(0); @@ -361,7 +370,10 @@ public class FileLockNodeManager extends FileBasedNodeManager { lock.release(); } } - logger.debug("state: " + result); + + if (logger.isDebugEnabled()) { + logger.debug("state: {}", result); + } return result; } catch (IOException | ActiveMQLockAcquisitionTimeoutException e) { throw new NodeManagerException(e); @@ -388,13 +400,19 @@ public class FileLockNodeManager extends FileBasedNodeManager { protected FileLock tryLock(final int lockPos) throws IOException { try { - logger.debug("trying to lock position: " + lockPos); - FileLock lock = lockChannels[lockPos].tryLock(); - if (lock != null) { - logger.debug("locked position: " + lockPos); - } else { - logger.debug("failed to lock position: " + lockPos); + if (logger.isDebugEnabled()) { + logger.debug("trying to lock position: {}", lockPos); } + + FileLock lock = lockChannels[lockPos].tryLock(); + if (logger.isDebugEnabled()) { + if (lock != null) { + logger.debug("locked position: {}", lockPos); + } else { + logger.debug("failed to lock position: {}", lockPos); + } + } + return lock; } catch (java.nio.channels.OverlappingFileLockException ex) { // This just means that another object on the same JVM is holding the lock diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java index 6c60028375..e67ae7dab1 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LastValueQueue.java @@ -40,9 +40,6 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.utils.actors.ArtemisExecutor; import org.apache.activemq.artemis.utils.collections.LinkedListIterator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; /** * A queue that will discard messages if a newer message with the same @@ -55,7 +52,6 @@ import java.lang.invoke.MethodHandles; @SuppressWarnings("ALL") public class LastValueQueue extends QueueImpl { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final Map map = new ConcurrentHashMap<>(); private final SimpleString lastValueKey; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java index 69c7bfe0fa..dd758bae5c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LegacyLDAPSecuritySettingPlugin.java @@ -330,12 +330,10 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { securityRoles = new HashMap<>(); try { if (logger.isDebugEnabled()) { - logger.debug(new StringBuilder().append("Performing LDAP search: ").append(destinationBase) - .append("\n\tfilter: ").append(filter) - .append("\n\tcontrols:") - .append("\n\t\treturningAttributes: ").append(roleAttribute) - .append("\n\t\tsearchScope: SUBTREE_SCOPE").toString()); + logger.debug("Performing LDAP search: {}\n\tfilter: {}\n\tcontrols:\n\t\treturningAttributes: {}\n\t\tsearchScope: SUBTREE_SCOPE", + destinationBase, filter, roleAttribute); } + NamingEnumeration searchResults = context.search(destinationBase, filter, searchControls); while (searchResults.hasMore()) { processSearchResult(securityRoles, searchResults.next()); @@ -358,21 +356,24 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { Attributes attrs = searchResult.getAttributes(); if (attrs == null || attrs.size() == 0) { if (logger.isDebugEnabled()) { - logger.debug("Skipping LDAP search result \"" + searchResultLdapName + "\" with " + (attrs == null ? "null" : attrs.size()) + " attributes"); + logger.debug("Skipping LDAP search result \"{}\" with {} attributes", searchResultLdapName, (attrs == null ? "null" : attrs.size())); } return; } List rdns = searchResultLdapName.getRdns(); if (rdns.size() < 3) { if (logger.isDebugEnabled()) { - logger.debug("\tSkipping LDAP search result \"" + searchResultLdapName + "\" with " + rdns.size() + " RDNs."); + logger.debug("\tSkipping LDAP search result \"{}\" with {} RDNs.", searchResultLdapName, rdns.size()); } return; } - StringBuilder logMessage = new StringBuilder(); - if (logger.isDebugEnabled()) { + + final boolean prepareDebugLog = logger.isDebugEnabled(); + final StringBuilder logMessage = prepareDebugLog ? new StringBuilder() : null; + if (prepareDebugLog) { logMessage.append("LDAP search result: ").append(searchResultLdapName); } + // we can count on the RDNs being in order from right to left Rdn rdn = rdns.get(rdns.size() - 3); String rawDestinationType = rdn.getValue().toString(); @@ -382,23 +383,23 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { } else if (rawDestinationType.toLowerCase().contains("topic")) { destinationType = "topic"; } - if (logger.isDebugEnabled()) { + if (prepareDebugLog) { logMessage.append("\n\tDestination type: ").append(destinationType); } rdn = rdns.get(rdns.size() - 2); - if (logger.isDebugEnabled()) { + if (prepareDebugLog) { logMessage.append("\n\tDestination name: ").append(rdn.getValue()); } String destination = rdn.getValue().toString(); rdn = rdns.get(rdns.size() - 1); - if (logger.isDebugEnabled()) { + if (prepareDebugLog) { logMessage.append("\n\tPermission type: ").append(rdn.getValue()); } String permissionType = rdn.getValue().toString(); - if (logger.isDebugEnabled()) { + if (prepareDebugLog) { logMessage.append("\n\tAttributes: ").append(attrs); } Attribute attr = attrs.get(roleAttribute); @@ -416,7 +417,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { LdapName ldapname = new LdapName(value); rdn = ldapname.getRdn(ldapname.size() - 1); String roleName = rdn.getValue().toString(); - if (logger.isDebugEnabled()) { + if (prepareDebugLog) { logMessage.append("\n\tRole name: ").append(roleName); } boolean write = permissionType.equalsIgnoreCase(writePermissionValue); @@ -446,8 +447,8 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { } } - if (logger.isDebugEnabled()) { - logger.debug(logMessage.toString()); + if (prepareDebugLog) { + logger.debug(String.valueOf(logMessage)); } if (!exists) { @@ -480,41 +481,41 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { * @param namingEvent the new entry event that occurred */ public void objectAdded(NamingEvent namingEvent) { - if (logger.isDebugEnabled()) { - logger.debug("objectAdded:\n\told binding: " + namingEvent.getOldBinding() + "\n\tnew binding: " + namingEvent.getNewBinding()); - } + logger.debug("objectAdded:\n\told binding: {}\n\tnew binding: {}", namingEvent.getOldBinding(), namingEvent.getNewBinding()); Map> newRoles = new HashMap<>(); try { processSearchResult(newRoles, (SearchResult) namingEvent.getNewBinding()); for (Map.Entry> newRole : newRoles.entrySet()) { - Set existingRoles = securityRepository.getMatch(newRole.getKey()); - if (securityRepository.containsExactWildcardMatch(newRole.getKey()) || securityRepository.containsExactMatch(newRole.getKey()) && existingRoles != securityRepository.getDefault()) { + final String newRoleKey = newRole.getKey(); + final Set newRoleValueSet = newRole.getValue(); + + Set existingRoles = securityRepository.getMatch(newRoleKey); + if (securityRepository.containsExactWildcardMatch(newRoleKey) || securityRepository.containsExactMatch(newRoleKey) && existingRoles != securityRepository.getDefault()) { Set merged = new HashSet<>(); for (Role existingRole : existingRoles) { - for (Role role : newRole.getValue()) { + for (Role role : newRoleValueSet) { if (existingRole.getName().equals(role.getName())) { if (logger.isDebugEnabled()) { - logger.debug("merging role " + role + " with existing role " + existingRole + " at " + newRole.getKey()); + logger.debug("merging role {} with existing role {} at {}", role, existingRole, newRoleKey); } + existingRole.merge(role); merged.add(role); } } } - for (Role role : newRole.getValue()) { + for (Role role : newRoleValueSet) { if (!merged.contains(role)) { - if (logger.isDebugEnabled()) { - logger.debug("add new role " + role + " to existing roles " + existingRoles); - } + logger.debug("add new role {} to existing roles {}", role, existingRoles); + existingRoles.add(role); } } } else { - if (logger.isDebugEnabled()) { - logger.debug("adding new match " + newRole.getKey() + ": " + newRole.getValue()); - } - securityRepository.addMatch(newRole.getKey(), newRole.getValue()); + logger.debug("adding new match {}: {}", newRoleKey, newRoleValueSet); + + securityRepository.addMatch(newRoleKey, newRoleValueSet); } } } catch (NamingException e) { @@ -528,24 +529,20 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { * @param namingEvent the removed entry event that occurred */ public void objectRemoved(NamingEvent namingEvent) { - if (logger.isDebugEnabled()) { - logger.debug("objectRemoved:\n\told binding: " + namingEvent.getOldBinding() + "\n\tnew binding: " + namingEvent.getNewBinding()); - } + logger.debug("objectRemoved:\n\told binding: {}\n\tnew binding: {}", namingEvent.getOldBinding(), namingEvent.getNewBinding()); try { LdapName ldapName = new LdapName(namingEvent.getOldBinding().getName()); List rdns = ldapName.getRdns(); if (rdns.size() < 3) { if (logger.isDebugEnabled()) { - logger.debug("Skipping old binding name \"" + namingEvent.getOldBinding().getName() + "\" with " + rdns.size() + " RDNs."); + logger.debug("Skipping old binding name \"{}\" with {} RDNs.", namingEvent.getOldBinding().getName(), rdns.size()); } return; } String match = rdns.get(rdns.size() - 2).getValue().toString(); - if (logger.isDebugEnabled()) { - logger.debug("Destination name: " + match); - } + logger.debug("Destination name: {}", match); if (match != null) { Set roles = securityRepository.getMatch(match); @@ -554,21 +551,21 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { for (Rdn rdn : ldapName.getRdns()) { if (rdn.getValue().equals(writePermissionValue)) { - logger.debug("Removing write permission from " + match); + logger.debug("Removing write permission from {}", match); for (Role role : roles) { if (role.isSend()) { rolesToRemove.add(role); } } } else if (rdn.getValue().equals(readPermissionValue)) { - logger.debug("Removing read permission from " + match); + logger.debug("Removing read permission from {}", match); for (Role role : roles) { if (role.isConsume()) { rolesToRemove.add(role); } } } else if (rdn.getValue().equals(adminPermissionValue)) { - logger.debug("Removing admin permission from " + match); + logger.debug("Removing admin permission from {}", match); for (Role role : roles) { if (role.isCreateDurableQueue() || role.isCreateNonDurableQueue() || role.isDeleteDurableQueue() || role.isDeleteNonDurableQueue()) { rolesToRemove.add(role); @@ -578,7 +575,7 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { } if (roles.removeAll(rolesToRemove)) { - logger.debug("Removed roles: " + rolesToRemove + ". Remaining roles: " + roles); + logger.debug("Removed roles: {}. Remaining roles: {}", rolesToRemove, roles); } } } catch (NamingException e) { @@ -599,9 +596,8 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin { * @param namingEvent the changed entry event that occurred */ public void objectChanged(NamingEvent namingEvent) { - if (logger.isDebugEnabled()) { - logger.debug("objectChanged:\n\told binding: " + namingEvent.getOldBinding() + "\n\tnew binding: " + namingEvent.getNewBinding()); - } + logger.debug("objectChanged:\n\told binding: {}\n\tnew binding: {}", namingEvent.getOldBinding(), namingEvent.getNewBinding()); + objectRemoved(namingEvent); objectAdded(namingEvent); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java index 8cc31a8ccb..79c27d62ac 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java @@ -158,7 +158,7 @@ public class LiveOnlyActivation extends Activation { try { clientSessionFactory = (ClientSessionFactoryInternal) scaleDownServerLocator.createSessionFactory(possibleLive.getA(), 0, false); } catch (Exception e) { - logger.trace("Failed to connect to " + possibleLive.getA()); + logger.trace("Failed to connect to {}", possibleLive.getA()); nodeLocator.notifyRegistrationFailed(false); if (clientSessionFactory != null) { clientSessionFactory.close(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java index 4cc0558af8..9eff597848 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/NamedLiveNodeLocatorForScaleDown.java @@ -93,8 +93,7 @@ public class NamedLiveNodeLocatorForScaleDown extends LiveNodeLocator { if (topologyMember.getNodeId().equals(myNodeID)) { if (logger.isTraceEnabled()) { - logger.trace(this + "::informing node about itself, nodeUUID=" + - server.getNodeID() + ", connectorPair=" + topologyMember + ", this = " + this); + logger.trace("{}::informing node about itself, nodeUUID={}, connectorPair={}, this = {}", this, server.getNodeID(), topologyMember, this); } return; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java index c475d67193..94569f89c2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/PostOfficeJournalLoader.java @@ -417,7 +417,9 @@ public class PostOfficeJournalLoader implements JournalLoader { for (Map.Entry> entry : perQueue.entrySet()) { for (PageCountPending record : entry.getValue()) { - logger.debug("Deleting pg tempCount {}", record.getID()); + if (logger.isDebugEnabled()) { + logger.debug("Deleting pg tempCount {}", record.getID()); + } storageManager.deletePendingPageCounter(txRecoverCounter.getID(), record.getID()); } @@ -429,7 +431,7 @@ public class PostOfficeJournalLoader implements JournalLoader { if (value == null) { logger.debug("Page {} wasn't open, so we will just ignore", entry.getKey()); } else { - logger.debug("Replacing counter {}", value.get()); + logger.debug("Replacing counter {}", value); counter.increment(txRecoverCounter, value.get(), sizeValue.get()); } } @@ -438,7 +440,9 @@ public class PostOfficeJournalLoader implements JournalLoader { logger.debug("Page {} didn't exist on address {}, so we are just removing records", pageId, addressPageMapEntry.getKey()); for (List records : perQueue.values()) { for (PageCountPending record : records) { - logger.debug("Removing pending page counter {}", record.getID()); + if (logger.isDebugEnabled()) { + logger.debug("Removing pending page counter {}", record.getID()); + } storageManager.deletePendingPageCounter(txRecoverCounter.getID(), record.getID()); txRecoverCounter.setContainsPersistent(); } @@ -476,7 +480,10 @@ public class PostOfficeJournalLoader implements JournalLoader { Queue queue = queues.get(queueID); if (queue == null) { - logger.debug("removing pending page counter id = " + pgCount.getID() + " as queueID=" + pgCount.getID() + " no longer exists"); + if (logger.isDebugEnabled()) { + logger.debug("removing pending page counter id = {} as queueID={} no longer exists", pgCount.getID(), queueID); + } + // this means the queue doesn't exist any longer, we will remove it from the storage storageManager.deletePendingPageCounter(txRecoverCounter.getID(), pgCount.getID()); txRecoverCounter.setContainsPersistent(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java index 0dab336f1c..66d6ff789b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java @@ -1087,9 +1087,9 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { public void run() { synchronized (QueueImpl.this) { if (groups.remove(groupIDToRemove) != null) { - logger.debug("Removing group after unproposal " + groupID + " from queue " + QueueImpl.this); + logger.debug("Removing group after unproposal {} from queue {}", groupID, QueueImpl.this); } else { - logger.debug("Couldn't remove Removing group " + groupIDToRemove + " after unproposal on queue " + QueueImpl.this); + logger.debug("Couldn't remove Removing group {} after unproposal on queue {}", groupIDToRemove, QueueImpl.this); } } } @@ -1101,7 +1101,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { @Override public void addHead(final MessageReference ref, boolean scheduling) { if (logger.isDebugEnabled()) { - logger.debug("AddHead, size = " + queueMemorySize + ", intermediate size = " + intermediateMessageReferences.size() + ", references size = " + messageReferences.size() + "\nreference=" + ref); + logger.debug("AddHead, size = {}, intermediate size = {}, references size = {}\nreference={}", queueMemorySize, intermediateMessageReferences.size(), messageReferences.size(), ref); } try (ArtemisCloseable metric = measureCritical(CRITICAL_PATH_ADD_HEAD)) { synchronized (this) { @@ -1126,7 +1126,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { @Override public void addSorted(final MessageReference ref, boolean scheduling) { if (logger.isDebugEnabled()) { - logger.debug("addSorted, size = " + queueMemorySize + ", intermediate size = " + intermediateMessageReferences.size() + ", references size = " + messageReferences.size() + "\nreference=" + ref); + logger.debug("addSorted, size = {}, intermediate size = {}, references size = {}\nreference={}", queueMemorySize, intermediateMessageReferences.size(), messageReferences.size(), ref); } try (ArtemisCloseable metric = measureCritical(CRITICAL_PATH_ADD_HEAD)) { synchronized (this) { @@ -1217,9 +1217,8 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { } if (direct && supportsDirectDeliver && !directDeliver && System.currentTimeMillis() - lastDirectDeliveryCheck > CHECK_QUEUE_SIZE_PERIOD) { - if (logger.isTraceEnabled()) { - logger.trace("Checking to re-enable direct deliver on queue " + this.getName()); - } + logger.trace("Checking to re-enable direct deliver on queue {}", name); + lastDirectDeliveryCheck = System.currentTimeMillis(); synchronized (directDeliveryGuard) { // The checkDirect flag is periodically set to true, if the delivery is specified as direct then this causes the @@ -1235,12 +1234,10 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { // Go into direct delivery mode directDeliver = supportsDirectDeliver; if (logger.isTraceEnabled()) { - logger.trace("Setting direct deliverer to " + supportsDirectDeliver + " on queue " + this.getName()); + logger.trace("Setting direct deliverer to {} on queue {}", supportsDirectDeliver, name); } } else { - if (logger.isTraceEnabled()) { - logger.trace("Couldn't set direct deliver back on queue " + this.getName()); - } + logger.trace("Couldn't set direct deliver back on queue {}", name); } } } @@ -1294,15 +1291,11 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { @Override public void forceDelivery() { if (pageSubscription != null && pageSubscription.isPaging()) { - if (logger.isTraceEnabled()) { - logger.trace("Force delivery scheduling depage"); - } + logger.trace("Force delivery scheduling depage"); scheduleDepage(false); } - if (logger.isTraceEnabled()) { - logger.trace("Force delivery delivering async"); - } + logger.trace("Force delivery delivering async"); deliverAsync(); } @@ -1410,9 +1403,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { @Override public void addConsumer(final Consumer consumer) throws Exception { - if (logger.isDebugEnabled()) { - logger.debug(this + " adding consumer " + consumer); - } + logger.debug("{} adding consumer {}", this, consumer); this.setSwept(false); @@ -1835,14 +1826,14 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { * hence no information about delivering statistics should be updated. */ @Override public void acknowledge(final Transaction tx, final MessageReference ref, final AckReason reason, final ServerConsumer consumer, boolean delivering) throws Exception { - boolean transactional = tx != null; + final boolean transactional = tx != null; RefsOperation refsOperation = null; if (transactional) { refsOperation = getRefsOperation(tx, reason, false, delivering); } if (logger.isTraceEnabled()) { - logger.trace(this + " acknowledge tx=" + transactional + " ref=" + ref + ", reason=" + reason + ", consumer=" + consumer); + logger.trace("{} acknowledge tx={} ref={}, reason={}, consumer={}", this, transactional, ref, reason, consumer); } if (nonDestructive && reason == AckReason.NORMAL) { @@ -1851,9 +1842,8 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { } else { decDelivering(ref); } - if (logger.isDebugEnabled()) { - logger.debug("acknowledge tx ignored nonDestructive=true and reason=NORMAL"); - } + + logger.debug("acknowledge tx ignored nonDestructive=true and reason=NORMAL"); } else { if (ref.isPaged()) { if (transactional) { @@ -1998,17 +1988,16 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { @Override public void expire(final MessageReference ref, final ServerConsumer consumer, boolean delivering) throws Exception { if (addressSettings.getExpiryAddress() != null) { - createExpiryResources(); if (logger.isTraceEnabled()) { - logger.trace("moving expired reference " + ref + " to address = " + addressSettings.getExpiryAddress() + " from queue=" + this.getName()); + logger.trace("moving expired reference {} to address = {} from queue={}", ref, addressSettings.getExpiryAddress(), name); } + move(null, addressSettings.getExpiryAddress(), null, ref, false, AckReason.EXPIRED, consumer, null, delivering); } else { - if (logger.isTraceEnabled()) { - logger.trace("expiry is null, just acking expired message for reference " + ref + " from queue=" + this.getName()); - } + logger.trace("expiry is null, just acking expired message for reference {} from queue={}", ref, name); + acknowledge(null, ref, AckReason.EXPIRED, consumer, delivering); } @@ -2413,10 +2402,10 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { } public boolean isExpirationRedundant() { - if (addressSettings.getExpiryAddress() != null && addressSettings.getExpiryAddress().equals(this.address)) { + final SimpleString expiryAddress = addressSettings.getExpiryAddress(); + if (expiryAddress != null && expiryAddress.equals(this.address)) { // check expire with itself would be silly (waste of time) - if (logger.isTraceEnabled()) - logger.trace("Redundant expiration from " + address + " to " + addressSettings.getExpiryAddress()); + logger.trace("Redundant expiration from {} to {}", address, expiryAddress); return true; } @@ -2445,9 +2434,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { LinkedList expiredMessages = new LinkedList<>(); synchronized (QueueImpl.this) { - if (logger.isDebugEnabled()) { - logger.debug("Scanning for expires on " + QueueImpl.this.getName()); - } + logger.debug("Scanning for expires on {}", name); if (iter == null) { if (server.hasBrokerQueuePlugins()) { @@ -2480,7 +2467,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { } } finally { if (!rescheduled) { - logger.debug("Scanning for expires on {} done", QueueImpl.this.getName()); + logger.debug("Scanning for expires on {} done", name); if (server.hasBrokerQueuePlugins()) { try { @@ -2516,8 +2503,10 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { } catch (Exception e) { ActiveMQServerLogger.LOGGER.unableToCommitTransaction(e); } - logger.debug("Expired " + elementsExpired + " references"); + if (logger.isDebugEnabled()) { + logger.debug("Expired {} references", elementsExpired); + } } // If empty we need to schedule depaging to make sure we would depage expired messages as well @@ -2985,7 +2974,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { */ private boolean deliver() { if (logger.isDebugEnabled()) { - logger.debug("Queue " + this.getName() + " doing deliver. messageReferences=" + messageReferences.size() + " with consumers=" + getConsumerCount()); + logger.debug("Queue {} doing deliver. messageReferences={} with consumers={}", name, messageReferences.size(), getConsumerCount()); } scheduledRunners.decrementAndGet(); @@ -3061,18 +3050,15 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { noDelivery++; } else { if (checkExpired(ref)) { - if (logger.isTraceEnabled()) { - logger.trace("Reference " + ref + " being expired"); - } + logger.trace("Reference {} being expired", ref); + removeMessageReference(holder, ref); handled++; consumers.reset(); continue; } - if (logger.isTraceEnabled()) { - logger.trace("Queue " + this.getName() + " is delivering reference " + ref); - } + logger.trace("Queue {} is delivering reference {}", name, ref); final SimpleString groupID = extractGroupID(ref); groupConsumer = getGroupConsumer(groupID); @@ -3145,9 +3131,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { // however I'm keeping this as an assertion case future developers ever change the logic here on this class ActiveMQServerLogger.LOGGER.nonDeliveryHandled(); } else { - if (logger.isDebugEnabled()) { - logger.debug(this + "::All the consumers were busy, giving up now"); - } + logger.debug("{}::All the consumers were busy, giving up now", this); break; } } @@ -3261,9 +3245,8 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { private void scheduleDepage(final boolean scheduleExpiry) { if (!depagePending) { - if (logger.isTraceEnabled()) { - logger.trace("Scheduling depage for queue " + this.getName()); - } + logger.trace("Scheduling depage for queue {}", name); + depagePending = true; pageSubscription.getPagingStore().execute(() -> depage(scheduleExpiry)); } @@ -3286,7 +3269,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { long timeout = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(DELIVERY_TIMEOUT); if (logger.isTraceEnabled()) { - logger.trace("QueueMemorySize before depage on queue=" + this.getName() + " is " + queueMemorySize.getSize()); + logger.trace("QueueMemorySize before depage on queue={} is {}", name, queueMemorySize.getSize()); } this.directDeliver = false; @@ -3303,7 +3286,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { depaged++; PagedReference reference = pageIterator.next(); if (logger.isDebugEnabled()) { - logger.debug("Depaging reference " + reference + " on queue " + this.getName() + " depaged::" + depaged); + logger.debug("Depaging reference {} on queue {} depaged::{}", reference, name, depaged); } addTail(reference, false); pageIterator.remove(); @@ -3313,15 +3296,15 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { } if (logger.isDebugEnabled()) { - int maxSize = pageSubscription.getPagingStore().getPageSizeBytes(); + final int maxSize = pageSubscription.getPagingStore().getPageSizeBytes(); if (depaged == 0 && queueMemorySize.getSize() >= maxSize) { - logger.debug("Couldn't depage any message as the maxSize on the queue was achieved. " + "There are too many pending messages to be acked in reference to the page configuration"); + logger.debug("Couldn't depage any message as the maxSize on the queue was achieved. There are too many pending messages to be acked in reference to the page configuration"); } if (logger.isDebugEnabled()) { - logger.debug("Queue Memory Size after depage on queue=" + this.getName() + " is " + queueMemorySize.getSize() + " with maxSize = " + maxSize + ". Depaged " + depaged + " messages, pendingDelivery=" + messageReferences.size() + ", intermediateMessageReferences= " + intermediateMessageReferences.size() + ", queueDelivering=" + deliveringMetrics.getMessageCount()); - + logger.debug("Queue Memory Size after depage on queue={} is {} with maxSize = {}. Depaged {} messages, pendingDelivery={}, intermediateMessageReferences= {}, queueDelivering={}", + name, queueMemorySize.getSize(), maxSize, depaged, messageReferences.size(), intermediateMessageReferences.size(), deliveringMetrics.getMessageCount()); } } @@ -3348,9 +3331,8 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { private void internalAddRedistributor() { if (redistributor == null && (consumers.isEmpty() || hasUnMatchedPending)) { - if (logger.isTraceEnabled()) { - logger.trace("QueueImpl::Adding redistributor on queue " + this.toString()); - } + logger.trace("QueueImpl::Adding redistributor on queue {}", this); + redistributor = new ConsumerHolder(new Redistributor(this, storageManager, postOffice)); redistributor.consumer.start(); consumers.add(redistributor); @@ -3365,10 +3347,8 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { final boolean ignoreRedeliveryDelay) throws Exception { if (internalQueue) { + logger.trace("Queue {} is an internal queue, no checkRedelivery", name); - if (logger.isTraceEnabled()) { - logger.trace("Queue " + this.getName() + " is an internal queue, no checkRedelivery"); - } // no DLQ check on internal queues // we just need to return statistics on the delivering decDelivering(reference); @@ -3385,7 +3365,8 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { // First check DLA if (maxDeliveries > 0 && deliveryCount >= maxDeliveries) { if (logger.isTraceEnabled()) { - logger.trace("Sending reference " + reference + " to DLA = " + addressSettings.getDeadLetterAddress() + " since ref.getDeliveryCount=" + reference.getDeliveryCount() + "and maxDeliveries=" + maxDeliveries + " from queue=" + this.getName()); + logger.trace("Sending reference {} to DLA = {} since ref.getDeliveryCount={} and maxDeliveries={} from queue={}", + reference, addressSettings.getDeadLetterAddress(), reference.getDeliveryCount(), maxDeliveries, name); } boolean dlaResult = sendToDeadLetterAddress(null, reference, addressSettings.getDeadLetterAddress()); @@ -3397,7 +3378,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { redeliveryDelay = calculateRedeliveryDelay(addressSettings, deliveryCount); if (logger.isTraceEnabled()) { - logger.trace("Setting redeliveryDelay=" + redeliveryDelay + " on reference=" + reference); + logger.trace("Setting redeliveryDelay={} on reference={}", redeliveryDelay, reference); } reference.setScheduledDeliveryTime(timeBase + redeliveryDelay); @@ -3489,8 +3470,11 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { for (SimpleString propName : copyMessage.getPropertyNames()) { if (propName.startsWith(Message.HDR_ROUTE_TO_IDS)) { oldRouteToIDs = (byte[]) copyMessage.removeProperty(propName.toString()); - final String hashcodeToString = oldRouteToIDs.toString(); // don't use Arrays.toString(..) here - logger.debug("Removed property from message: " + propName + " = " + hashcodeToString + " (" + ByteBuffer.wrap(oldRouteToIDs).getLong() + ")"); + + if (logger.isDebugEnabled()) { + final String hashcodeToString = oldRouteToIDs.toString(); // don't use Arrays.toString(..) here + logger.debug("Removed property from message: {} = {} ({})", propName, hashcodeToString, ByteBuffer.wrap(oldRouteToIDs).getLong()); + } // there should only be one of these properties so potentially save some loop iterations break; @@ -3515,7 +3499,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { if (targetBinding == null) { ActiveMQServerLogger.LOGGER.unableToFindTargetQueue(targetNodeID); } else { - logger.debug("Routing on binding: " + targetBinding); + logger.debug("Routing on binding: {}", targetBinding); targetBinding.route(copyMessage, routingContext); } } @@ -3558,7 +3542,10 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { // parse the queue name of the remote queue binding to determine the node ID String temp = remoteQueueBinding.getQueue().getName().toString(); targetNodeID = temp.substring(temp.lastIndexOf(".") + 1); - logger.debug("Message formerly destined for " + oldQueueName + " with ID: " + oldQueueID + " on address " + copyMessage.getAddressSimpleString() + " on node " + targetNodeID); + + if (logger.isDebugEnabled()) { + logger.debug("Message formerly destined for {} with ID: {} on address {} on node {}", oldQueueName, oldQueueID, copyMessage.getAddressSimpleString(), targetNodeID); + } // now that we have the name of the queue we need to look through all the bindings again to find the new remote queue binding // again, we only care about the remote queue bindings @@ -3570,11 +3557,12 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { if (oldQueueName.equals(innerRemoteQueueBinding.getRoutingName()) && targetNodeID.equals(queueSuffix.toString())) { targetBinding = innerRemoteQueueBinding; if (logger.isDebugEnabled()) { - logger.debug("Message now destined for " + innerRemoteQueueBinding.getRoutingName() + " with ID: " + innerRemoteQueueBinding.getRemoteQueueID() + " on address " + copyMessage.getAddress() + " on node " + targetNodeID); + logger.debug("Message now destined for {} with ID: {} on address {} on node {}", + innerRemoteQueueBinding.getRoutingName(), innerRemoteQueueBinding.getRemoteQueueID(), copyMessage.getAddress(), targetNodeID); } break; } else { - logger.debug("Failed to match: " + innerRemoteQueueBinding); + logger.debug("Failed to match: {}", innerRemoteQueueBinding); } } } @@ -3827,9 +3815,8 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { } } - if (logger.isTraceEnabled()) { - logger.trace("Queue " + getName() + " is out of direct delivery as no consumers handled a delivery"); - } + logger.trace("Queue {} is out of direct delivery as no consumers handled a delivery", name); + return false; } } @@ -3907,9 +3894,8 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { private boolean checkExpired(final MessageReference reference) { try { if (reference.getMessage().isExpired()) { - if (logger.isTraceEnabled()) { - logger.trace("Reference " + reference + " is expired"); - } + logger.trace("Reference {} is expired", reference); + reference.handled(); try { @@ -4492,9 +4478,8 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { slowConsumerReaperFuture.cancel(false); slowConsumerReaperFuture = null; slowConsumerReaperRunnable = null; - if (logger.isDebugEnabled()) { - logger.debug("Cancelled slow-consumer-reaper thread for queue \"" + getName() + "\""); - } + + logger.debug("Cancelled slow-consumer-reaper thread for queue \"{}\"", name); } } else { if (slowConsumerReaperRunnable == null) { @@ -4515,7 +4500,8 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { slowConsumerReaperFuture = scheduledExecutor.scheduleWithFixedDelay(slowConsumerReaperRunnable, settings.getSlowConsumerCheckPeriod(), settings.getSlowConsumerCheckPeriod(), TimeUnit.SECONDS); if (logger.isDebugEnabled()) { - logger.debug("Scheduled slow-consumer-reaper thread for queue \"" + getName() + "\"; slow-consumer-check-period=" + settings.getSlowConsumerCheckPeriod() + ", slow-consumer-threshold=" + settings.getSlowConsumerThreshold() + ", slow-consumer-threshold-measurement-unit=" + settings.getSlowConsumerThresholdMeasurementUnit().toString() + ", slow-consumer-policy=" + settings.getSlowConsumerPolicy()); + logger.debug("Scheduled slow-consumer-reaper thread for queue \"{}\"; slow-consumer-check-period={}, slow-consumer-threshold={}, slow-consumer-threshold-measurement-unit={}, slow-consumer-policy={}", + name, settings.getSlowConsumerCheckPeriod(), settings.getSlowConsumerThreshold(), settings.getSlowConsumerThresholdMeasurementUnit(), settings.getSlowConsumerPolicy()); } } @@ -4603,11 +4589,11 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { @Override public void run() { - float queueRate = getRate(); - long queueMessages = getMessageCount(); + final float queueRate = getRate(); + final long queueMessages = getMessageCount(); if (logger.isDebugEnabled()) { - logger.debug(getAddress() + ":" + getName() + " has " + queueMessages + " message(s) and " + getConsumerCount() + " consumer(s) and is receiving messages at a rate of " + queueRate + " msgs/second."); + logger.debug("{}:{} has {} message(s) and {} consumer(s) and is receiving messages at a rate of {} msgs/second.", address, name, queueMessages, getConsumerCount(), queueRate); } final int consumerCount = getConsumerCount(); @@ -4618,9 +4604,7 @@ public class QueueImpl extends CriticalComponentImpl implements Queue { float queueThreshold = thresholdInMsgPerSecond * consumerCount; if (queueRate < queueThreshold && queueMessages < queueThreshold) { - if (logger.isDebugEnabled()) { - logger.debug("Insufficient messages received on queue \"" + getName() + "\" to satisfy slow-consumer-threshold. Skipping inspection of consumer."); - } + logger.debug("Insufficient messages received on queue \"{}\" to satisfy slow-consumer-threshold. Skipping inspection of consumer.", name); return; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueManagerImpl.java index d17d08ed5f..535e7d972a 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueManagerImpl.java @@ -39,9 +39,7 @@ public class QueueManagerImpl extends ReferenceCounterUtil implements QueueManag Queue queue = server.locateQueue(queueName); //the queue may already have been deleted and this is a result of that if (queue == null) { - if (logger.isDebugEnabled()) { - logger.debug("no queue to delete \"" + queueName + "\"."); - } + logger.debug("no queue to delete \"{}\".", queueName); return; } @@ -55,8 +53,9 @@ public class QueueManagerImpl extends ReferenceCounterUtil implements QueueManag long messageCount = queue.getMessageCount(); if (logger.isDebugEnabled()) { - logger.debug("purging queue \"" + queue.getName() + "\": consumerCount = " + consumerCount + "; messageCount = " + messageCount); + logger.debug("purging queue \"{}\": consumerCount = {}; messageCount = {}", queue.getName(), consumerCount, messageCount); } + try { queue.deleteMatchingReferences(QueueImpl.DEFAULT_FLUSH_LIMIT, null, AckReason.KILLED); } catch (Exception e) { @@ -67,11 +66,12 @@ public class QueueManagerImpl extends ReferenceCounterUtil implements QueueManag public static void performAutoDeleteQueue(ActiveMQServer server, Queue queue) { SimpleString queueName = queue.getName(); AddressSettings settings = server.getAddressSettingsRepository().getMatch(queue.getAddress().toString()); + if (logger.isDebugEnabled()) { - logger.debug("deleting auto-created queue \"" + queueName + "\": consumerCount = " + queue.getConsumerCount() + "; messageCount = " + queue.getMessageCount() + "; isAutoDelete = " + queue.isAutoDelete()); + logger.debug("deleting auto-created queue \"{}\": consumerCount = {}; messageCount = {}; isAutoDelete = {}", queueName, queue.getConsumerCount(), queue.getMessageCount(), queue.isAutoDelete()); } - ActiveMQServerLogger.LOGGER.autoRemoveQueue("" + queue.getName(), queue.getID(), "" + queue.getAddress()); + ActiveMQServerLogger.LOGGER.autoRemoveQueue(String.valueOf(queue.getName()), queue.getID(), String.valueOf(queue.getAddress())); try { server.destroyQueue(queueName, null, true, false, false, true); 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 0b74bcc8c9..65f39783c9 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 @@ -110,9 +110,8 @@ public class RefsOperation extends TransactionOperationAbstract { ref.emptyConsumerID(); - if (logger.isTraceEnabled()) { - logger.trace("rolling back " + ref); - } + logger.trace("rolling back {}", ref); + try { if (ref.isAlreadyAcked()) { ackedRefs.add(ref); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ReplicationError.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ReplicationError.java index ac9ad3e7e0..ff3ed994aa 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ReplicationError.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ReplicationError.java @@ -48,12 +48,12 @@ final class ReplicationError implements Interceptor { @Override public boolean intercept(Packet packet, RemotingConnection connection) throws ActiveMQException { - if (packet.getType() != PacketImpl.BACKUP_REGISTRATION_FAILED) + if (packet.getType() != PacketImpl.BACKUP_REGISTRATION_FAILED) { return true; - - if (logger.isTraceEnabled()) { - logger.trace("Received ReplicationError::" + packet); } + + logger.trace("Received ReplicationError::{}", packet); + BackupReplicationStartFailedMessage message = (BackupReplicationStartFailedMessage) packet; switch (message.getRegistrationProblem()) { case ALREADY_REPLICATING: diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java index 4c147972b3..c047171154 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/RoutingContextImpl.java @@ -33,14 +33,9 @@ import org.apache.activemq.artemis.api.core.RoutingType; import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; import org.apache.activemq.artemis.core.server.mirror.MirrorController; import org.apache.activemq.artemis.core.transaction.Transaction; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; public class RoutingContextImpl implements RoutingContext { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - // The pair here is Durable and NonDurable private final Map map = new HashMap<>(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java index 90290354ca..4540b51e7c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScaleDownHandler.java @@ -117,7 +117,7 @@ public class ScaleDownHandler { // perform a loop per address for (SimpleString address : postOffice.getAddresses()) { - logger.debug("Scaling down address " + address); + logger.debug("Scaling down address {}", address); Bindings bindings = postOffice.lookupBindingsForAddress(address); // It will get a list of queues on this address, ordered by the number of messages @@ -152,7 +152,7 @@ public class ScaleDownHandler { final Set queues, final ClientSession clientSession, final ClientProducer producer) throws Exception { - logger.debug("Scaling down messages on address " + address); + logger.debug("Scaling down messages on address {}", address); long messageCount = 0; final HashMap controls = new HashMap<>(); @@ -173,7 +173,7 @@ public class ScaleDownHandler { // compile a list of all the relevant queues and queue iterators for this address for (Queue loopQueue : queues) { - logger.debug("Scaling down messages on address " + address + " / performing loop on queue " + loopQueue); + logger.debug("Scaling down messages on address {} / performing loop on queue {}", address, loopQueue); try (LinkedListIterator messagesIterator = loopQueue.browserIterator()) { @@ -189,7 +189,7 @@ public class ScaleDownHandler { // no need to lookup on itself, we just add it queuesFound.add(controlEntry.getValue()); } else if (controlEntry.getValue().lookup(messageReference)) { - logger.debug("Message existed on queue " + controlEntry.getKey().getID() + " removeID=" + controlEntry.getValue().getQueueID()); + logger.debug("Message existed on queue {} removeID={}", controlEntry.getKey().getID(), controlEntry.getValue().getQueueID()); queuesFound.add(controlEntry.getValue()); } } @@ -206,9 +206,9 @@ public class ScaleDownHandler { if (logger.isDebugEnabled()) { if (messageReference.isPaged()) { - logger.debug("*********************<<<<< Scaling down pdgmessage " + message); + logger.debug("*********************<<<<< Scaling down pdgmessage {}", message); } else { - logger.debug("*********************<<<<< Scaling down message " + message); + logger.debug("*********************<<<<< Scaling down message {}", message); } } @@ -299,7 +299,9 @@ public class ScaleDownHandler { message.putBytesProperty(Message.HDR_SCALEDOWN_TO_IDS.toString(), oldRouteToIDs); } - logger.debug("Scaling down message " + message + " from " + address + " to " + message.getAddress() + " on node " + targetNodeId); + if (logger.isDebugEnabled()) { + logger.debug("Scaling down message {} from {} to {} on node {}", message, address, message.getAddress(), targetNodeId); + } producer.send(message.getAddress(), message); @@ -332,7 +334,7 @@ public class ScaleDownHandler { List preparedTransactions = resourceManager.getPreparedTransactions(); Map queueIDs = new HashMap<>(); for (Xid xid : preparedTransactions) { - logger.debug("Scaling down transaction: " + xid); + logger.debug("Scaling down transaction: {}", xid); Transaction transaction = resourceManager.getTransaction(xid); session.start(xid, XAResource.TMNOFLAGS); List allOperations = transaction.getAllOperations(); @@ -446,11 +448,17 @@ public class ScaleDownHandler { long queueID = getQueueID(session, queue.getName()); if (queueID == -1) { session.createQueue(new QueueConfiguration(queue.getName()).setAddress(addressName).setRoutingType(routingType).setFilterString(queue.getFilter() == null ? null : queue.getFilter().getFilterString()).setDurable(queue.isDurable())); - logger.debug("Failed to get queue ID, creating queue [addressName=" + addressName + ", queueName=" + queue.getName() + ", routingType=" + queue.getRoutingType() + ", filter=" + (queue.getFilter() == null ? "" : queue.getFilter().getFilterString()) + ", durable=" + queue.isDurable() + "]"); + if (logger.isDebugEnabled()) { + logger.debug("Failed to get queue ID, creating queue [addressName={}, queueName={}, routingType={}, filter={}, durable={}]", + addressName, queue.getName(), queue.getRoutingType(), (queue.getFilter() == null ? "" : queue.getFilter().getFilterString()), queue.isDurable()); + } queueID = getQueueID(session, queue.getName()); } - logger.debug("ID for " + queue + " is: " + queueID); + if (logger.isDebugEnabled()) { + logger.debug("ID for {} is: {}", queue, queueID); + } + return queueID; } @@ -461,7 +469,7 @@ public class ScaleDownHandler { ClientMessage managementMessage = session.createMessage(false); ManagementHelper.putAttribute(managementMessage, ResourceNames.QUEUE + queueName, "ID"); session.start(); - logger.debug("Requesting ID for: " + queueName); + logger.debug("Requesting ID for: {}", queueName); ClientMessage reply = requestor.request(managementMessage); result = ManagementHelper.getResult(reply); } @@ -578,13 +586,13 @@ public class ScaleDownHandler { MessageReference initialRef = null; for (int i = 0; i < numberOfScans; i++) { - logger.debug("Iterating on queue " + queue + " while looking for reference " + reference); + logger.debug("Iterating on queue {} while looking for reference {}", queue, reference); memoryIterator = queue.iterator(); while (memoryIterator.hasNext()) { lastRef = memoryIterator.next(); - logger.debug("Iterating on message " + lastRef); + logger.debug("Iterating on message {}", lastRef); if (lastRef.getMessage().equals(reference.getMessage())) { memoryIterator.remove(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerImpl.java index 4fcd909102..881a9b35a2 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerImpl.java @@ -67,7 +67,7 @@ public class ScheduledDeliveryHandlerImpl implements ScheduledDeliveryHandler { if (deliveryTime > 0 && scheduledExecutor != null) { if (logger.isTraceEnabled()) { - logger.trace("Scheduling delivery for " + ref + " to occur at " + deliveryTime); + logger.trace("Scheduling delivery for {} to occur at {}", ref, deliveryTime); } addInPlace(deliveryTime, ref, tail); @@ -167,7 +167,7 @@ public class ScheduledDeliveryHandlerImpl implements ScheduledDeliveryHandler { if (delay < 0) { if (logger.isTraceEnabled()) { - logger.trace("calling another scheduler now as deliverTime " + deliveryTime + " < now=" + now); + logger.trace("calling another scheduler now as deliverTime {} < now={}", deliveryTime, now); } // if delay == 0 we will avoid races between adding the scheduler and finishing it ScheduledDeliveryRunnable runnable = new ScheduledDeliveryRunnable(deliveryTime); @@ -176,14 +176,14 @@ public class ScheduledDeliveryHandlerImpl implements ScheduledDeliveryHandler { ScheduledDeliveryRunnable runnable = new ScheduledDeliveryRunnable(deliveryTime); if (logger.isTraceEnabled()) { - logger.trace("Setting up scheduler for " + deliveryTime + " with a delay of " + delay + " as now=" + now); + logger.trace("Setting up scheduler for {} with a delay of {} as now={}", deliveryTime, delay, now); } runnables.put(deliveryTime, runnable); scheduledExecutor.schedule(runnable, delay, TimeUnit.MILLISECONDS); } else { if (logger.isTraceEnabled()) { - logger.trace("Couldn't make another scheduler as " + deliveryTime + " is already set, now is " + now); + logger.trace("Couldn't make another scheduler as {} is already set, now is {}", deliveryTime, now); } } } @@ -212,15 +212,13 @@ public class ScheduledDeliveryHandlerImpl implements ScheduledDeliveryHandler { // we can't just assume deliveryTime here as we could deliver earlier than what we are supposed to // this is basically a hack to work around an OS or JDK bug! if (logger.isTraceEnabled()) { - logger.trace("Scheduler is working around OS imprecisions on " + - "timing and re-scheduling an executor. now=" + now + - " and deliveryTime=" + deliveryTime); + logger.trace("Scheduler is working around OS imprecisions on timing and re-scheduling an executor. now={} and deliveryTime={}", now, deliveryTime); } ScheduledDeliveryHandlerImpl.this.scheduleDelivery(deliveryTime); } if (logger.isTraceEnabled()) { - logger.trace("Is it " + System.currentTimeMillis() + " now and we are running deliveryTime = " + deliveryTime); + logger.trace("It is {} now and we are running deliveryTime = {}", System.currentTimeMillis(), deliveryTime); } synchronized (scheduledReferences) { @@ -246,13 +244,13 @@ public class ScheduledDeliveryHandlerImpl implements ScheduledDeliveryHandler { } if (logger.isTraceEnabled()) { - logger.trace("sending message " + reference + " to delivery, deliveryTime = " + deliveryTime); + logger.trace("sending message {} to delivery, deliveryTime = {}", reference, deliveryTime); } references.addFirst(reference); } if (logger.isTraceEnabled()) { - logger.trace("Finished loop on deliveryTime = " + deliveryTime); + logger.trace("Finished loop on deliveryTime = {}", deliveryTime); } } @@ -261,7 +259,7 @@ public class ScheduledDeliveryHandlerImpl implements ScheduledDeliveryHandler { Queue queue = entry.getKey(); LinkedList list = entry.getValue(); if (logger.isTraceEnabled()) { - logger.trace("Delivering " + list.size() + " elements on list to queue " + queue); + logger.trace("Delivering {} elements on list to queue {}", list.size(), queue); } queue.addHead(list, true); } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java index 9b07578dfc..e8ed25652b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java @@ -78,7 +78,6 @@ import java.lang.invoke.MethodHandles; */ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -394,18 +393,14 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { AtomicInteger checkInteger = availableCredits; if (callback != null && !callback.hasCredits(this, ref) || checkInteger != null && checkInteger.get() <= 0) { if (logger.isDebugEnabled()) { - logger.debug(this + " is busy for the lack of credits. Current credits = " + - availableCredits + - " Can't receive reference " + - ref); + logger.debug("{} is busy for the lack of credits. Current credits = {} Can't receive reference {}", this, availableCredits, ref); } return HandleStatus.BUSY; } if (server.hasBrokerMessagePlugins() && !server.callBrokerMessagePluginsCanAccept(this, ref)) { - if (logger.isTraceEnabled()) { - logger.trace("Reference " + ref + " is not allowed to be consumed by " + this + " due to message plugin filter."); - } + logger.trace("Reference {} is not allowed to be consumed by {} due to message plugin filter.", ref, this); + return HandleStatus.NO_MATCH; } @@ -422,11 +417,9 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { // This has to be checked inside the lock as the set to null is done inside the lock if (largeMessageDeliverer != null) { if (logger.isDebugEnabled()) { - logger.debug(this + " is busy delivering large message " + - largeMessageDeliverer + - ", can't deliver reference " + - ref); + logger.debug("{} is busy delivering large message {}, can't deliver reference {}", this, largeMessageDeliverer, ref); } + return HandleStatus.BUSY; } final Message message = ref.getMessage(); @@ -436,15 +429,13 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { } if (filter != null && !filter.match(message)) { - if (logger.isTraceEnabled()) { - logger.trace("Reference " + ref + " is a noMatch on consumer " + this); - } + logger.trace("Reference {} is a noMatch on consumer {}", ref, this); + return HandleStatus.NO_MATCH; } - if (logger.isTraceEnabled()) { - logger.trace("ServerConsumerImpl::" + this + " Handling reference " + ref); - } + logger.trace("ServerConsumerImpl::{} Handling reference {}", this, ref); + if (!browseOnly) { if (!preAcknowledge) { deliveringRefs.add(ref); @@ -543,13 +534,14 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { @Override public synchronized void close(final boolean failed) throws Exception { - // Close should only ever be done once per consumer. - if (isClosed) return; + if (isClosed) { + return; + } isClosed = true; if (logger.isTraceEnabled()) { - logger.trace("ServerConsumerImpl::" + this + " being closed with failed=" + failed, new Exception("trace")); + logger.trace("ServerConsumerImpl::{} being closed with failed={}", this, failed, new Exception("trace")); } if (server.hasBrokerConsumerPlugins()) { @@ -571,9 +563,8 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { Transaction tx = new TransactionImpl(storageManager); refs.forEach(ref -> { - if (logger.isTraceEnabled()) { - logger.trace("ServerConsumerImpl::" + this + " cancelling reference " + ref); - } + logger.trace("ServerConsumerImpl::{} cancelling reference {}", this, ref); + ref.getQueue().cancel(tx, ref, true); }); @@ -723,7 +714,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { } if (logger.isTraceEnabled()) { - logger.trace("ServerConsumerImpl::" + this + " Preparing Cancelling list for messageID = " + ref.getMessage().getMessageID() + ", ref = " + ref); + logger.trace("ServerConsumerImpl::{} Preparing Cancelling list for messageID = {}, ref = {}", this, ref.getMessage().getMessageID(), ref); } } @@ -808,9 +799,8 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { @Override public void receiveCredits(final int credits) { if (credits == -1) { - if (logger.isDebugEnabled()) { - logger.debug(this + ":: FlowControl::Received disable flow control message"); - } + logger.debug("{}:: FlowControl::Received disable flow control message", this); + // No flow control availableCredits = null; @@ -818,24 +808,17 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { promptDelivery(); } else if (credits == 0) { // reset, used on slow consumers - logger.debug(this + ":: FlowControl::Received reset flow control message"); + logger.debug("{}:: FlowControl::Received reset flow control message", this); availableCredits.set(0); } else { int previous = availableCredits.getAndAdd(credits); if (logger.isDebugEnabled()) { - logger.debug(this + "::FlowControl::Received " + - credits + - " credits, previous value = " + - previous + - " currentValue = " + - availableCredits.get()); + logger.debug("{}::FlowControl::Received {} credits, previous value = {} currentValue = {}", this, credits, previous, availableCredits.get()); } if (previous <= 0 && previous + credits > 0) { - if (logger.isTraceEnabled()) { - logger.trace(this + "::calling promptDelivery from receiving credits"); - } + logger.trace("{}::calling promptDelivery from receiving credits", this); promptDelivery(); } } @@ -917,7 +900,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { } if (logger.isTraceEnabled()) { - logger.trace("ACKing ref " + ref + " on tx= " + tx + ", consumer=" + this); + logger.trace("ACKing ref {} on tx={}, consumer={}", ref, tx, this); } if (ref == null) { @@ -966,13 +949,12 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { boolean startedTransaction = false; if (logger.isTraceEnabled()) { - logger.trace("individualACK messageID=" + messageID); + logger.trace("individualACK messageID={}", messageID); } if (tx == null) { - if (logger.isTraceEnabled()) { - logger.trace("individualACK starting new TX"); - } + logger.trace("individualACK starting new TX"); + startedTransaction = true; tx = new TransactionImpl(storageManager); } @@ -983,7 +965,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { ref = removeReferenceByID(messageID); if (logger.isTraceEnabled()) { - logger.trace("ACKing ref " + ref + " on tx= " + tx + ", consumer=" + this); + logger.trace("ACKing ref {} on tx={}, consumer={}", ref, tx, this); } if (ref == null) { @@ -1175,10 +1157,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { availableCredits.addAndGet(-packetSize); if (logger.isTraceEnabled()) { - logger.trace(this + "::FlowControl::delivery standard taking " + - packetSize + - " from credits, available now is " + - availableCredits); + logger.trace("{}::FlowControl::delivery standard taking {} from credits, available now is {}", this, packetSize, availableCredits); } } } @@ -1288,10 +1267,8 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { } if (availableCredits != null && availableCredits.get() <= 0) { - if (logger.isTraceEnabled()) { - logger.trace(this + "::FlowControl::delivery largeMessage interrupting as there are no more credits, available=" + - availableCredits); - } + logger.trace("{}::FlowControl::delivery largeMessage interrupting as there are no more credits, available={}", this, availableCredits); + releaseHeapBodyBuffer(); return false; } @@ -1315,11 +1292,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { } if (logger.isTraceEnabled()) { - logger.trace(this + "::FlowControl::" + - " deliver initialpackage with " + - packetSize + - " delivered, available now = " + - availableCredits); + logger.trace("{}::FlowControl:: deliver initialpackage with {} delivered, available now = {}", this, packetSize, availableCredits); } } @@ -1331,10 +1304,8 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { return false; } else { if (availableCredits != null && availableCredits.get() <= 0) { - if (logger.isTraceEnabled()) { - logger.trace(this + "::FlowControl::deliverLargeMessage Leaving loop of send LargeMessage because of credits, available=" + - availableCredits); - } + logger.trace("{}::FlowControl::deliverLargeMessage Leaving loop of send LargeMessage because of credits, available={}", this, availableCredits); + releaseHeapBodyBuffer(); return false; } @@ -1370,10 +1341,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { } if (logger.isTraceEnabled()) { - logger.trace(this + "::FlowControl::largeMessage deliver continuation, packetSize=" + - packetSize + - " available now=" + - availableCredits); + logger.trace("{}::FlowControl::largeMessage deliver continuation, packetSize={} available now={}", this, packetSize, availableCredits); } } @@ -1386,9 +1354,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener { } } - if (logger.isTraceEnabled()) { - logger.trace("Finished deliverLargeMessage"); - } + logger.trace("Finished deliverLargeMessage"); finish(); 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 28a80a4308..67201d3c7e 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 @@ -110,11 +110,9 @@ import java.lang.invoke.MethodHandles; */ public class ServerSessionImpl implements ServerSession, FailureListener { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private boolean securityEnabled = true; private final String securityDomain; @@ -618,10 +616,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener { Notification notification = new Notification(null, CoreNotificationType.CONSUMER_CREATED, props); if (logger.isDebugEnabled()) { - logger.debug("Session with user=" + username + - ", connection=" + this.remotingConnection + - " created a consumer on queue " + unPrefixedQueueName + - ", filter = " + filterString); + logger.debug("Session with user={}, connection={} created a consumer on queue {}, filter = {}", + username, remotingConnection, unPrefixedQueueName, filterString); } managementService.sendNotification(notification); @@ -762,9 +758,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener { } if (logger.isDebugEnabled()) { - logger.debug("Queue " + queueConfiguration.getName() + " created on address " + queueConfiguration.getAddress() + - " with filter=" + queueConfiguration.getFilterString() + " temporary = " + - queueConfiguration.isTemporary() + " durable=" + queueConfiguration.isDurable() + " on session user=" + this.username + ", connection=" + this.remotingConnection); + logger.debug("Queue {} created on address {} with filter={} temporary = {} durable={} on session user={}, connection={}", + queueConfiguration.getName(), queueConfiguration.getAddress(), queueConfiguration.getFilterString(), + queueConfiguration.isTemporary(), queueConfiguration.isDurable(), username, remotingConnection); } return queue; @@ -1127,9 +1123,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener { private void run() { try { - if (logger.isDebugEnabled()) { - logger.debug("deleting temporary queue " + bindingName); - } + logger.debug("deleting temporary queue {}", bindingName); + try { server.destroyQueue(bindingName, null, false, false, true); if (observer != null) { @@ -1243,8 +1238,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { } catch (Exception e) { // just ignored // will log it just in case - logger.debug("Ignored exception while acking messageID " + messageID + - " on a rolledback TX", e); + logger.debug("Ignored exception while acking messageID {} on a rolledback TX", messageID, e); } newTX.rollback(); } else { @@ -1314,9 +1308,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener { @Override public synchronized void commit() throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("Calling commit"); - } + logger.trace("Calling commit"); + try { if (tx != null) { tx.commit(); @@ -1384,9 +1377,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { } else { Transaction theTx = resourceManager.removeTransaction(xid, remotingConnection); - if (logger.isTraceEnabled()) { - logger.trace("XAcommit into " + theTx + ", xid=" + xid); - } + logger.trace("XAcommit into {}, xid={}", theTx, xid); if (theTx == null) { // checked heuristic committed transactions @@ -1396,9 +1387,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { // checked heuristic rolled back transactions throw new ActiveMQXAException(XAException.XA_HEURRB, "transaction has been heuristically rolled back: " + xid); } else { - if (logger.isTraceEnabled()) { - logger.trace("XAcommit into " + theTx + ", xid=" + xid + " cannot find it"); - } + logger.trace("XAcommit into {}, xid={} cannot find it", theTx, xid); throw new ActiveMQXAException(XAException.XAER_NOTA, "Cannot find xid in resource manager: " + xid); } @@ -1533,9 +1522,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { throw new ActiveMQXAException(XAException.XAER_PROTO, msg); } else { Transaction theTx = resourceManager.removeTransaction(xid, remotingConnection); - if (logger.isTraceEnabled()) { - logger.trace("xarollback into " + theTx); - } + logger.trace("xarollback into {}", theTx); if (theTx == null) { // checked heuristic committed transactions @@ -1545,9 +1532,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { // checked heuristic rolled back transactions throw new ActiveMQXAException(XAException.XA_HEURRB, "transaction has ben heuristically rolled back: " + xid); } else { - if (logger.isTraceEnabled()) { - logger.trace("xarollback into " + theTx + ", xid=" + xid + " forcing a rollback regular"); - } + logger.trace("xarollback into {}, xid={} forcing a rollback regular", theTx, xid); try { // jbpapp-8845 @@ -1562,9 +1547,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { } } else { if (theTx.getState() == Transaction.State.SUSPENDED) { - if (logger.isTraceEnabled()) { - logger.trace("xarollback into " + theTx + " sending tx back as it was suspended"); - } + logger.trace("xarollback into {} sending tx back as it was suspended", theTx); // Put it back resourceManager.putTransaction(xid, tx, remotingConnection); @@ -1597,9 +1580,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { tx = newTransaction(xid); - if (logger.isTraceEnabled()) { - logger.trace("xastart into tx= " + tx); - } + logger.trace("xastart into tx= {}", tx); boolean added = resourceManager.putTransaction(xid, tx, remotingConnection); @@ -1620,24 +1601,19 @@ public class ServerSessionImpl implements ServerSession, FailureListener { } if (theTX.isEffective()) { - logger.debug("Client failed with Xid " + xid + " but the server already had it " + theTX.getState()); + logger.debug("Client failed with Xid {} but the server already had it {}", xid, theTX.getState()); tx = null; } else { theTX.markAsRollbackOnly(new ActiveMQException("Can't commit as a Failover happened during the operation")); tx = theTX; } - if (logger.isTraceEnabled()) { - logger.trace("xastart into tx= " + tx); - } + logger.trace("xastart into tx= {}", tx); } @Override public synchronized void xaSuspend() throws Exception { - - if (logger.isTraceEnabled()) { - logger.trace("xasuspend on " + this.tx); - } + logger.trace("xasuspend on {}", tx); if (tx == null) { final String msg = "Cannot suspend, session is not doing work in a transaction "; @@ -1665,9 +1641,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { } else { Transaction theTx = resourceManager.getTransaction(xid); - if (logger.isTraceEnabled()) { - logger.trace("xaprepare into " + ", xid=" + xid + ", tx= " + tx); - } + logger.trace("xaprepare into xid={}, tx={}", xid, tx); if (theTx == null) { final String msg = "Cannot find xid in resource manager: " + xid; @@ -1750,7 +1724,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { ServerConsumer consumer = locateConsumer(consumerID); if (consumer == null) { - logger.debug("There is no consumer with id " + consumerID); + logger.debug("There is no consumer with id {}", consumerID); return; } @@ -1826,7 +1800,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { } if (logger.isTraceEnabled()) { - logger.trace("send(message=" + message + ", direct=" + direct + ") being called"); + logger.trace("send(message={}, direct={}) being called", message, direct); } if (message.getAddress() == null) { 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 f9fa83e672..780327b873 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 @@ -105,7 +105,6 @@ public final class SharedNothingBackupActivation extends Activation implements R @Override public void run() { try { - logger.trace("SharedNothingBackupActivation..start"); synchronized (activeMQServer) { activeMQServer.setState(ActiveMQServerImpl.SERVER_STATE.STARTED); @@ -125,14 +124,15 @@ public final class SharedNothingBackupActivation extends Activation implements R if (!activeMQServer.initialisePart1(scalingDown)) { if (logger.isTraceEnabled()) { - logger.trace("could not initialize part1 " + scalingDown); + logger.trace("could not initialize part1 {}", scalingDown); } return; } synchronized (this) { - if (closed) + if (closed) { return; + } backupQuorum = new SharedNothingBackupQuorum(activeMQServer.getNodeManager(), activeMQServer.getScheduledPool(), networkHealthCheck, replicaPolicy.getQuorumSize(), replicaPolicy.getVoteRetries(), replicaPolicy.getVoteRetryWait(), replicaPolicy.getQuorumVoteWait(), attemptFailBack); activeMQServer.getClusterManager().getQuorumManager().registerQuorum(backupQuorum); activeMQServer.getClusterManager().getQuorumManager().registerQuorumHandler(new ServerConnectVoteHandler(activeMQServer)); @@ -166,8 +166,7 @@ public final class SharedNothingBackupActivation extends Activation implements R ActiveMQServerLogger.LOGGER.backupServerStarted(activeMQServer.getVersion().getFullVersion(), activeMQServer.getNodeManager().getNodeId()); activeMQServer.setState(ActiveMQServerImpl.SERVER_STATE.STARTED); - if (logger.isTraceEnabled()) - logger.trace("Setting server state as started"); + logger.trace("Setting server state as started"); SharedNothingBackupQuorum.BACKUP_ACTIVATION signal; do { @@ -176,20 +175,17 @@ public final class SharedNothingBackupActivation extends Activation implements R return; } - if (logger.isTraceEnabled()) { - logger.trace("looking up the node through nodeLocator.locateNode()"); - } + logger.trace("looking up the node through nodeLocator.locateNode()"); + //locate the first live server to try to replicate nodeLocator.locateNode(); Pair possibleLive = nodeLocator.getLiveConfiguration(); nodeID = nodeLocator.getNodeID(); - if (logger.isDebugEnabled()) { - logger.debug("Connecting towards a possible live, connection information=" + possibleLive + ", nodeID=" + nodeID); - } + logger.debug("Connecting towards a possible live, connection information={}, nodeID={}", possibleLive, nodeID); //in a normal (non failback) scenario if we couldn't find our live server we should fail if (!attemptFailBack) { - logger.debug("attemptFailback=false, nodeID=" + nodeID); + logger.debug("attemptFailback=false, nodeID={}", nodeID); //this shouldn't happen if (nodeID == null) { @@ -207,14 +203,14 @@ public final class SharedNothingBackupActivation extends Activation implements R } else { clusterControl = null; } - if (clusterControl == null) { - if (logger.isTraceEnabled()) { - logger.trace("sleeping " + clusterController.getRetryIntervalForReplicatedCluster() + " it should retry"); - } + if (clusterControl == null) { + final long retryIntervalForReplicatedCluster = clusterController.getRetryIntervalForReplicatedCluster(); + logger.trace("sleeping {} it should retry", retryIntervalForReplicatedCluster); + //its ok to retry here since we haven't started replication yet //it may just be the server has gone since discovery - Thread.sleep(clusterController.getRetryIntervalForReplicatedCluster()); + Thread.sleep(retryIntervalForReplicatedCluster); signal = SharedNothingBackupQuorum.BACKUP_ACTIVATION.ALREADY_REPLICATING; continue; } @@ -227,9 +223,7 @@ public final class SharedNothingBackupActivation extends Activation implements R */ signal = backupQuorum.waitForStatusChange(); - if (logger.isTraceEnabled()) { - logger.trace("Got a signal " + signal + " through backupQuorum.waitForStatusChange()"); - } + logger.trace("Got a signal {} through backupQuorum.waitForStatusChange()", signal); /** * replicationEndpoint will be holding lots of open files. Make sure they get @@ -239,20 +233,16 @@ public final class SharedNothingBackupActivation extends Activation implements R // time to give up if (!activeMQServer.isStarted() || signal == STOP) { if (logger.isTraceEnabled()) { - logger.trace("giving up on the activation:: activemqServer.isStarted=" + activeMQServer.isStarted() + " while signal = " + signal); + logger.trace("giving up on the activation:: activemqServer.isStarted={} while signal = {}", activeMQServer.isStarted(), signal); } return; } else if (signal == FAIL_OVER) { // time to fail over - if (logger.isTraceEnabled()) { - logger.trace("signal == FAIL_OVER, breaking the loop"); - } + logger.trace("signal == FAIL_OVER, breaking the loop"); break; } else if (signal == SharedNothingBackupQuorum.BACKUP_ACTIVATION.FAILURE_REPLICATING || signal == SharedNothingBackupQuorum.BACKUP_ACTIVATION.FAILURE_RETRY) { // something has gone badly run restart from scratch - if (logger.isTraceEnabled()) { - logger.trace("Starting a new thread to stop the server!"); - } + logger.trace("Starting a new thread to stop the server!"); final SharedNothingBackupQuorum.BACKUP_ACTIVATION signalToStop = signal; @@ -260,9 +250,8 @@ public final class SharedNothingBackupActivation extends Activation implements R @Override public void run() { try { - if (logger.isTraceEnabled()) { - logger.trace("Calling activeMQServer.stop() as initialization failed"); - } + logger.trace("Calling activeMQServer.stop() as initialization failed"); + if (activeMQServer.getState() != ActiveMQServer.SERVER_STATE.STOPPED && activeMQServer.getState() != ActiveMQServer.SERVER_STATE.STOPPING) { @@ -293,9 +282,7 @@ public final class SharedNothingBackupActivation extends Activation implements R } while (signal == SharedNothingBackupQuorum.BACKUP_ACTIVATION.ALREADY_REPLICATING); - if (logger.isTraceEnabled()) { - logger.trace("Activation loop finished, current signal = " + signal); - } + logger.trace("Activation loop finished, current signal = {}", signal); activeMQServer.getClusterManager().getQuorumManager().unRegisterQuorum(backupQuorum); @@ -304,9 +291,7 @@ public final class SharedNothingBackupActivation extends Activation implements R throw ActiveMQMessageBundle.BUNDLE.backupServerNotInSync(); } - if (logger.isTraceEnabled()) { - logger.trace("@@@ setReplicaPolicy::" + replicaPolicy); - } + logger.trace("@@@ setReplicaPolicy::{}", replicaPolicy); replicaPolicy.getReplicatedPolicy().setReplicaPolicy(replicaPolicy); activeMQServer.setHAPolicy(replicaPolicy.getReplicatedPolicy()); @@ -346,7 +331,7 @@ public final class SharedNothingBackupActivation extends Activation implements R } } catch (Exception e) { if (logger.isTraceEnabled()) { - logger.trace(e.getMessage() + ", serverStarted=" + activeMQServer.isStarted(), e); + logger.trace("{}, serverStarted={}", e.getMessage(), activeMQServer.isStarted(), e); } if ((e instanceof InterruptedException || e instanceof IllegalStateException) && !activeMQServer.isStarted()) // do not log these errors if the server is being stopped. @@ -357,9 +342,8 @@ public final class SharedNothingBackupActivation extends Activation implements R private static ClusterControl tryConnectToNodeInReplicatedCluster(ClusterController clusterController, TransportConfiguration tc) { try { - if (logger.isTraceEnabled()) { - logger.trace("Calling clusterController.connectToNodeInReplicatedCluster(" + tc + ")"); - } + logger.trace("Calling clusterController.connectToNodeInReplicatedCluster({})", tc); + if (tc != null) { return clusterController.connectToNodeInReplicatedCluster(tc); } @@ -480,8 +464,7 @@ public final class SharedNothingBackupActivation extends Activation implements R @Override public void onLiveStopping(ReplicationLiveIsStoppingMessage.LiveStopping finalMessage) throws ActiveMQException { if (logger.isTraceEnabled()) { - logger.trace("Remote fail-over, got message=" + finalMessage + ", backupUpToDate=" + - backupUpToDate); + logger.trace("Remote fail-over, got message={}, backupUpToDate={}", finalMessage, backupUpToDate); } if (!activeMQServer.getHAPolicy().isBackup() || activeMQServer.getHAPolicy().isSharedStore()) { throw new ActiveMQInternalErrorException(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java index bae9b592ec..9adc4236ce 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedNothingLiveActivation.java @@ -104,7 +104,8 @@ public class SharedNothingLiveActivation extends LiveActivation { if (replicatedPolicy.isCheckForLiveServer() && isNodeIdUsed()) { //set for when we failback if (logger.isTraceEnabled()) { - logger.trace("setting up replicatedPolicy.getReplicaPolicy for back start, replicaPolicy::{}, isBackup={}, server={}", replicatedPolicy.getReplicaPolicy(), replicatedPolicy.isBackup(), activeMQServer); + logger.trace("setting up replicatedPolicy.getReplicaPolicy for back start, replicaPolicy::{}, isBackup={}, server={}", + replicatedPolicy.getReplicaPolicy(), replicatedPolicy.isBackup(), activeMQServer); } replicatedPolicy.getReplicaPolicy().setReplicatedPolicy(replicatedPolicy); activeMQServer.setHAPolicy(replicatedPolicy.getReplicaPolicy()); @@ -272,9 +273,8 @@ public class SharedNothingLiveActivation extends LiveActivation { @Override public void run() { try { - if (logger.isTraceEnabled()) { - logger.trace("Calling activeMQServer.stop() to stop the server"); - } + logger.trace("Calling activeMQServer.stop() to stop the server"); + activeMQServer.stop(); } catch (Exception e) { ActiveMQServerLogger.LOGGER.errorRestartingBackupServer(activeMQServer, e); @@ -445,9 +445,7 @@ public class SharedNothingLiveActivation extends LiveActivation { ClientSession clientSession = clientSessionFactory.createSession(user, password, false, false, false, false, 0)) { result = true; } catch (Exception e) { - if (logger.isDebugEnabled()) { - logger.debug("isActive check failed", e); - } + logger.debug("isActive check failed", e); } return result; 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 80af5743cc..d14e1cec81 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 @@ -288,7 +288,7 @@ public final class SharedStoreBackupActivation extends Activation { @Override public void run() { try { - logger.debug(activeMQServer + "::Stopping live node in favor of failback"); + logger.debug("{}::Stopping live node in favor of failback", activeMQServer); NodeManager nodeManager = activeMQServer.getNodeManager(); activeMQServer.stop(true, false, true); @@ -306,7 +306,7 @@ public final class SharedStoreBackupActivation extends Activation { return; activeMQServer.setHAPolicy(sharedStoreSlavePolicy); - logger.debug(activeMQServer + "::Starting backup node now after failback"); + logger.debug("{}::Starting backup node now after failback", activeMQServer); activeMQServer.start(); LockListener lockListener = activeLockListener; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java index 64ced96f0f..b4e2f2ac73 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/SharedStoreLiveActivation.java @@ -61,9 +61,7 @@ public final class SharedStoreLiveActivation extends LiveActivation { activeMQServer.checkJournalDirectory(); - if (logger.isDebugEnabled()) { - logger.debug("First part initialization on " + this); - } + logger.debug("First part initialization on {}", this); if (!activeMQServer.initialisePart1(false)) return; @@ -73,9 +71,8 @@ public final class SharedStoreLiveActivation extends LiveActivation { * looks like we've failed over at some point need to inform that we are the * backup so when the current live goes down they failover to us */ - if (logger.isDebugEnabled()) { - logger.debug("announcing backup to the former live" + this); - } + logger.debug("announcing backup to the former live {}", this); + activeMQServer.getBackupManager().start(); if (!sharedStoreMasterPolicy.isWaitForActivation()) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/TransientQueueManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/TransientQueueManagerImpl.java index c30d421ad3..197f5e8d80 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/TransientQueueManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/TransientQueueManagerImpl.java @@ -37,9 +37,7 @@ public class TransientQueueManagerImpl extends ReferenceCounterUtil implements T private void doIt() { try { - if (logger.isDebugEnabled()) { - logger.debug("deleting temporary queue " + queueName); - } + logger.debug("deleting temporary queue {}", queueName); try { server.destroyQueue(queueName, null, false); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ArtemisMBeanServerGuard.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ArtemisMBeanServerGuard.java index 128f15d65d..735cb35210 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ArtemisMBeanServerGuard.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ArtemisMBeanServerGuard.java @@ -129,7 +129,7 @@ public class ArtemisMBeanServerGuard implements InvocationHandler { try { objectName = ObjectName.getInstance(object); } catch (MalformedObjectNameException e) { - logger.debug("can't check invoke rights as object name invalid: " + object, e); + logger.debug("can't check invoke rights as object name invalid: {}", object, e); return false; } if (canBypassRBAC(objectName)) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementConnector.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementConnector.java index dd33d174d8..8b8aecbe68 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementConnector.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/ManagementConnector.java @@ -94,7 +94,7 @@ public class ManagementConnector implements ActiveMQComponent { connectorServerFactory.setTrustStorePassword(configuration.getTrustStorePassword()); connectorServerFactory.init(); } catch (Exception e) { - logger.error("Can't init JMXConnectorServer: " + e.getMessage(), e); + logger.error("Can't init JMXConnectorServer:", e); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java index e0f4273a28..d7c3a3342f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java @@ -257,9 +257,7 @@ public class ManagementServiceImpl implements ManagementService { registerAddressMeters(addressInfo, addressControl); - if (logger.isDebugEnabled()) { - logger.debug("registered address " + objectName); - } + logger.debug("registered address {}", objectName); } @Override @@ -291,9 +289,7 @@ public class ManagementServiceImpl implements ManagementService { final StorageManager storageManager) throws Exception { if (addressInfo.isInternal()) { - if (logger.isDebugEnabled()) { - logger.debug("won't register internal queue: " + queue); - } + logger.debug("won't register internal queue: {}", queue); return; } @@ -308,9 +304,7 @@ public class ManagementServiceImpl implements ManagementService { registerInRegistry(ResourceNames.QUEUE + queue.getName(), queueControl); registerQueueMeters(queue); - if (logger.isDebugEnabled()) { - logger.debug("registered queue " + objectName); - } + logger.debug("registered queue {}", objectName); } @Override @@ -377,9 +371,7 @@ public class ManagementServiceImpl implements ManagementService { registerInJMX(objectName, divertControl); registerInRegistry(ResourceNames.DIVERT + divert.getUniqueName(), divertControl); - if (logger.isDebugEnabled()) { - logger.debug("registered divert " + objectName); - } + logger.debug("registered divert {}", objectName); } @Override @@ -494,9 +486,7 @@ public class ManagementServiceImpl implements ManagementService { registerInJMX(objectName, connectionRouterControl); registerInRegistry(ResourceNames.CONNECTION_ROUTER + router.getName(), connectionRouterControl); - if (logger.isDebugEnabled()) { - logger.debug("registered connection router " + objectName); - } + logger.debug("registered connection router {}", objectName); } @Override @@ -535,9 +525,8 @@ public class ManagementServiceImpl implements ManagementService { } String resourceName = message.getStringProperty(ManagementHelper.HDR_RESOURCE_NAME); - if (logger.isDebugEnabled()) { - logger.debug("handling management message for " + resourceName); - } + + logger.debug("handling management message for {}", resourceName); String operation = message.getStringProperty(ManagementHelper.HDR_OPERATION_NAME); @@ -781,9 +770,8 @@ public class ManagementServiceImpl implements ManagementService { @Override public void sendNotification(final Notification notification) throws Exception { if (logger.isTraceEnabled()) { - logger.trace("Sending Notification = " + notification + - ", notificationEnabled=" + notificationsEnabled + - " messagingServerControl=" + messagingServerControl); + logger.trace("Sending Notification = {}, notificationEnabled={} messagingServerControl={}", + notification, notificationsEnabled, messagingServerControl); } // This needs to be synchronized since we need to ensure notifications are processed in strict sequence synchronized (this) { @@ -807,9 +795,8 @@ public class ManagementServiceImpl implements ManagementService { // Note at backup initialisation we don't want to send notifications either // https://jira.jboss.org/jira/browse/HORNETQ-317 if (messagingServer == null || !messagingServer.isActive()) { - if (logger.isDebugEnabled()) { - logger.debug("ignoring message " + notification + " as the server is not initialized"); - } + logger.debug("ignoring message {} as the server is not initialized", notification); + return; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/MetricsManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/MetricsManager.java index 448b5c46b0..fd771129d4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/MetricsManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/metrics/MetricsManager.java @@ -144,9 +144,7 @@ public class MetricsManager { for (Gauge.Builder gaugeBuilder : newMeters) { Gauge gauge = gaugeBuilder.register(meterRegistry); meters.add(gauge); - if (log.isDebugEnabled()) { - log.debug("Registered meter: " + gauge.getId()); - } + log.debug("Registered meter: {}", gauge.getId()); } return meters; }); @@ -159,9 +157,7 @@ public class MetricsManager { } for (Meter meter : meters) { Meter removed = meterRegistry.remove(meter); - if (log.isDebugEnabled()) { - log.debug("Unregistered meter: " + removed.getId()); - } + log.debug("Unregistered meter: {}", removed.getId()); } return null; }); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/BrokerMessageAuthorizationPlugin.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/BrokerMessageAuthorizationPlugin.java index 2f530ff399..62806025c0 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/BrokerMessageAuthorizationPlugin.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/BrokerMessageAuthorizationPlugin.java @@ -69,13 +69,13 @@ public class BrokerMessageAuthorizationPlugin implements ActiveMQServerPlugin { Subject subject = getSubject(consumer); if (subject == null) { if (logger.isDebugEnabled()) { - logger.debug("Subject not found for consumer: " + consumer.getID()); + logger.debug("Subject not found for consumer: {}", consumer.getID()); } return false; } boolean permitted = new RolePrincipal(requiredRole).implies(subject); if (!permitted && logger.isDebugEnabled()) { - logger.debug("Message consumer: " + consumer.getID() + " does not have required role `" + requiredRole + "` needed to receive message: " + reference.getMessageID()); + logger.debug("Message consumer: {} does not have required role `{}` needed to receive message: {}", consumer.getID(), requiredRole, reference.getMessageID()); } return permitted; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/LoggingActiveMQServerPlugin.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/LoggingActiveMQServerPlugin.java index b26939e97d..541034cd2e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/LoggingActiveMQServerPlugin.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/LoggingActiveMQServerPlugin.java @@ -700,13 +700,13 @@ public class LoggingActiveMQServerPlugin implements ActiveMQServerPlugin, Serial */ private void dumpConfiguration() { if (logger.isDebugEnabled()) { - logger.debug("LoggingPlugin logAll=" + logAll); - logger.debug("LoggingPlugin logConnectionEvents=" + logConnectionEvents); - logger.debug("LoggingPlugin logSessionEvents=" + logSessionEvents); - logger.debug("LoggingPlugin logConsumerEvents=" + logConsumerEvents); - logger.debug("LoggingPlugin logSendingEvents=" + logSendingEvents); - logger.debug("LoggingPlugin logDeliveringEvents=" + logDeliveringEvents); - logger.debug("LoggingPlugin logInternalEvents=" + logInternalEvents); + logger.debug("LoggingPlugin logAll={}", logAll); + logger.debug("LoggingPlugin logConnectionEvents={}", logConnectionEvents); + logger.debug("LoggingPlugin logSessionEvents={}", logSessionEvents); + logger.debug("LoggingPlugin logConsumerEvents={}", logConsumerEvents); + logger.debug("LoggingPlugin logSendingEvents={}", logSendingEvents); + logger.debug("LoggingPlugin logDeliveringEvents={}", logDeliveringEvents); + logger.debug("LoggingPlugin logInternalEvents={}", logInternalEvents); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/NotificationActiveMQServerPlugin.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/NotificationActiveMQServerPlugin.java index 0f232e9ea0..fe7d90cea3 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/NotificationActiveMQServerPlugin.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/plugin/impl/NotificationActiveMQServerPlugin.java @@ -121,7 +121,7 @@ public class NotificationActiveMQServerPlugin implements ActiveMQServerPlugin { managementService.sendNotification(new Notification(null, CoreNotificationType.MESSAGE_DELIVERED, props)); } } catch (Exception e) { - logger.warn("Error sending notification: " + CoreNotificationType.MESSAGE_DELIVERED, e.getMessage(), e); + logger.warn("Error sending notification: {}", CoreNotificationType.MESSAGE_DELIVERED, e); } } } @@ -147,7 +147,7 @@ public class NotificationActiveMQServerPlugin implements ActiveMQServerPlugin { managementService.sendNotification(new Notification(null, CoreNotificationType.MESSAGE_EXPIRED, props)); } } catch (Exception e) { - logger.warn("Error sending notification: " + CoreNotificationType.MESSAGE_EXPIRED, e.getMessage(), e); + logger.warn("Error sending notification: {}", CoreNotificationType.MESSAGE_EXPIRED, e); } } } @@ -163,7 +163,7 @@ public class NotificationActiveMQServerPlugin implements ActiveMQServerPlugin { managementService.sendNotification(new Notification(null, type, props)); } catch (Exception e) { - logger.warn("Error sending notification: " + type, e.getMessage(), e); + logger.warn("Error sending notification: {}", type, e); } } } @@ -181,7 +181,7 @@ public class NotificationActiveMQServerPlugin implements ActiveMQServerPlugin { managementService.sendNotification(new Notification(null, type, props)); } catch (Exception e) { - logger.warn("Error sending notification: " + type, e.getMessage(), e); + logger.warn("Error sending notification: {}", type, e); } } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java index 7235d01b32..30eda77d0d 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/reload/ReloadManagerImpl.java @@ -116,7 +116,7 @@ public class ReloadManagerImpl extends ActiveMQScheduledComponent implements Rel long fileModified = file.lastModified(); if (logger.isDebugEnabled()) { - logger.debug("Validating lastModified " + lastModified + " modified = " + fileModified + " on " + uri); + logger.debug("Validating lastModified {} modified = {} on {}", lastModified, fileModified, uri); } if ((lastModified > 0 && fileModified > lastModified) || diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/replay/ReplayManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/replay/ReplayManager.java index 8ddeaedcfe..c900948a92 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/replay/ReplayManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/replay/ReplayManager.java @@ -87,9 +87,8 @@ public class ReplayManager { } private void actualReplay(Date start, Date end, String sourceAddress, String targetAddressParameter, String filterStr) throws Exception { - if (logger.isDebugEnabled()) { - logger.debug("Replay::" + sourceAddress); - } + logger.debug("Replay::{}", sourceAddress); + if (sourceAddress == null) { throw new NullPointerException("sourceAddress"); } @@ -128,26 +127,22 @@ public class ReplayManager { for (JournalFile file : files) { if (start != null || end != null) { - long fileEpochTime = journal.getDatePortionMillis(file.getFile().getFileName()); + final String fileName = file.getFile().getFileName(); + final long fileEpochTime = journal.getDatePortionMillis(fileName); if (logger.isDebugEnabled()) { - String datePortion = journal.getDatePortion(file.getFile().getFileName()); - logger.debug("Evaluating replay for file " + file.getFile().getFileName() + ", datePortion=" + datePortion + "\n" + - "\tInterval evaluated: start(" + start + ") --- file(" + new Date(fileEpochTime) + ") --- end(" + end + ")\n" + - "\tepoch times: start(" + start.getTime() + ") --- file(" + fileEpochTime + ") + end(" + end.getTime() + ")"); + String datePortion = journal.getDatePortion(fileName); + logger.debug("Evaluating replay for file {}, datePortion={}\n\tInterval evaluated: start({}) --- file({}) --- end({})\n\tepoch times: start({}) --- file({}) + end({})", + fileName, datePortion, start, new Date(fileEpochTime), end, start.getTime(), fileEpochTime, end.getTime()); } if (start != null && fileEpochTime < start.getTime()) { - if (logger.isDebugEnabled()) { - logger.debug("File " + file.getFile().getFileName() + " being skipped on start comparison"); - } + logger.debug("File {} being skipped on start comparison", fileName); continue; } if (end != null && fileEpochTime > end.getTime()) { - if (logger.isDebugEnabled()) { - logger.debug("File " + file.getFile().getFileName() + " being skipped on end comparison"); - } + logger.debug("File {} being skipped on end comparison", fileName); continue; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/ConnectionRouter.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/ConnectionRouter.java index 10323fd999..5f40c96b18 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/ConnectionRouter.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/ConnectionRouter.java @@ -155,9 +155,7 @@ public class ConnectionRouter implements ActiveMQComponent { public TargetResult getTarget(Connection connection, String clientID, String username) { if (clientID != null && clientID.startsWith(ConnectionRouter.CLIENT_ID_PREFIX)) { - if (logger.isDebugEnabled()) { - logger.debug("The clientID [" + clientID + "] starts with ConnectionRouter.CLIENT_ID_PREFIX"); - } + logger.debug("The clientID [{}] starts with ConnectionRouter.CLIENT_ID_PREFIX", clientID); return localTarget; } @@ -172,7 +170,7 @@ public class ConnectionRouter implements ActiveMQComponent { if (this.localTargetFilter != null && this.localTargetFilter.matcher(key).matches()) { if (logger.isDebugEnabled()) { - logger.debug("The " + keyType + "[" + key + "] matches the localTargetFilter " + localTargetFilter.pattern()); + logger.debug("The {}[{}] matches the localTargetFilter {}", keyType, key, localTargetFilter.pattern()); } return localTarget; @@ -185,42 +183,42 @@ public class ConnectionRouter implements ActiveMQComponent { TargetResult result = null; if (cache != null) { - String nodeId = cache.get(key); + final String nodeId = cache.get(key); if (logger.isDebugEnabled()) { - logger.debug("The cache returns target [" + nodeId + "] for " + keyType + "[" + key + "]"); + logger.debug("The cache returns target [{}] for {}[{}]", nodeId, keyType, key); } if (nodeId != null) { Target target = pool.getReadyTarget(nodeId); if (target != null) { if (logger.isDebugEnabled()) { - logger.debug("The target [" + nodeId + "] is ready for " + keyType + "[" + key + "]"); + logger.debug("The target [{}] is ready for {}[{}]", nodeId, keyType, key); } return new TargetResult(target); } if (logger.isDebugEnabled()) { - logger.debug("The target [" + nodeId + "] is not ready for " + keyType + "[" + key + "]"); + logger.debug("The target [{}] is not ready for {}[{}]", nodeId, keyType, key); } } } - List targets = pool.getTargets(); - - Target target = policy.selectTarget(targets, key); + final List targets = pool.getTargets(); + final Target target = policy.selectTarget(targets, key); if (logger.isDebugEnabled()) { - logger.debug("The policy selects [" + target + "] from " + targets + " for " + keyType + "[" + key + "]"); + logger.debug("The policy selects [{}] from {} for {}[{}]", target, targets, keyType, key); } if (target != null) { result = new TargetResult(target); if (cache != null) { if (logger.isDebugEnabled()) { - logger.debug("Caching " + keyType + "[" + key + "] for [" + target + "]"); + logger.debug("Caching {}[{}] for [{}]", keyType, key, target); } + cache.put(key, target.getNodeID()); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/ConnectionRouterManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/ConnectionRouterManager.java index 14df523a39..0b6e5ffd88 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/ConnectionRouterManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/ConnectionRouterManager.java @@ -158,7 +158,7 @@ public final class ConnectionRouterManager implements ActiveMQComponent { if (connector != null) { staticConnectors.add(connector); } else { - logger.warn("Static connector not found: " + config.isLocalTargetEnabled()); + logger.warn("Static connector not found: {}", config.isLocalTargetEnabled()); } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/caches/LocalCache.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/caches/LocalCache.java index 5c1bf323e2..dfc24460ed 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/caches/LocalCache.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/caches/LocalCache.java @@ -136,4 +136,4 @@ public class LocalCache implements Cache, RemovalListener { } } } -} \ No newline at end of file +} diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/policies/LeastConnectionsPolicy.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/policies/LeastConnectionsPolicy.java index d1385c4cf5..ed91a1bc43 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/policies/LeastConnectionsPolicy.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/policies/LeastConnectionsPolicy.java @@ -53,20 +53,18 @@ public class LeastConnectionsPolicy extends RoundRobinPolicy { Integer connectionCount = target.getAttribute("broker", "ConnectionCount", Integer.class, 3000); if (connectionCount < connectionCountThreshold) { - if (logger.isDebugEnabled()) { - logger.debug("Updating the connection count to 0/" + connectionCount + " for the target " + target); - } + logger.debug("Updating the connection count to 0/{} for the target {}", connectionCount, target); connectionCount = 0; - } else if (logger.isDebugEnabled()) { - logger.debug("Updating the connection count to " + connectionCount + " for the target " + target); + } else { + logger.debug("Updating the connection count to {} for the target {}", connectionCount, target); } connectionCountCache.put(target, connectionCount); return true; } catch (Exception e) { - logger.warn("Error on updating the connectionCount for the target " + target, e); + logger.warn("Error on updating the connectionCount for the target {}", target, e); return false; } @@ -115,9 +113,7 @@ public class LeastConnectionsPolicy extends RoundRobinPolicy { leastTargets.add(target); } - if (logger.isDebugEnabled()) { - logger.debug("LeastConnectionsPolicy.sortedTargets: " + sortedTargets); - } + logger.debug("LeastConnectionsPolicy.sortedTargets: {}", sortedTargets); List selectedTargets = sortedTargets.firstEntry().getValue(); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/pools/AbstractPool.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/pools/AbstractPool.java index 52a2b86fc7..919672b153 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/pools/AbstractPool.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/pools/AbstractPool.java @@ -134,7 +134,7 @@ public abstract class AbstractPool implements Pool { } if (logger.isDebugEnabled()) { - logger.debug("Ready targets are " + targets + " / " + targetMonitors + " and quorumSize is " + quorumSize); + logger.debug("Ready targets are {} / {} and quorumSize is {}", targets, targetMonitors, quorumSize); } return targets.size() < quorumSize ? Collections.emptyList() : targets; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/targets/TargetMonitor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/targets/TargetMonitor.java index 3304f5dc3b..376055d665 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/targets/TargetMonitor.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/routing/targets/TargetMonitor.java @@ -71,7 +71,7 @@ public class TargetMonitor extends ActiveMQScheduledComponent implements TargetL try { target.disconnect(); } catch (Exception e) { - logger.debug("Error on disconnecting target " + target, e); + logger.debug("Error on disconnecting target {}", target, e); } } @@ -79,24 +79,20 @@ public class TargetMonitor extends ActiveMQScheduledComponent implements TargetL public void run() { try { if (!target.isConnected()) { - if (logger.isDebugEnabled()) { - logger.debug("Connecting to " + target); - } + logger.debug("Connecting to {}", target); target.connect(); } targetReady = target.checkReadiness() && checkTargetProbes(); - if (logger.isDebugEnabled()) { - if (targetReady) { - logger.debug(target + " is ready"); - } else { - logger.debug(target + " is not ready"); - } + if (targetReady) { + logger.debug("{} is ready", target); + } else { + logger.debug("{} is not ready", target); } } catch (Exception e) { - logger.warn("Error monitoring " + target, e); + logger.warn("Error monitoring {}", target, e); targetReady = false; } @@ -105,7 +101,7 @@ public class TargetMonitor extends ActiveMQScheduledComponent implements TargetL private boolean checkTargetProbes() { for (TargetProbe targetProbe : targetProbes) { if (!targetProbe.check(target)) { - logger.info(targetProbe.getName() + " has failed on " + target); + logger.info("{} has failed on {}", targetProbe.getName(), target); return false; } } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/HierarchicalObjectRepository.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/HierarchicalObjectRepository.java index 3bf2808f04..a202c0f366 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/HierarchicalObjectRepository.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/HierarchicalObjectRepository.java @@ -306,7 +306,7 @@ public class HierarchicalObjectRepository implements HierarchicalRepository { public static void registerProtocol(ProtocolManagerFactory manager) { Persister[] messagePersisters = manager.getPersister(); if (messagePersisters == null || messagePersisters.length == 0) { - logger.debug("Cannot find persister for " + manager); + logger.debug("Cannot find persister for {}", manager); } else { for (Persister p : messagePersisters) { registerPersister(p); diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQBasicSecurityManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQBasicSecurityManager.java index 412ed5c188..09cfb841d1 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQBasicSecurityManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQBasicSecurityManager.java @@ -92,9 +92,7 @@ public class ActiveMQBasicSecurityManager implements ActiveMQSecurityManager5, U } } } catch (Exception e) { - if (logger.isDebugEnabled()) { - logger.debug("Couldn't validate user", e); - } + logger.debug("Couldn't validate user", e); } return null; @@ -111,9 +109,10 @@ public class ActiveMQBasicSecurityManager implements ActiveMQSecurityManager5, U final CheckType checkType, final String address) { boolean authorized = SecurityManagerUtil.authorize(subject, roles, checkType, rolePrincipalClass); - - if (logger.isTraceEnabled()) { - logger.trace("user " + (authorized ? " is " : " is NOT ") + "authorized"); + if (authorized) { + logger.trace("user is authorized"); + } else { + logger.trace("user is NOT authorized"); } return authorized; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQJAASSecurityManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQJAASSecurityManager.java index c28abe9f16..3c84e9eb7c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQJAASSecurityManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/ActiveMQJAASSecurityManager.java @@ -92,9 +92,7 @@ public class ActiveMQJAASSecurityManager implements ActiveMQSecurityManager5 { try { return getAuthenticatedSubject(user, password, remotingConnection, securityDomain); } catch (LoginException e) { - if (logger.isDebugEnabled()) { - logger.debug("Couldn't validate user", e); - } + logger.debug("Couldn't validate user", e); return null; } } @@ -111,8 +109,10 @@ public class ActiveMQJAASSecurityManager implements ActiveMQSecurityManager5 { final String address) { boolean authorized = SecurityManagerUtil.authorize(subject, roles, checkType, rolePrincipalClass); - if (logger.isTraceEnabled()) { - logger.trace("user " + (authorized ? " is " : " is NOT ") + "authorized"); + if (authorized) { + logger.trace("user is authorized"); + } else { + logger.trace("user is NOT authorized"); } return authorized; diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/AbstractPrincipalLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/AbstractPrincipalLoginModule.java index e44a2848ab..ed807ef5f9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/AbstractPrincipalLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/AbstractPrincipalLoginModule.java @@ -73,7 +73,7 @@ public abstract class AbstractPrincipalLoginModule implements AuditLoginModule { if (!authenticatedPrincipals.isEmpty()) { loginSucceeded = true; } - logger.debug("login " + authenticatedPrincipals); + logger.debug("login {}", authenticatedPrincipals); return loginSucceeded; } @@ -87,7 +87,7 @@ public abstract class AbstractPrincipalLoginModule implements AuditLoginModule { clear(); - logger.debug("commit, result: " + result); + logger.debug("commit, result: {}", result); return result; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java index 684b12eb34..12673ba1d9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/CertificateLoginModule.java @@ -86,7 +86,7 @@ public abstract class CertificateLoginModule extends PropertiesLoader implements } if (debug) { - logger.debug("Certificate for user: " + username); + logger.debug("Certificate for user: {}", username); } return true; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ExternalCertificateLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ExternalCertificateLoginModule.java index cb4359e510..3284843aa5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ExternalCertificateLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ExternalCertificateLoginModule.java @@ -73,7 +73,10 @@ public class ExternalCertificateLoginModule implements AuditLoginModule { userName = certificates[0].getSubjectDN().getName(); } - logger.debug("Certificates: " + Arrays.toString(certificates) + ", userName: " + userName); + if (logger.isDebugEnabled()) { + logger.debug("Certificates: {}, userName: {}", Arrays.toString(certificates), userName); + } + return userName != null; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java index 94f0cc56d0..4a4822908c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/GuestLoginModule.java @@ -73,7 +73,7 @@ public class GuestLoginModule implements AuditLoginModule { principals.add(new RolePrincipal(roleName)); if (debug) { - logger.debug("Initialized debug=" + debug + " guestUser=" + userName + " guestGroup=" + roleName); + logger.debug("Initialized debug={} guestUser={} guestGroup={}", debug, userName, roleName); } } @@ -96,7 +96,7 @@ public class GuestLoginModule implements AuditLoginModule { } } if (debug) { - logger.debug("Guest login " + loginSucceeded); + logger.debug("Guest login {}", loginSucceeded); } return loginSucceeded; } @@ -108,7 +108,7 @@ public class GuestLoginModule implements AuditLoginModule { } if (debug) { - logger.debug("commit: " + loginSucceeded); + logger.debug("commit: {}", loginSucceeded); } return loginSucceeded; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java index c640682185..8013becf30 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/InVMLoginModule.java @@ -95,7 +95,7 @@ public class InVMLoginModule implements AuditLoginModule { } loginSucceeded = true; - logger.debug("login " + user); + logger.debug("login {}", user); return loginSucceeded; } @@ -120,7 +120,7 @@ public class InVMLoginModule implements AuditLoginModule { // will whack loginSucceeded clear(); - logger.debug("commit, result: " + result); + logger.debug("commit, result: {}", result); return result; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java index 86201e9cd4..8eae7a8188 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModule.java @@ -291,9 +291,7 @@ public class LDAPLoginModule implements AuditLoginModule { private void resolveRolesForDN(DirContext context, String dn, String username, List roles) throws NamingException { addRoles(context, dn, username, roles); - if (logger.isDebugEnabled()) { - logger.debug("Roles " + roles + " for user " + username); - } + logger.debug("Roles {} for user {}", roles, username); for (String role : roles) { groups.add(new RolePrincipal(role)); } @@ -302,9 +300,7 @@ public class LDAPLoginModule implements AuditLoginModule { private String resolveDN(String username, List roles) throws FailedLoginException { String dn = null; - if (logger.isDebugEnabled()) { - logger.debug("Create the LDAP initial context."); - } + logger.debug("Create the LDAP initial context."); try { openContext(); } catch (Exception ne) { @@ -343,8 +339,8 @@ public class LDAPLoginModule implements AuditLoginModule { if (logger.isDebugEnabled()) { logger.debug("Get the user DN."); logger.debug("Looking for the user in LDAP with "); - logger.debug(" base DN: " + getLDAPPropertyValue(ConfigKey.USER_BASE)); - logger.debug(" filter: " + filter); + logger.debug(" base DN: {}", getLDAPPropertyValue(ConfigKey.USER_BASE)); + logger.debug(" filter: {}", filter); } NamingEnumeration results = null; @@ -377,7 +373,7 @@ public class LDAPLoginModule implements AuditLoginModule { } if (result.isRelative()) { - logger.debug("LDAP returned a relative name: " + result.getName()); + logger.debug("LDAP returned a relative name: {}", result.getName()); NameParser parser = context.getNameParser(""); Name contextName = parser.parse(context.getNameInNamespace()); @@ -387,7 +383,7 @@ public class LDAPLoginModule implements AuditLoginModule { name = name.addAll(entryName); dn = name.toString(); } else { - logger.debug("LDAP returned an absolute name: " + result.getName()); + logger.debug("LDAP returned an absolute name: {}", result.getName()); try { URI uri = new URI(result.getName()); @@ -406,9 +402,7 @@ public class LDAPLoginModule implements AuditLoginModule { } } - if (logger.isDebugEnabled()) { - logger.debug("Using DN [" + dn + "] for binding."); - } + logger.debug("Using DN [{}] for binding.", dn); Attributes attrs = result.getAttributes(); if (attrs == null) { @@ -470,8 +464,8 @@ public class LDAPLoginModule implements AuditLoginModule { if (logger.isDebugEnabled()) { logger.debug("Get user roles."); logger.debug("Looking for the user roles in LDAP with "); - logger.debug(" base DN: " + getLDAPPropertyValue(ConfigKey.ROLE_BASE)); - logger.debug(" filter: " + filter); + logger.debug(" base DN: {}", getLDAPPropertyValue(ConfigKey.ROLE_BASE)); + logger.debug(" filter: {}", filter); } HashSet haveSeenNames = new HashSet<>(); Queue pendingNameExpansion = new LinkedList<>(); @@ -510,8 +504,8 @@ public class LDAPLoginModule implements AuditLoginModule { if (logger.isDebugEnabled()) { logger.debug("Get 'expanded' user roles."); logger.debug("Looking for the 'expanded' user roles in LDAP with "); - logger.debug(" base DN: " + getLDAPPropertyValue(ConfigKey.ROLE_BASE)); - logger.debug(" filter: " + expandFilter); + logger.debug(" base DN: {}", getLDAPPropertyValue(ConfigKey.ROLE_BASE)); + logger.debug(" filter: {}", expandFilter); } try { results = Subject.doAs(brokerGssapiIdentity, (PrivilegedExceptionAction< NamingEnumeration>) () -> context.search(getLDAPPropertyValue(ConfigKey.ROLE_BASE), expandFilter, constraints)); @@ -574,28 +568,20 @@ public class LDAPLoginModule implements AuditLoginModule { protected boolean bindUser(DirContext context, String dn, String password) throws NamingException { boolean isValid = false; - if (logger.isDebugEnabled()) { - logger.debug("Binding the user."); - } + logger.debug("Binding the user."); context.addToEnvironment(Context.SECURITY_AUTHENTICATION, "simple"); context.addToEnvironment(Context.SECURITY_PRINCIPAL, dn); context.addToEnvironment(Context.SECURITY_CREDENTIALS, password); try { String baseDn = getLDAPPropertyValue(ConfigKey.CONNECTION_URL).replaceFirst(".*/", ","); String userDn = dn.replace(baseDn, ""); - if (logger.isDebugEnabled()) { - logger.debug("Get user Attributes with dn " + userDn); - } + logger.debug("Get user Attributes with dn {}", userDn); context.getAttributes(userDn, null); isValid = true; - if (logger.isDebugEnabled()) { - logger.debug("User " + dn + " successfully bound."); - } + logger.debug("User {} successfully bound.", dn); } catch (AuthenticationException e) { isValid = false; - if (logger.isDebugEnabled()) { - logger.debug("Authentication failed for dn=" + dn); - } + logger.debug("Authentication failed for dn={}", dn); } if (isLoginPropertySet(ConfigKey.CONNECTION_USERNAME)) { @@ -651,9 +637,7 @@ public class LDAPLoginModule implements AuditLoginModule { } env.put(Context.REFERRAL, referral); - if (logger.isDebugEnabled()) { - logger.debug("Referral handling: " + referral); - } + logger.debug("Referral handling: {}", referral); if ("GSSAPI".equalsIgnoreCase(getLDAPPropertyValue(ConfigKey.AUTHENTICATION))) { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PrincipalConversionLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PrincipalConversionLoginModule.java index 87fbe84b7e..73d1d72613 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PrincipalConversionLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PrincipalConversionLoginModule.java @@ -66,9 +66,9 @@ public class PrincipalConversionLoginModule implements AuditLoginModule { for (String principalClass : principalClasses) { String trimmedCandidateClassName = principalClass.trim(); for (Principal candidatePrincipal : subject.getPrincipals()) { - logger.debug("Checking principal class name:" + candidatePrincipal.getClass().getName() + ", " + candidatePrincipal); + logger.debug("Checking principal class name:{}, {}", candidatePrincipal.getClass().getName(), candidatePrincipal); if (candidatePrincipal.getClass().getName().equals(trimmedCandidateClassName)) { - logger.debug("converting: " + candidatePrincipal); + logger.debug("converting: {}", candidatePrincipal); principal = new UserPrincipal(candidatePrincipal.getName()); subject.getPrincipals().add(principal); break; @@ -76,7 +76,10 @@ public class PrincipalConversionLoginModule implements AuditLoginModule { } } } - logger.debug("commit, result: " + (principal != null)); + + if (logger.isDebugEnabled()) { + logger.debug("commit, result: {}", (principal != null)); + } return principal != null; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoader.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoader.java index 19c326f5df..80adf23ca4 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoader.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoader.java @@ -114,7 +114,7 @@ public class PropertiesLoader { } } if (debug) { - logger.debug("Using basedir=" + (baseDir == null ? null : baseDir.getAbsolutePath())); + logger.debug("Using basedir={}", (baseDir == null ? null : baseDir.getAbsolutePath())); } return baseDir; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoginModule.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoginModule.java index 808526d651..e5e1c6a6f9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoginModule.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/PropertiesLoginModule.java @@ -121,7 +121,7 @@ public class PropertiesLoginModule extends PropertiesLoader implements AuditLogi loginSucceeded = true; if (debug) { - logger.debug("login " + user); + logger.debug("login {}", user); } return loginSucceeded; } @@ -152,7 +152,7 @@ public class PropertiesLoginModule extends PropertiesLoader implements AuditLogi clear(); if (debug) { - logger.debug("commit, result: " + result); + logger.debug("commit, result: {}", result); } return result; } diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ReloadableProperties.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ReloadableProperties.java index 0a093719e3..396340402c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ReloadableProperties.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/security/jaas/ReloadableProperties.java @@ -65,12 +65,12 @@ public class ReloadableProperties { invertedValueProps = null; regexpProps = null; if (key.isDebug()) { - logger.debug("Load of: " + key); + logger.debug("Load of: {}", key); } } catch (IOException e) { ActiveMQServerLogger.LOGGER.failedToLoadProperty(key.toString(), e.getLocalizedMessage(), e); if (key.isDebug()) { - logger.debug("Load of: " + key + ", failure exception" + e); + logger.debug("Load of: {}, failure exception {}", key, e); } } reloadTime = System.currentTimeMillis(); @@ -119,7 +119,7 @@ public class ReloadableProperties { Pattern p = Pattern.compile(str.substring(1, str.length() - 1)); regexpProps.put((String) val.getKey(), p); } catch (PatternSyntaxException e) { - logger.warn("Ignoring invalid regexp: " + str, e); + logger.warn("Ignoring invalid regexp: {}", str, e); } } } diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java index 98ce1b2294..bf7a160e52 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java @@ -571,7 +571,7 @@ public class ConfigurationImplTest extends ActiveMQTestBase { tempFolder = new File(tempFolder.getAbsolutePath()); tempFolder.mkdirs(); - log.debug("TempFolder = " + tempFolder.getAbsolutePath()); + log.debug("TempFolder = {}", tempFolder.getAbsolutePath()); ConfigurationImpl configuration = new ConfigurationImpl(); configuration.setJournalDirectory(tempFolder.getAbsolutePath()); @@ -589,7 +589,7 @@ public class ConfigurationImplTest extends ActiveMQTestBase { tempFolder = new File(tempFolder.getAbsolutePath()); tempFolder.mkdirs(); - log.debug("TempFolder = " + tempFolder.getAbsolutePath()); + log.debug("TempFolder = {}", tempFolder.getAbsolutePath()); configuration.setNodeManagerLockDirectory(tempFolder.getAbsolutePath()); File lockLocation = configuration.getNodeManagerLockLocation(); Assert.assertTrue(lockLocation.exists()); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/JAASSecurityManagerTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/JAASSecurityManagerTest.java index 5715d60b7e..5cbacd2649 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/JAASSecurityManagerTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/JAASSecurityManagerTest.java @@ -78,7 +78,7 @@ public class JAASSecurityManagerTest { @Test public void testLoginClassloading() throws Exception { ClassLoader existingLoader = Thread.currentThread().getContextClassLoader(); - log.debug("loader: " + existingLoader); + log.debug("loader: {}", existingLoader); try { if (usingNewLoader) { URLClassLoader simulatedLoader = new URLClassLoader(new URL[]{tmpDir.getRoot().toURI().toURL()}, null); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/TextFileCertificateLoginModuleTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/TextFileCertificateLoginModuleTest.java index 7540018e5e..289f05a92f 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/TextFileCertificateLoginModuleTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/security/jaas/TextFileCertificateLoginModuleTest.java @@ -122,11 +122,10 @@ public class TextFileCertificateLoginModuleTest { long timeTaken = endTime - startTime; for (int i = 0; i < NUMBER_SUBJECTS; i++) { - logger.info("subject is: " + subjects[i].getPrincipals().toString()); + logger.info("subject is: {}", subjects[i].getPrincipals().toString()); } - logger.info(usersFiles + ": Time taken is " + timeTaken); - + logger.info("{}: Time taken is {}", usersFiles, timeTaken); } private JaasCallbackHandler getJaasCertificateCallbackHandler(String user) { diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitorTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitorTest.java index 7211582852..66628cc473 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitorTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileStoreMonitorTest.java @@ -81,19 +81,19 @@ public class FileStoreMonitorTest extends ActiveMQTestBase { @Override public void tick(long usableSpace, long totalSpace) { tick.incrementAndGet(); - log.debug("tick:: usableSpace: " + usableSpace + ", totalSpace:" + totalSpace); + log.debug("tick:: usableSpace: {}, totalSpace:{}", usableSpace, totalSpace); } @Override public void over(long usableSpace, long totalSpace) { over.incrementAndGet(); - log.debug("over:: usableSpace: " + usableSpace + ", totalSpace:" + totalSpace); + log.debug("over:: usableSpace: {}, totalSpace:{}", usableSpace, totalSpace); } @Override public void under(long usableSpace, long totalSpace) { under.incrementAndGet(); - log.debug("under:: usableSpace: " + usableSpace + ", totalSpace:" + totalSpace); + log.debug("under:: usableSpace: {}, totalSpace: {}", usableSpace, totalSpace); } }; FileStoreMonitor storeMonitor = new FileStoreMonitor(scheduledExecutorService, executorService, 100, TimeUnit.MILLISECONDS, 0.999, null); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java index 91ac9b32cc..b967f03997 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/impl/ScheduledDeliveryHandlerTest.java @@ -285,7 +285,7 @@ public class ScheduledDeliveryHandlerTest extends Assert { assertTrue(ref.getScheduledDeliveryTime() >= lastTime); } else { if (ref.getScheduledDeliveryTime() < lastTime) { - log.debug("^^^fail at " + ref.getScheduledDeliveryTime()); + log.debug("^^^fail at {}", ref.getScheduledDeliveryTime()); } } lastTime = ref.getScheduledDeliveryTime(); diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModuleTest.java b/artemis-server/src/test/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModuleTest.java index 32dd30e0a5..6303debf04 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModuleTest.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/spi/core/security/jaas/LDAPLoginModuleTest.java @@ -117,7 +117,7 @@ public class LDAPLoginModuleTest extends AbstractLdapTestUnit { @Test public void testLogin() throws Exception { - logger.info("num session: " + ldapServer.getLdapSessionManager().getSessions().length); + logger.info("num session: {}", ldapServer.getLdapSessionManager().getSessions().length); LoginContext context = new LoginContext("LDAPLogin", new CallbackHandler() { @Override diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/NoFilesBehind.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/NoFilesBehind.java index d4f610ccee..ed24704a31 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/NoFilesBehind.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/NoFilesBehind.java @@ -20,9 +20,6 @@ package org.apache.activemq.artemis.tests.util; import java.io.File; import org.apache.activemq.artemis.utils.FileUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; import org.junit.Assert; import org.junit.rules.TestWatcher; import org.junit.runner.Description; @@ -32,8 +29,6 @@ import org.junit.runner.Description; */ public class NoFilesBehind extends TestWatcher { - private static Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final String[] filesToCheck; public NoFilesBehind(String... filesToCheck) { diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/NoProcessFilesBehind.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/NoProcessFilesBehind.java index ed6996e10e..c7c66b9c95 100644 --- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/NoProcessFilesBehind.java +++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/NoProcessFilesBehind.java @@ -29,9 +29,6 @@ import java.util.List; import com.sun.management.UnixOperatingSystemMXBean; import org.apache.activemq.artemis.nativo.jlibaio.LibaioContext; import org.apache.activemq.artemis.utils.Wait; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; import org.junit.Assert; import org.junit.rules.TestWatcher; import org.junit.runner.Description; @@ -41,8 +38,6 @@ import org.junit.runner.Description; */ public class NoProcessFilesBehind extends TestWatcher { - private static Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - public NoProcessFilesBehind(long maxFiles) { this(-1, maxFiles); } diff --git a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java index ee7433d6d6..f3f65d6db0 100644 --- a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java +++ b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java @@ -57,15 +57,11 @@ public class ActiveMQXAResourceRecovery { private ActiveMQXAResourceWrapper res; public ActiveMQXAResourceRecovery() { - if (logger.isTraceEnabled()) { - logger.trace("Constructing ActiveMQXAResourceRecovery"); - } + logger.trace("Constructing ActiveMQXAResourceRecovery"); } public boolean initialise(final String config) { - if (logger.isTraceEnabled()) { - logger.trace(this + " initialise: " + config); - } + logger.trace("{} initialise: {}", this, config); String[] configs = config.split(";"); XARecoveryConfig[] xaRecoveryConfigs = new XARecoveryConfig[configs.length]; @@ -82,17 +78,13 @@ public class ActiveMQXAResourceRecovery { res = new ActiveMQXAResourceWrapper(xaRecoveryConfigs); - if (logger.isTraceEnabled()) { - logger.trace(this + " initialised"); - } + logger.trace("{} initialised", this); return true; } public boolean hasMoreResources() { - if (logger.isTraceEnabled()) { - logger.trace(this + " hasMoreResources"); - } + logger.trace("{} hasMoreResources", this); /* * The way hasMoreResources is supposed to work is as follows: @@ -114,9 +106,7 @@ public class ActiveMQXAResourceRecovery { } public XAResource getXAResource() { - if (logger.isTraceEnabled()) { - logger.trace(this + " getXAResource"); - } + logger.trace("{} getXAResource", this); return res; } diff --git a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceWrapper.java b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceWrapper.java index 237735d610..d672b7c5ab 100644 --- a/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceWrapper.java +++ b/artemis-service-extensions/src/main/java/org/apache/activemq/artemis/service/extensions/xa/recovery/ActiveMQXAResourceWrapper.java @@ -63,9 +63,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList this.xaRecoveryConfigs = xaRecoveryConfigs; if (logger.isDebugEnabled()) { - logger.debug("Recovery configured with " + Arrays.toString(xaRecoveryConfigs) + - ", instance=" + - System.identityHashCode(this)); + logger.debug("Recovery configured with {}, instance={}", Arrays.toString(xaRecoveryConfigs), System.identityHashCode(this)); } } @@ -74,14 +72,14 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList XAResource xaResource = getDelegate(false); if (logger.isDebugEnabled()) { - logger.debug("looking for recover at " + xaResource + " configuration " + Arrays.toString(this.xaRecoveryConfigs)); + logger.debug("looking for recover at {} configuration {}", xaResource, Arrays.toString(this.xaRecoveryConfigs)); } try { Xid[] xids = xaResource.recover(flag); if (logger.isDebugEnabled() && xids != null && xids.length > 0) { - logger.debug("Recovering these following IDs " + Arrays.toString(xids) + " at " + this); + logger.debug("Recovering these following IDs {} at {}", Arrays.toString(xids), this); } return xids; @@ -94,9 +92,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList @Override public void commit(final Xid xid, final boolean onePhase) throws XAException { XAResource xaResource = getDelegate(true); - if (logger.isDebugEnabled()) { - logger.debug("Commit " + xaResource + " xid " + " onePhase=" + onePhase); - } + logger.debug("Commit {} xid onePhase={}", xaResource, onePhase); try { xaResource.commit(xid, onePhase); } catch (XAException e) { @@ -107,9 +103,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList @Override public void rollback(final Xid xid) throws XAException { XAResource xaResource = getDelegate(true); - if (logger.isDebugEnabled()) { - logger.debug("Rollback " + xaResource + " xid "); - } + logger.debug("Rollback {} xid", xaResource); try { xaResource.rollback(xid); } catch (XAException e) { @@ -120,10 +114,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList @Override public void forget(final Xid xid) throws XAException { XAResource xaResource = getDelegate(false); - if (logger.isDebugEnabled()) { - logger.debug("Forget " + xaResource + " xid "); - } - + logger.debug("Forget {} xid ", xaResource); try { xaResource.forget(xid); } catch (XAException e) { @@ -148,9 +139,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList @Override public int prepare(final Xid xid) throws XAException { XAResource xaResource = getDelegate(true); - if (logger.isDebugEnabled()) { - logger.debug("prepare " + xaResource + " xid "); - } + logger.debug("prepare {} xid ", xaResource); try { return xaResource.prepare(xid); } catch (XAException e) { @@ -161,9 +150,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList @Override public void start(final Xid xid, final int flags) throws XAException { XAResource xaResource = getDelegate(false); - if (logger.isDebugEnabled()) { - logger.debug("start " + xaResource + " xid "); - } + logger.debug("start {} xid ", xaResource); try { xaResource.start(xid, flags); } catch (XAException e) { @@ -174,9 +161,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList @Override public void end(final Xid xid, final int flags) throws XAException { XAResource xaResource = getDelegate(false); - if (logger.isDebugEnabled()) { - logger.debug("end " + xaResource + " xid "); - } + logger.debug("end {} xid ", xaResource); try { xaResource.end(xid, flags); } catch (XAException e) { @@ -187,9 +172,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList @Override public int getTransactionTimeout() throws XAException { XAResource xaResource = getDelegate(false); - if (logger.isDebugEnabled()) { - logger.debug("getTransactionTimeout " + xaResource + " xid "); - } + logger.debug("getTransactionTimeout {} xid ", xaResource); try { return xaResource.getTransactionTimeout(); } catch (XAException e) { @@ -200,9 +183,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList @Override public boolean setTransactionTimeout(final int seconds) throws XAException { XAResource xaResource = getDelegate(false); - if (logger.isDebugEnabled()) { - logger.debug("setTransactionTimeout " + xaResource + " xid "); - } + logger.debug("setTransactionTimeout {} xid ", xaResource); try { return xaResource.setTransactionTimeout(seconds); } catch (XAException e) { @@ -213,9 +194,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList @Override public void connectionFailed(final ActiveMQException me, boolean failedOver) { if (me.getType() == ActiveMQExceptionType.DISCONNECTED) { - if (logger.isDebugEnabled()) { - logger.debug("being disconnected for server shutdown", me); - } + logger.debug("being disconnected for server shutdown", me); } else { ActiveMQXARecoveryLogger.LOGGER.xaRecoverConnectionError(csf, me); } @@ -255,9 +234,8 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList if (error != null) { xae.initCause(error); } - if (logger.isDebugEnabled()) { - logger.debug("Cannot get connectionFactory XAResource", xae); - } + logger.debug("Cannot get connectionFactory XAResource", xae); + throw xae; } else { XAException xae = new XAException("Error trying to connect to any providers for xa recovery"); @@ -265,9 +243,8 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList if (error != null) { xae.initCause(error); } - if (logger.isDebugEnabled()) { - logger.debug("Cannot get connectionFactory XAResource", xae); - } + logger.debug("Cannot get connectionFactory XAResource", xae); + throw xae; } @@ -291,16 +268,15 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } for (XARecoveryConfig xaRecoveryConfig : xaRecoveryConfigs) { - if (xaRecoveryConfig == null) { continue; } + if (logger.isDebugEnabled()) { - logger.debug("Trying to connect recovery on " + xaRecoveryConfig + " of " + Arrays.toString(xaRecoveryConfigs)); + logger.debug("Trying to connect recovery on {} of {}", xaRecoveryConfig, Arrays.toString(xaRecoveryConfigs)); } ClientSession cs = null; - try { // setting ha=false because otherwise the connector would go towards any server, causing Heuristic exceptions // we really need to control what server it's connected to @@ -323,9 +299,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } } catch (Throwable e) { ActiveMQXARecoveryLogger.LOGGER.xaRecoverAutoConnectionError(xaRecoveryConfig, e); - if (logger.isDebugEnabled()) { - logger.debug(e.getMessage(), e); - } + logger.debug(e.getMessage(), e); try { if (cs != null) @@ -333,9 +307,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList if (serverLocator != null) serverLocator.close(); } catch (Throwable ignored) { - if (logger.isTraceEnabled()) { - logger.trace(e.getMessage(), ignored); - } + logger.trace(e.getMessage(), ignored); } continue; } diff --git a/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/RetryRule.java b/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/RetryRule.java index 233241c422..ea7f023cf0 100644 --- a/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/RetryRule.java +++ b/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/RetryRule.java @@ -85,7 +85,7 @@ public class RetryRule implements MethodRule { public void evaluate() throws Throwable { int retries = getNumberOfRetries(method) + 1; for (int i = 0; i < retries; i++) { - logger.warn("LOOP " + i); + logger.warn("LOOP {}", i); base.evaluate(); } } @@ -111,14 +111,14 @@ public class RetryRule implements MethodRule { int retries = getNumberOfRetries(method); for (int retryNr = 0; retryNr < retries; retryNr++) { - logger.warn("RETRY " + (retryNr + 1) + " of " + retries + " on " + target.getClass() + "::" + method.getName(), currentException); + logger.warn("RETRY {} of {} on {}::{}", (retryNr + 1), retries, target.getClass(), method.getName(), currentException); currentException = null; try { base.evaluate(); - logger.warn("RETRY " + (retryNr + 1) + " of " + retries + " on " + target.getClass() + "::" + method.getName() + " succeeded"); + logger.warn("RETRY {} of {} on {}::{} succeeded", (retryNr + 1), retries, target.getClass(), method.getName()); break; } catch (Throwable t2) { - logger.warn("RETRY " + (retryNr + 1) + " of " + retries + " on " + target.getClass() + "::" + method.getName() + " failed ", t2); + logger.warn("RETRY {} of {} on {}::{} failed", (retryNr + 1), retries, target.getClass(), method.getName(), t2); currentException = t2; } } diff --git a/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java b/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java index afc908ec2a..f267c017da 100644 --- a/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java +++ b/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java @@ -84,7 +84,9 @@ public class ThreadLeakCheckRule extends TestWatcher { */ @Override protected void finished(Description description) { - log.debug("checking thread enabled? " + enabled + " testFailed? " + testFailed); + if (log.isDebugEnabled()) { + log.debug("checking thread enabled? {}, testFailed? {}", enabled, testFailed); + } try { if (enabled) { boolean failed = true; diff --git a/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/Wait.java b/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/Wait.java index 099f13971e..099c45a0ac 100644 --- a/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/Wait.java +++ b/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/Wait.java @@ -45,7 +45,7 @@ public class Wait { if (logger.isDebugEnabled()) { logger.debug("Wait util was unable to locate ThreadDumpUtil class/method", e); } else { - logger.info("Wait util was unable to locate ThreadDumpUtil class/method due to: " + e.getClass().getName() + ": " + e.getMessage()); + logger.info("Wait util was unable to locate ThreadDumpUtil class/method due to: {}: {}", e.getClass().getName(), e.getMessage()); } } } diff --git a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java index 2149368c3a..03d4524b98 100644 --- a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java +++ b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java @@ -29,19 +29,21 @@ import javax.jms.MessageProducer; import javax.jms.Session; import java.io.FileInputStream; import java.io.InputStream; +import java.lang.invoke.MethodHandles; import java.util.Properties; import java.util.Random; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicLong; -import java.util.logging.Logger; import org.apache.activemq.artemis.utils.TokenBucketLimiter; import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl; import org.apache.qpid.jms.JmsConnectionFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class PerfBase { - private static final Logger log = Logger.getLogger(PerfSender.class.getName()); + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static final String DEFAULT_PERF_PROPERTIES_FILE_NAME = "target/classes/perf.properties"; @@ -93,20 +95,20 @@ public abstract class PerfBase { String clientLibrary = props.getProperty("client-library", "core"); String uri = props.getProperty("server-uri", "tcp://localhost:61616"); - PerfBase.log.info("num-messages: " + noOfMessages); - PerfBase.log.info("num-warmup-messages: " + noOfWarmupMessages); - PerfBase.log.info("message-size: " + messageSize); - PerfBase.log.info("durable: " + durable); - PerfBase.log.info("transacted: " + transacted); - PerfBase.log.info("batch-size: " + batchSize); - PerfBase.log.info("drain-queue: " + drainQueue); - PerfBase.log.info("throttle-rate: " + throttleRate); - PerfBase.log.info("destination-name: " + destinationName); - PerfBase.log.info("disable-message-id: " + disableMessageID); - PerfBase.log.info("disable-message-timestamp: " + disableTimestamp); - PerfBase.log.info("dups-ok-acknowledge: " + dupsOK); - PerfBase.log.info("server-uri: " + uri); - PerfBase.log.info("client-library:" + clientLibrary); + PerfBase.log.info("num-messages: {}", noOfMessages); + PerfBase.log.info("num-warmup-messages: {}", noOfWarmupMessages); + PerfBase.log.info("message-size: {}", messageSize); + PerfBase.log.info("durable: {}", durable); + PerfBase.log.info("transacted: {}", transacted); + PerfBase.log.info("batch-size: {}", batchSize); + PerfBase.log.info("drain-queue: {}", drainQueue); + PerfBase.log.info("throttle-rate: {}", throttleRate); + PerfBase.log.info("destination-name: {}", destinationName); + PerfBase.log.info("disable-message-id: {}", disableMessageID); + PerfBase.log.info("disable-message-timestamp: {}", disableTimestamp); + PerfBase.log.info("dups-ok-acknowledge: {}", dupsOK); + PerfBase.log.info("server-uri: {}", uri); + PerfBase.log.info("client-library:{}", clientLibrary); PerfParams perfParams = new PerfParams(); perfParams.setNoOfMessagesToSend(noOfMessages); @@ -189,7 +191,7 @@ public abstract class PerfBase { } start = System.currentTimeMillis(); - PerfBase.log.info("warming up by sending " + perfParams.getNoOfWarmupMessages() + " messages"); + PerfBase.log.info("warming up by sending {} messages", perfParams.getNoOfWarmupMessages()); sendMessages(perfParams.getNoOfWarmupMessages(), perfParams.getBatchSize(), perfParams.isDurable(), perfParams.isSessionTransacted(), false, perfParams.getThrottleRate(), perfParams.getMessageSize()); PerfBase.log.info("warmed up"); start = System.currentTimeMillis(); @@ -281,7 +283,7 @@ public abstract class PerfBase { drainSession.close(); - PerfBase.log.info("Drained " + count + " messages"); + PerfBase.log.info("Drained {} messages", count); } private void sendMessages(final int numberOfMessages, @@ -363,7 +365,7 @@ public abstract class PerfBase { if (warmingUp) { boolean committed = checkCommit(); if (count.incrementAndGet() == perfParams.getNoOfWarmupMessages()) { - PerfBase.log.info("warmed up after receiving " + count.longValue() + " msgs"); + PerfBase.log.info("warmed up after receiving {} msgs", count.longValue()); if (!committed) { checkCommit(); } diff --git a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java index 6d447c9289..ed7f78325c 100644 --- a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java +++ b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java @@ -16,12 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; -import java.util.logging.Logger; - public class PerfListener extends PerfBase { - private static final Logger log = Logger.getLogger(PerfListener.class.getName()); - public static void main(final String[] args) { try { String fileName = PerfBase.getPerfFileName(args); diff --git a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java index b8cca50fe6..61f6246212 100644 --- a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java +++ b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java @@ -16,12 +16,8 @@ */ package org.apache.activemq.artemis.jms.example; -import java.util.logging.Logger; - public class PerfSender extends PerfBase { - private static final Logger log = Logger.getLogger(PerfSender.class.getName()); - public static void main(final String[] args) { try { String fileName = PerfBase.getPerfFileName(args); diff --git a/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java b/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java index bd17b38853..474ef861ba 100644 --- a/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java +++ b/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java @@ -18,13 +18,15 @@ package org.apache.activemq.artemis.jms.soak.example; import java.io.FileInputStream; import java.io.InputStream; +import java.lang.invoke.MethodHandles; import java.util.Properties; import java.util.Random; -import java.util.logging.Logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SoakBase { - - private static final Logger log = Logger.getLogger(SoakBase.class.getName()); + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static final String DEFAULT_SOAK_PROPERTIES_FILE_NAME = "soak.properties"; @@ -73,19 +75,19 @@ public class SoakBase { boolean disableMessageID = Boolean.valueOf(props.getProperty("disable-message-id")); boolean disableTimestamp = Boolean.valueOf(props.getProperty("disable-message-timestamp")); - SoakBase.log.info("duration-in-minutes: " + durationInMinutes); - SoakBase.log.info("num-warmup-messages: " + noOfWarmupMessages); - SoakBase.log.info("message-size: " + messageSize); - SoakBase.log.info("durable: " + durable); - SoakBase.log.info("transacted: " + transacted); - SoakBase.log.info("batch-size: " + batchSize); - SoakBase.log.info("drain-queue: " + drainQueue); - SoakBase.log.info("throttle-rate: " + throttleRate); - SoakBase.log.info("connection-factory-lookup: " + connectionFactoryLookup); - SoakBase.log.info("destination-lookup: " + destinationLookup); - SoakBase.log.info("disable-message-id: " + disableMessageID); - SoakBase.log.info("disable-message-timestamp: " + disableTimestamp); - SoakBase.log.info("dups-ok-acknowledge: " + dupsOK); + SoakBase.log.info("duration-in-minutes: {}", durationInMinutes); + SoakBase.log.info("num-warmup-messages: {}", noOfWarmupMessages); + SoakBase.log.info("message-size: {}", messageSize); + SoakBase.log.info("durable: {}", durable); + SoakBase.log.info("transacted: {}", transacted); + SoakBase.log.info("batch-size: {}", batchSize); + SoakBase.log.info("drain-queue: {}", drainQueue); + SoakBase.log.info("throttle-rate: {}", throttleRate); + SoakBase.log.info("connection-factory-lookup: {}", connectionFactoryLookup); + SoakBase.log.info("destination-lookup: {}", destinationLookup); + SoakBase.log.info("disable-message-id: {}", disableMessageID); + SoakBase.log.info("disable-message-timestamp: {}", disableTimestamp); + SoakBase.log.info("dups-ok-acknowledge: {}", dupsOK); SoakParams soakParams = new SoakParams(); soakParams.setDurationInMinutes(durationInMinutes); diff --git a/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java b/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java index 8002f1f988..44d6cf6a5c 100644 --- a/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java +++ b/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java @@ -27,13 +27,17 @@ import javax.jms.MessageListener; import javax.jms.Session; import javax.naming.InitialContext; import javax.naming.NamingException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.invoke.MethodHandles; import java.util.UUID; import java.util.concurrent.atomic.AtomicLong; -import java.util.logging.Logger; public class SoakReceiver { - private static final Logger log = Logger.getLogger(SoakReceiver.class.getName()); + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static final String EOF = UUID.randomUUID().toString(); diff --git a/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java b/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java index 839acba14f..80ecfc2757 100644 --- a/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java +++ b/examples/features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java @@ -27,15 +27,18 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.naming.InitialContext; import javax.naming.NamingException; + +import java.lang.invoke.MethodHandles; import java.util.concurrent.atomic.AtomicLong; -import java.util.logging.Logger; import org.apache.activemq.artemis.utils.TokenBucketLimiter; import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class SoakSender { - private static final Logger log = Logger.getLogger(SoakSender.class.getName()); + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); public static void main(final String[] args) { try { diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.java index 07d4c6d33f..22bb043422 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/ActiveMQMessageAuditTest.java @@ -133,7 +133,7 @@ public class ActiveMQMessageAuditTest extends TestCase { ActiveMQMessageAuditNoSync audit = new ActiveMQMessageAuditNoSync(); byte[] bytes = serialize(audit); - LOG.debug("Length: " + bytes.length); + LOG.debug("Length: {}", bytes.length); audit = recover(bytes); List list = new ArrayList<>(); @@ -143,7 +143,7 @@ public class ActiveMQMessageAuditTest extends TestCase { pid.setConnectionId("test"); pid.setSessionId(0); pid.setValue(j); - LOG.debug("producer " + j); + LOG.debug("producer {}", j); for (int i = 0; i < 1000; i++) { MessageId id = new MessageId(); @@ -156,7 +156,7 @@ public class ActiveMQMessageAuditTest extends TestCase { if (i % 100 == 0) { bytes = serialize(audit); - LOG.debug("Length: " + bytes.length); + LOG.debug("Length: {}", bytes.length); audit = recover(bytes); } @@ -166,7 +166,7 @@ public class ActiveMQMessageAuditTest extends TestCase { } list.clear(); bytes = serialize(audit); - LOG.debug("Length: " + bytes.length); + LOG.debug("Length: {}", bytes.length); audit = recover(bytes); } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/IdGenerator.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/IdGenerator.java index 6d0aecf894..054226a8bd 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/IdGenerator.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/amqp/client/util/IdGenerator.java @@ -81,7 +81,7 @@ public class IdGenerator { if (LOG.isTraceEnabled()) { LOG.trace("Closing the server socket failed", ioe); } else { - LOG.warn("Closing the server socket failed" + " due " + ioe.getMessage()); + LOG.warn("Closing the server socket failed due to {}", ioe.getMessage()); } } } diff --git a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyWSTransport.java b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyWSTransport.java index 6878eb24e1..e831f2ff9f 100644 --- a/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyWSTransport.java +++ b/tests/artemis-test-support/src/main/java/org/apache/activemq/transport/netty/NettyWSTransport.java @@ -148,7 +148,7 @@ public class NettyWSTransport extends NettyTcpTransport { WebSocketFrame frame = (WebSocketFrame) message; if (frame instanceof TextWebSocketFrame) { TextWebSocketFrame textFrame = (TextWebSocketFrame) frame; - LOG.warn("WebSocket Client received message: " + textFrame.text()); + LOG.warn("WebSocket Client received message: {}", textFrame.text()); ctx.fireExceptionCaught(new IOException("Received invalid frame over WebSocket.")); } else if (frame instanceof BinaryWebSocketFrame) { BinaryWebSocketFrame binaryFrame = (BinaryWebSocketFrame) frame; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AnycastTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AnycastTest.java index d085e12ca3..24b46888ff 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AnycastTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/AnycastTest.java @@ -101,7 +101,7 @@ public class AnycastTest extends ActiveMQTestBase { for (int j = 0; j < num / 2; j++) { ClientMessage m = consumers[i].receive(2000); assertNotNull(m); - logger.debug("consumer" + i + " received: " + m.getBodyBuffer().readString()); + logger.debug("consumer{} received: {}", i, m.getBodyBuffer().readString()); } assertNull(consumers[i].receive(200)); @@ -160,7 +160,7 @@ public class AnycastTest extends ActiveMQTestBase { for (int j = 0; j < num / 2; j++) { ClientMessage m = consumers[i].receive(2000); assertNotNull(m); - logger.debug("consumer" + i + " received: " + m.getBodyBuffer().readString()); + logger.debug("consumer{} received: {}", i, m.getBodyBuffer().readString()); } assertNull(consumers[i].receive(200)); @@ -176,7 +176,7 @@ public class AnycastTest extends ActiveMQTestBase { for (int j = 0; j < num / 2; j++) { ClientMessage m = consumers[i].receive(2000); assertNotNull(m); - logger.debug("consumer" + i + " received: " + m.getBodyBuffer().readString()); + logger.debug("consumer{} received: {}", i, m.getBodyBuffer().readString()); } assertNull(consumers[i].receive(200)); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/MulticastTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/MulticastTest.java index fdb94281a2..afe1900a61 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/MulticastTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/addressing/MulticastTest.java @@ -102,7 +102,7 @@ public class MulticastTest extends ActiveMQTestBase { for (int j = 0; j < num; j++) { ClientMessage m = consumers[i].receive(2000); assertNotNull(m); - logger.debug("consumer" + i + " received: " + m.getBodyBuffer().readString()); + logger.debug("consumer{} received: {}", i, m.getBodyBuffer().readString()); } assertNull(consumers[i].receive(200)); @@ -161,7 +161,7 @@ public class MulticastTest extends ActiveMQTestBase { for (int j = 0; j < num; j++) { ClientMessage m = consumers[i].receive(2000); assertNotNull(m); - logger.debug("consumer" + i + " received: " + m.getBodyBuffer().readString()); + logger.debug("consumer{} received: {}", i, m.getBodyBuffer().readString()); } assertNull(consumers[i].receive(200)); @@ -177,7 +177,7 @@ public class MulticastTest extends ActiveMQTestBase { for (int j = 0; j < num; j++) { ClientMessage m = consumers[i].receive(2000); assertNotNull(m); - logger.debug("consumer" + i + " received: " + m.getBodyBuffer().readString()); + logger.debug("consumer{} received: {}", i, m.getBodyBuffer().readString()); } assertNull(consumers[i].receive(200)); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpDLQReceiverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpDLQReceiverTest.java index 177dbe0779..46925f4a63 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpDLQReceiverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpDLQReceiverTest.java @@ -50,22 +50,22 @@ public class AmqpDLQReceiverTest extends AmqpClientTestSupport { assertNotNull(queue); receiver.flow(100); for (int i = 0; i < 10; i++) { - logger.debug("i = " + i); + logger.debug("i = {}", i); AmqpMessage receive = receiver.receive(5000, TimeUnit.MILLISECONDS); receive.modified(true, false); Queue queueView = getProxyToQueue(getQueueName()); - logger.debug("receive = " + receive.getWrappedMessage().getDeliveryCount()); - logger.debug("queueView.getMessageCount() = " + queueView.getMessageCount()); - logger.debug("queueView.getDeliveringCount() = " + queueView.getDeliveringCount()); - logger.debug("queueView.getPersistentSize() = " + queueView.getPersistentSize()); + logger.debug("receive = {}", receive.getWrappedMessage().getDeliveryCount()); + logger.debug("queueView.getMessageCount() = {}", queueView.getMessageCount()); + logger.debug("queueView.getDeliveringCount() = {}", queueView.getDeliveringCount()); + logger.debug("queueView.getPersistentSize() = {}", queueView.getPersistentSize()); } receiver.close(); connection.close(); Queue queueView = getProxyToQueue(getQueueName()); - logger.debug("queueView.getMessageCount() = " + queueView.getMessageCount()); - logger.debug("queueView.getDeliveringCount() = " + queueView.getDeliveringCount()); - logger.debug("queueView.getPersistentSize() = " + queueView.getPersistentSize()); + logger.debug("queueView.getMessageCount() = {}", queueView.getMessageCount()); + logger.debug("queueView.getDeliveringCount() = {}", queueView.getDeliveringCount()); + logger.debug("queueView.getPersistentSize() = {}", queueView.getPersistentSize()); Wait.assertEquals(0, queueView::getMessageCount); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFullyQualifiedNameTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFullyQualifiedNameTest.java index 06b7bf35f4..a24710994e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFullyQualifiedNameTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFullyQualifiedNameTest.java @@ -232,7 +232,7 @@ public class AmqpFullyQualifiedNameTest extends JMSClientTestSupport { Bindings bindings = server.getPostOffice().getBindingsForAddress(multicastAddress); for (Binding b : bindings.getBindings()) { - logger.debug("checking binidng " + b.getUniqueName() + " " + ((LocalQueueBinding)b).getQueue().getDeliveringMessages()); + logger.debug("checking binidng {} {}", b.getUniqueName(), ((LocalQueueBinding)b).getQueue().getDeliveringMessages()); SimpleString qName = b.getUniqueName(); //do FQQN query QueueQueryResult result = server.queueQuery(CompositeAddress.toFullyQualified(multicastAddress, qName)); @@ -319,7 +319,7 @@ public class AmqpFullyQualifiedNameTest extends JMSClientTestSupport { producer3.send(session.createMessage()); assertTrue(Wait.waitFor(() -> server.locateQueue(anycastQ3).getMessageCount() == 5, 2000, 200)); - logger.debug("Queue is: " + q1); + logger.debug("Queue is: {}", q1); MessageConsumer consumer1 = session.createConsumer(q1); MessageConsumer consumer2 = session.createConsumer(q2); MessageConsumer consumer3 = session.createConsumer(q3); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpLargeMessageTest.java index 6cc1e010f4..2014cb1018 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpLargeMessageTest.java @@ -312,7 +312,7 @@ public class AmqpLargeMessageTest extends AmqpClientTestSupport { if (wrapped.getBody() instanceof Data) { // converters can change this to AmqValue Data data = (Data) wrapped.getBody(); - LOG.debug("received : message: " + data.getValue().getLength()); + LOG.debug("received : message: {}", data.getValue().getLength()); assertEquals(payload, data.getValue().getLength()); } message.accept(); @@ -366,7 +366,7 @@ public class AmqpLargeMessageTest extends AmqpClientTestSupport { MessageImpl wrapped = (MessageImpl) message.getWrappedMessage(); if (wrapped.getBody() instanceof Data) { Data data = (Data) wrapped.getBody(); - LOG.debug("received : message: " + data.getValue().getLength()); + LOG.debug("received : message: {}", data.getValue().getLength()); assertEquals(payload, data.getValue().getLength()); } @@ -469,7 +469,7 @@ public class AmqpLargeMessageTest extends AmqpClientTestSupport { payload[i] = (byte) rand.nextInt(256); } - LOG.debug("Created buffer with size : " + sizeInBytes + " bytes"); + LOG.debug("Created buffer with size : {} bytes", sizeInBytes); return payload; } @@ -552,7 +552,7 @@ public class AmqpLargeMessageTest extends AmqpClientTestSupport { } public void doTestSendLargeMessage(int expectedSize) throws Exception { - LOG.debug("doTestSendLargeMessage called with expectedSize " + expectedSize); + LOG.debug("doTestSendLargeMessage called with expectedSize {}", expectedSize); byte[] payload = createLargePayload(expectedSize); assertEquals(expectedSize, payload.length); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpMaxFrameSizeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpMaxFrameSizeTest.java index 518e5b41d0..22ef2b233c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpMaxFrameSizeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpMaxFrameSizeTest.java @@ -182,7 +182,7 @@ public class AmqpMaxFrameSizeTest extends AmqpClientTestSupport { verifyMessage(receivedMessage, payloadSize); - LOG.trace("received : message " + i); + LOG.trace("received : message {}", i); receivedMessage.accept(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpPresettledReceiverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpPresettledReceiverTest.java index 811894a6f2..b3d7f9d94c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpPresettledReceiverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpPresettledReceiverTest.java @@ -71,7 +71,7 @@ public class AmqpPresettledReceiverTest extends AmqpClientTestSupport { receiver1.close(); receiver2.close(); - logger.debug("Message Count after all consumed: " + queueView.getMessageCount()); + logger.debug("Message Count after all consumed: {}", queueView.getMessageCount()); // Should be nothing left on the Queue AmqpReceiver receiver3 = session.createReceiver(getQueueName()); @@ -79,7 +79,7 @@ public class AmqpPresettledReceiverTest extends AmqpClientTestSupport { AmqpMessage received = receiver3.receive(5, TimeUnit.SECONDS); if (received != null) { - logger.debug("Message read: " + received.getMessageId()); + logger.debug("Message read: {}", received.getMessageId()); } assertNull(received); @@ -108,14 +108,14 @@ public class AmqpPresettledReceiverTest extends AmqpClientTestSupport { } receiver.close(); - logger.debug("Message Count after all consumed: " + queueView.getMessageCount()); + logger.debug("Message Count after all consumed: {}", queueView.getMessageCount()); // Open a new receiver and see if any message are left on the Queue receiver = session.createReceiver(getQueueName()); receiver.flow(1); AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS); if (received != null) { - logger.debug("Message read: " + received.getMessageId()); + logger.debug("Message read: {}", received.getMessageId()); } assertNull(received); @@ -160,14 +160,14 @@ public class AmqpPresettledReceiverTest extends AmqpClientTestSupport { receiver.close(); - logger.debug("Message Count after all consumed: " + queueView.getMessageCount()); + logger.debug("Message Count after all consumed: {}", queueView.getMessageCount()); // Open a new receiver and see if any message are left on the Queue receiver = session.createReceiver(getQueueName()); receiver.flow(1); AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS); if (received != null) { - logger.debug("Message read: " + received.getMessageId()); + logger.debug("Message read: {}", received.getMessageId()); } assertNull(received); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpReceiverDrainTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpReceiverDrainTest.java index 72f786fee6..4c2c8ad894 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpReceiverDrainTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpReceiverDrainTest.java @@ -74,7 +74,7 @@ public class AmqpReceiverDrainTest extends AmqpClientTestSupport { for (int i = 0; i < MSG_COUNT; ++i) { AmqpMessage message = receiver.receive(5, TimeUnit.SECONDS); assertNotNull("Failed to read message: " + (i + 1), message); - logger.info("Read message: " + message.getMessageId()); + logger.info("Read message: {}", message.getMessageId()); message.accept(); } receiver.close(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpReceiverWithFiltersTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpReceiverWithFiltersTest.java index 38c6593b67..dd8dfaa8b8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpReceiverWithFiltersTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpReceiverWithFiltersTest.java @@ -153,7 +153,7 @@ public class AmqpReceiverWithFiltersTest extends AmqpClientTestSupport { for (int i = 0; i < NUM_MESSAGES / 2; ++i) { AmqpMessage message = receiver.receive(5, TimeUnit.SECONDS); Assert.assertNotNull(message); - logger.debug("Read message: " + message.getApplicationProperty("myNewID")); + logger.debug("Read message: {}", message.getApplicationProperty("myNewID")); assertNotNull(message); messages.add(message); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java index 15db01e027..e4e2648657 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSendReceiveTest.java @@ -440,7 +440,7 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { message.setMessageAnnotation("serialNo", i); message.setText("Test-Message"); - logger.debug("Sending message: " + message.getMessageId()); + logger.debug("Sending message: {}", message.getMessageId()); sender.send(message); } @@ -462,7 +462,7 @@ public class AmqpSendReceiveTest extends AmqpClientTestSupport { for (int i = 0; i < MSG_COUNT; ++i) { received = receiver2.receive(5, TimeUnit.SECONDS); assertNotNull("Should have got a message", received); - logger.debug("Read message: " + received.getMessageId()); + logger.debug("Read message: {}", received.getMessageId()); assertEquals("msg" + i, received.getMessageId()); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSessionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSessionTest.java index 174fee19b0..9f85393923 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSessionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpSessionTest.java @@ -54,7 +54,7 @@ public class AmqpSessionTest extends AmqpClientTestSupport { @Override public void inspectClosedResource(Session session) { - log.debug("Session closed: " + session.getContext()); + log.debug("Session closed: {}", session.getContext()); } @Override diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpTransactionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpTransactionTest.java index d1dbccf459..49e12d520e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpTransactionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpTransactionTest.java @@ -716,7 +716,7 @@ public class AmqpTransactionTest extends AmqpClientTestSupport { receiver.flow((NUM_MESSAGES + 2) * 2); for (int i = 0; i < NUM_MESSAGES; ++i) { AmqpMessage message = receiver.receive(5, TimeUnit.SECONDS); - logger.debug("Read message: " + message.getApplicationProperty("msgId")); + logger.debug("Read message: {}", message.getApplicationProperty("msgId")); assertNotNull(message); messages.add(message); } @@ -724,7 +724,7 @@ public class AmqpTransactionTest extends AmqpClientTestSupport { // Commit half the consumed messages [0, 1, 2, 3, 4] txnSession.begin(); for (int i = 0; i < NUM_MESSAGES / 2; ++i) { - logger.debug("Commit: Accepting message: " + messages.get(i).getApplicationProperty("msgId")); + logger.debug("Commit: Accepting message: {}", messages.get(i).getApplicationProperty("msgId")); messages.get(i).accept(txnSession, false); } txnSession.commit(); @@ -732,7 +732,7 @@ public class AmqpTransactionTest extends AmqpClientTestSupport { // Rollback the other half the consumed messages [5, 6, 7, 8, 9] txnSession.begin(); for (int i = NUM_MESSAGES / 2; i < NUM_MESSAGES; ++i) { - logger.debug("Rollback: Accepting message: " + messages.get(i).getApplicationProperty("msgId")); + logger.debug("Rollback: Accepting message: {}", messages.get(i).getApplicationProperty("msgId")); messages.get(i).accept(txnSession, false); } txnSession.rollback(); @@ -740,7 +740,7 @@ public class AmqpTransactionTest extends AmqpClientTestSupport { // After rollback messages should still be acquired so we read last sent message [10] { AmqpMessage message = receiver.receive(5, TimeUnit.SECONDS); - logger.debug("Read message: " + message.getApplicationProperty("msgId")); + logger.debug("Read message: {}", message.getApplicationProperty("msgId")); assertNotNull(message); assertEquals(NUM_MESSAGES, message.getApplicationProperty("msgId")); message.release(); @@ -758,7 +758,7 @@ public class AmqpTransactionTest extends AmqpClientTestSupport { { receiver.flow(1); AmqpMessage message = receiver.receive(5, TimeUnit.SECONDS); - logger.debug("Read message: " + message.getApplicationProperty("msgId")); + logger.debug("Read message: {}", message.getApplicationProperty("msgId")); assertNotNull(message); assertEquals(NUM_MESSAGES, message.getApplicationProperty("msgId")); message.accept(); @@ -768,7 +768,7 @@ public class AmqpTransactionTest extends AmqpClientTestSupport { receiver.flow(1); AmqpMessage message = receiver.receive(1, TimeUnit.SECONDS); if (message != null) { - logger.debug("Read message: " + message.getApplicationProperty("msgId")); + logger.debug("Read message: {}", message.getApplicationProperty("msgId")); } assertNull(message); } finally { @@ -808,7 +808,7 @@ public class AmqpTransactionTest extends AmqpClientTestSupport { { // This will result in message [0[ being consumed once we commit. message1.accept(txnSession, false); - logger.debug("Commit: accepting message: " + message1.getApplicationProperty("msgId")); + logger.debug("Commit: accepting message: {}", message1.getApplicationProperty("msgId")); AmqpMessage message = new AmqpMessage(); message.setText("Test-Message"); @@ -822,7 +822,7 @@ public class AmqpTransactionTest extends AmqpClientTestSupport { txnSession.begin(); { message2.accept(txnSession, false); - logger.debug("Rollback: accepting message: " + message2.getApplicationProperty("msgId")); + logger.debug("Rollback: accepting message: {}", message2.getApplicationProperty("msgId")); AmqpMessage message = new AmqpMessage(); message.setText("Test-Message"); @@ -840,7 +840,7 @@ public class AmqpTransactionTest extends AmqpClientTestSupport { for (int i = 1; i <= NUM_MESSAGES; ++i) { AmqpMessage message = receiver.receive(5, TimeUnit.SECONDS); assertNotNull("Expected a message for: " + i, message); - logger.debug("Accepting message: " + message.getApplicationProperty("msgId")); + logger.debug("Accepting message: {}", message.getApplicationProperty("msgId")); assertEquals(i, message.getApplicationProperty("msgId")); message.accept(); } @@ -879,7 +879,7 @@ public class AmqpTransactionTest extends AmqpClientTestSupport { } if (i % 100 == 0) { - if (i % 1000 == 0) logger.debug("Read message " + i); + if (i % 1000 == 0) logger.debug("Read message {}", i); consumerSession.commit(); } } @@ -904,7 +904,7 @@ public class AmqpTransactionTest extends AmqpClientTestSupport { for (int i = 0; i < MESSAGE_COUNT; i++) { producer.send(sendingSession.createTextMessage("message " + i), DeliveryMode.PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE); if (i % 100 == 0) { - if (i % 1000 == 0) logger.debug("Sending " + i); + if (i % 1000 == 0) logger.debug("Sending {}", i); sendingSession.commit(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageConsumerTest.java index 7da225954f..91b3a93a02 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageConsumerTest.java @@ -731,7 +731,7 @@ public class JMSMessageConsumerTest extends JMSClientTestSupport { while (count > 0) { try { if (++n % 1000 == 0) { - LOG.debug("received " + n + " messages"); + LOG.debug("received {} messages", n); } Message m = consumer.receive(5000); @@ -783,11 +783,11 @@ public class JMSMessageConsumerTest extends JMSClientTestSupport { Wait.assertEquals(0, queueView::getMessageCount); long taken = (System.currentTimeMillis() - time); - LOG.debug("Microbenchamrk ran in " + taken + " milliseconds, sending/receiving " + numMessages); + LOG.debug("Microbenchamrk ran in {} milliseconds, sending/receiving {}", taken, numMessages); double messagesPerSecond = ((double) numMessages / (double) taken) * 1000; - LOG.debug(((int) messagesPerSecond) + " messages per second"); + LOG.debug("{} messages per second", ((int) messagesPerSecond)); } @Test(timeout = 60000) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageTypesTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageTypesTest.java index d86ea65bce..d1af4c1e82 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageTypesTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSMessageTypesTest.java @@ -134,7 +134,7 @@ public class JMSMessageTypesTest extends JMSClientTestSupport { MessageProducer producer = session.createProducer(queue); for (int i = 0; i < NUM_MESSAGES; i++) { - logger.debug("Sending " + i); + logger.debug("Sending {}", i); BytesMessage message = session.createBytesMessage(); message.writeBytes(bytes); @@ -156,13 +156,15 @@ public class JMSMessageTypesTest extends JMSClientTestSupport { byte[] bytesReceived = new byte[(int) size]; m.readBytes(bytesReceived); - logger.debug("Received " + ByteUtil.bytesToHex(bytesReceived, 1) + " count - " + m.getIntProperty("count")); + if (logger.isDebugEnabled()) { + logger.debug("Received {} count - {}", ByteUtil.bytesToHex(bytesReceived, 1), m.getIntProperty("count")); + } Assert.assertArrayEquals(bytes, bytesReceived); } long taken = (System.currentTimeMillis() - time) / 1000; - logger.debug("taken = " + taken); + logger.debug("taken = {}", taken); } @Test(timeout = 60000) @@ -193,7 +195,7 @@ public class JMSMessageTypesTest extends JMSClientTestSupport { MessageProducer producer = session.createProducer(queue); for (int i = 0; i < NUM_MESSAGES; i++) { - logger.debug("Sending " + i); + logger.debug("Sending {}", i); Message message = session.createMessage(); message.setIntProperty("count", i); @@ -210,7 +212,7 @@ public class JMSMessageTypesTest extends JMSClientTestSupport { } long taken = (System.currentTimeMillis() - time) / 1000; - logger.debug("taken = " + taken); + logger.debug("taken = {}", taken); } @Test(timeout = 60000) @@ -236,7 +238,7 @@ public class JMSMessageTypesTest extends JMSClientTestSupport { MessageProducer producer = session.createProducer(queue); for (int i = 0; i < NUM_MESSAGES; i++) { - logger.debug("Sending " + i); + logger.debug("Sending {}", i); MapMessage message = session.createMapMessage(); message.setInt("i", i); @@ -257,7 +259,7 @@ public class JMSMessageTypesTest extends JMSClientTestSupport { } long taken = (System.currentTimeMillis() - time) / 1000; - logger.debug("taken = " + taken); + logger.debug("taken = {}", taken); } @Test(timeout = 60000) @@ -283,7 +285,7 @@ public class JMSMessageTypesTest extends JMSClientTestSupport { MessageProducer producer = session.createProducer(queue); for (int i = 0; i < NUM_MESSAGES; i++) { - logger.debug("Sending " + i); + logger.debug("Sending {}", i); TextMessage message = session.createTextMessage("text" + i); message.setStringProperty("text", "text" + i); producer.send(message); @@ -300,7 +302,7 @@ public class JMSMessageTypesTest extends JMSClientTestSupport { } long taken = (System.currentTimeMillis() - time) / 1000; - logger.debug("taken = " + taken); + logger.debug("taken = {}", taken); } @Test(timeout = 60000) @@ -408,7 +410,7 @@ public class JMSMessageTypesTest extends JMSClientTestSupport { MessageProducer producer = session.createProducer(queue); for (int i = 0; i < NUM_MESSAGES; i++) { - logger.debug("Sending " + i); + logger.debug("Sending {}", i); ObjectMessage message = session.createObjectMessage(new AnythingSerializable(i)); producer.send(message); } @@ -426,7 +428,7 @@ public class JMSMessageTypesTest extends JMSClientTestSupport { } long taken = (System.currentTimeMillis() - time) / 1000; - logger.debug("taken = " + taken); + logger.debug("taken = {}", taken); } @Test(timeout = 60000) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSNonDestructiveTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSNonDestructiveTest.java index d2522a85c7..9a32f5d512 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSNonDestructiveTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSNonDestructiveTest.java @@ -654,16 +654,16 @@ public class JMSNonDestructiveTest extends JMSClientTestSupport { } } for (Map.Entry> entry : results.entrySet()) { - StringBuilder logMessage = new StringBuilder(); - logMessage.append("Messages received with lastval=" + entry.getKey() + " ("); + StringBuilder values = new StringBuilder(); for (String s : entry.getValue()) { int occurrences = Collections.frequency(entry.getValue(), s); if (occurrences > 1 && !dups.containsValue(Integer.parseInt(s))) { dups.put(s, occurrences); } - logMessage.append(s + ","); + values.append(s); + values.append(","); } - logger.info(logMessage + ")"); + logger.info("Messages received with lastval={} ({})", entry.getKey(), values); } if (dups.size() > 0) { StringBuffer sb = new StringBuffer(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSSaslGssapiTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSSaslGssapiTest.java index f81c4dd820..7c133a03e1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSSaslGssapiTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSSaslGssapiTest.java @@ -125,7 +125,7 @@ public class JMSSaslGssapiTest extends JMSClientTestSupport { Keytab kt = Keytab.loadKeytab(userKeyTab); for (PrincipalName name : kt.getPrincipals()) { for (KeytabEntry entry : kt.getKeytabEntries(name)) { - LOG.info("KeyTab Entry: PrincipalName:" + entry.getPrincipal() + " ; KeyInfo:" + entry.getKey().getKeyType()); + LOG.info("KeyTab Entry: PrincipalName:{} ; KeyInfo:{}", entry.getPrincipal(), entry.getKey().getKeyType()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTemporaryDestinationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTemporaryDestinationTest.java index 9a9f6c4e64..c2e86a7528 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTemporaryDestinationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTemporaryDestinationTest.java @@ -44,7 +44,7 @@ public class JMSTemporaryDestinationTest extends JMSClientTestSupport { try { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); TemporaryQueue queue = session.createTemporaryQueue(); - logger.debug("queue:" + queue.getQueueName()); + logger.debug("queue:{}", queue.getQueueName()); MessageProducer producer = session.createProducer(queue); TextMessage message = session.createTextMessage(); @@ -97,7 +97,7 @@ public class JMSTemporaryDestinationTest extends JMSClientTestSupport { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); TemporaryTopic topic = session.createTemporaryTopic(); - logger.debug("topic:" + topic.getTopicName()); + logger.debug("topic:{}", topic.getTopicName()); MessageConsumer consumer = session.createConsumer(topic); MessageProducer producer = session.createProducer(topic); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTransactionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTransactionTest.java index 40d249d371..d24806a1ce 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTransactionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTransactionTest.java @@ -45,7 +45,7 @@ public class JMSTransactionTest extends JMSClientTestSupport { Session session = connection.createSession(true, Session.SESSION_TRANSACTED); javax.jms.Queue queue = session.createQueue(getQueueName()); - logger.debug("queue:" + queue.getQueueName()); + logger.debug("queue:{}", queue.getQueueName()); MessageProducer p = session.createProducer(queue); for (int i = 0; i < 10; i++) { TextMessage message = session.createTextMessage(); @@ -67,7 +67,7 @@ public class JMSTransactionTest extends JMSClientTestSupport { Session session = connection.createSession(true, Session.SESSION_TRANSACTED); javax.jms.Queue queue = session.createQueue(getQueueName()); - logger.debug("queue:" + queue.getQueueName()); + logger.debug("queue:{}", queue.getQueueName()); MessageProducer p = session.createProducer(queue); for (int i = 0; i < 10; i++) { TextMessage message = session.createTextMessage(); @@ -111,7 +111,7 @@ public class JMSTransactionTest extends JMSClientTestSupport { Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); javax.jms.Queue queue = session.createQueue(getQueueName()); - logger.debug("queue:" + queue.getQueueName()); + logger.debug("queue:{}", queue.getQueueName()); MessageProducer p = session.createProducer(queue); for (int i = 0; i < 10; i++) { TextMessage message = session.createTextMessage(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/QueueAutoCreationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/QueueAutoCreationTest.java index 4c791d176d..8b4bbcf4d8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/QueueAutoCreationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/QueueAutoCreationTest.java @@ -95,7 +95,7 @@ public class QueueAutoCreationTest extends JMSClientTestSupport { Map.Entry entry = map.entrySet().iterator().next(); AddressSettings settings = entry.getValue(); settings.setAutoCreateQueues(true); - logger.debug("server cofg, isauto? " + entry.getValue().isAutoCreateQueues()); + logger.debug("server cofg, isauto? {}", entry.getValue().isAutoCreateQueues()); } @@ -123,7 +123,7 @@ public class QueueAutoCreationTest extends JMSClientTestSupport { ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:5672"); Connection connection = factory.createConnection(); SimpleString addressName = UUIDGenerator.getInstance().generateSimpleStringUUID(); - logger.debug("Address is " + addressName); + logger.debug("Address is {}", addressName); clientSession.createAddress(addressName, RoutingType.ANYCAST, false); Topic topic = new ActiveMQTopic(addressName.toString()); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -142,7 +142,7 @@ public class QueueAutoCreationTest extends JMSClientTestSupport { ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:5672"); Connection connection = factory.createConnection(); SimpleString addressName = UUIDGenerator.getInstance().generateSimpleStringUUID(); - logger.debug("Address is " + addressName); + logger.debug("Address is {}", addressName); clientSession.createAddress(addressName, RoutingType.ANYCAST, false); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -163,7 +163,7 @@ public class QueueAutoCreationTest extends JMSClientTestSupport { ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:5672"); Connection connection = factory.createConnection(); SimpleString addressName = UUIDGenerator.getInstance().generateSimpleStringUUID(); - logger.debug("Address is " + addressName); + logger.debug("Address is {}", addressName); clientSession.createAddress(addressName, RoutingType.ANYCAST, false); Connection recConnection = factory.createConnection(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/TopicDurableTests.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/TopicDurableTests.java index 9d7522bf29..2736bc365b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/TopicDurableTests.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/TopicDurableTests.java @@ -85,14 +85,14 @@ public class TopicDurableTests extends JMSClientTestSupport { assertThat(recvd1.size(), is(count)); assertMessageContent(recvd1, batchPrefix); - logger.debug(sub1ID + " :First batch messages received"); + logger.debug("{} :First batch messages received", sub1ID); assertThat(recvd2.size(), is(count)); assertMessageContent(recvd2, batchPrefix); - logger.debug(sub2ID + " :First batch messages received"); + logger.debug("{} :First batch messages received", sub2ID); subscriber1.close(); - logger.debug(sub1ID + " : closed"); + logger.debug("{} : closed", sub1ID); batchPrefix = "Second"; listMsgs = generateMessages(session, batchPrefix, count); @@ -102,15 +102,15 @@ public class TopicDurableTests extends JMSClientTestSupport { recvd2 = receiveMessages(subscriber2, count); assertThat(recvd2.size(), is(count)); assertMessageContent(recvd2, batchPrefix); - logger.debug(sub2ID + " :Second batch messages received"); + logger.debug("{} :Second batch messages received", sub2ID); subscriber1 = session.createDurableSubscriber(testTopic, sub1ID); - logger.debug(sub1ID + " :connected"); + logger.debug("{} :connected", sub1ID); recvd1 = receiveMessages(subscriber1, count); assertThat(recvd1.size(), is(count)); assertMessageContent(recvd1, batchPrefix); - logger.debug(sub1ID + " :Second batch messages received"); + logger.debug("{} :Second batch messages received", sub1ID); subscriber1.close(); subscriber2.close(); @@ -124,7 +124,7 @@ public class TopicDurableTests extends JMSClientTestSupport { public void testSharedNonDurableSubscription() throws Exception { int iterations = 10; for (int i = 0; i < iterations; i++) { - logger.debug("testSharedNonDurableSubscription; iteration: " + i); + logger.debug("testSharedNonDurableSubscription; iteration: {}", i); //SETUP-START JmsConnectionFactory connectionFactory1 = new JmsConnectionFactory(getBrokerQpidJMSConnectionURI()); Connection connection1 = connectionFactory1.createConnection(); @@ -249,7 +249,7 @@ public class TopicDurableTests extends JMSClientTestSupport { resultsList.add(new CompletableFuture<>()); receivedResList.add(new ArrayList<>()); MessageListener myListener = message -> { - logger.debug("Mesages received" + message + " count: " + totalCount.get()); + logger.debug("Mesages received{} count: {}", message, totalCount.get()); receivedResList.get(index).add(message); if (totalCount.decrementAndGet() == 0) { for (int j = 0; j < consumer.length; j++) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/QpidDispatchPeerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/QpidDispatchPeerTest.java index 12e8dd775d..0f4caf7df6 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/QpidDispatchPeerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/QpidDispatchPeerTest.java @@ -90,9 +90,7 @@ public class QpidDispatchPeerTest extends AmqpClientTestSupport { long pid = qpidProcess.pid(); int result = ExecuteUtil.runCommand(true, "kill", "-STOP", Long.toString(pid)); Assert.assertEquals(0, result); - logger.info("\n*******************************************************************************************************************************\n" + - "Paused" + - "\n*******************************************************************************************************************************"); + logger.info("\n{}\nPaused\n{}", "*".repeat(127), "*".repeat(127)); Thread.sleep(timeToWait); result = ExecuteUtil.runCommand(true, "kill", "-9", Long.toString(pid)); Assert.assertEquals(0, result); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/ValidateAMQPErrorsTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/ValidateAMQPErrorsTest.java index d0125eb87b..0b7610b6e3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/ValidateAMQPErrorsTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/ValidateAMQPErrorsTest.java @@ -406,7 +406,7 @@ public class ValidateAMQPErrorsTest extends AmqpClientTestSupport { Object value = map.get("sender"); if (value != null) { if (messagesReceived.get() != ((Integer) value).intValue()) { - logger.warn("Message out of order. Expected " + messagesReceived.get() + " but received " + value); + logger.warn("Message out of order. Expected {} but received {}", messagesReceived.get(), value); errors.incrementAndGet(); } messagesReceived.incrementAndGet(); @@ -518,7 +518,7 @@ public class ValidateAMQPErrorsTest extends AmqpClientTestSupport { String remoteAddress = remoteTarget == null ? null : remoteTarget.getAddress(); if (remoteAddress == null || !remoteAddress.startsWith(ProtonProtocolManager.MIRROR_ADDRESS)) { errors.incrementAndGet(); - logger.warn("Receiving address as " + remoteAddress); + logger.warn("Receiving address as {}", remoteAddress); return; } if (linkOpens.incrementAndGet() != 2) { @@ -552,7 +552,7 @@ public class ValidateAMQPErrorsTest extends AmqpClientTestSupport { Object value = map.get("sender"); if (value != null) { if (messagesReceived.get() != ((Integer) value).intValue()) { - logger.warn("Message out of order. Expected " + messagesReceived.get() + " but received " + value); + logger.warn("Message out of order. Expected {} but received {}", messagesReceived.get(), value); errors.incrementAndGet(); } messagesReceived.incrementAndGet(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/interop/AmqpCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/interop/AmqpCoreTest.java index 92deb3b0e8..fe94dd5a34 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/interop/AmqpCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/interop/AmqpCoreTest.java @@ -159,13 +159,13 @@ public class AmqpCoreTest extends JMSClientTestSupport { @Override public void onMessage(ClientMessage message) { - logger.debug("received: " + message.getBodySize()); + logger.debug("received: {}", message.getBodySize()); if (message.getBodySize() == 0) { logger.debug("xxx found zero len message!"); zeroLen.set(true); } - logger.debug("[receiver " + id + "] recieved: " + numMsg.incrementAndGet()); + logger.debug("[receiver {}] recieved: {}", id, numMsg.incrementAndGet()); } public void assertMessagesReceived(int num) throws Exception { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/InterruptedAMQPLargeMessage.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/InterruptedAMQPLargeMessage.java index e693850960..0d81490688 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/InterruptedAMQPLargeMessage.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/largemessages/InterruptedAMQPLargeMessage.java @@ -134,7 +134,7 @@ public class InterruptedAMQPLargeMessage extends AmqpClientTestSupport { } browserIterator.close(); - logger.debug("There are " + serverQueue.getMessageCount() + " on the queue"); + logger.debug("There are {} on the queue", serverQueue.getMessageCount()); int messageCount = (int)serverQueue.getMessageCount(); AmqpClient client = createLocalClient(); @@ -153,7 +153,7 @@ public class InterruptedAMQPLargeMessage extends AmqpClientTestSupport { message.accept(true); received++; - logger.debug("Received " + received); + logger.debug("Received {}", received); Data data = (Data)message.getWrappedMessage().getBody(); byte[] byteArray = data.getValue().getArray(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/paging/AmqpMaxReadPagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/paging/AmqpMaxReadPagingTest.java index e79589fd1e..8b43455496 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/paging/AmqpMaxReadPagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/paging/AmqpMaxReadPagingTest.java @@ -91,7 +91,7 @@ public class AmqpMaxReadPagingTest extends AmqpClientTestSupport { receiver.flow(MSG_COUNT); Assert.assertNotNull(receiver.receive(10, TimeUnit.SECONDS)); // wait some time so we have some data if (receiver.getPrefetchSize() > 10) { - logger.warn("Receiver has an unexpected size of " + receiver.getPrefetchSize() + " elements on the client buffer"); + logger.warn("Receiver has an unexpected size of {} elements on the client buffer", receiver.getPrefetchSize()); } PagingStore pagingStore = server.getPagingManager().getPageStore(SimpleString.toSimpleString(getQueueName())); Assert.assertTrue(pagingStore.isPaging()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/AddressCommandTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/AddressCommandTest.java index fb1c71a97a..82d32440c7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/AddressCommandTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/AddressCommandTest.java @@ -243,13 +243,13 @@ public class AddressCommandTest extends JMSTestBase { private void checkExecutionPassed(AbstractAction command) throws Exception { String fullMessage = output.toString(); - logger.debug("output: " + fullMessage); + logger.debug("output: {}", fullMessage); assertTrue(fullMessage, fullMessage.contains("successfully")); } private void checkExecutionFailure(AbstractAction command, String message) throws Exception { String fullMessage = error.toString(); - logger.debug("error: " + fullMessage); + logger.debug("error: {}", fullMessage); assertTrue(fullMessage, fullMessage.contains(message)); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/QueueCommandTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/QueueCommandTest.java index 0f5f91b7f1..c14771b2e2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/QueueCommandTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cli/QueueCommandTest.java @@ -384,13 +384,13 @@ public class QueueCommandTest extends JMSTestBase { private void checkExecutionPassed(AbstractAction command) throws Exception { String fullMessage = output.toString(); - logger.debug("output: " + fullMessage); + logger.debug("output: {}", fullMessage); assertTrue(fullMessage, fullMessage.contains("successfully")); } private void checkExecutionFailure(AbstractAction command, String message) throws Exception { String fullMessage = error.toString(); - logger.debug("error: " + fullMessage); + logger.debug("error: {}", fullMessage); assertTrue(fullMessage, fullMessage.contains(message)); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java index 586fe8bb14..e362201536 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AcknowledgeTest.java @@ -119,7 +119,8 @@ public class AcknowledgeTest extends ActiveMQTestBase { @Override public void onMessage(final ClientMessage message) { - logger.debug("Got message " + c++); + int msgNum = c++; + logger.debug("Got message {}", msgNum); latch.countDown(); } }); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java index b496166dc1..8f31493ecf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/AutoCreateJmsDestinationTest.java @@ -383,7 +383,7 @@ public class AutoCreateJmsDestinationTest extends JMSTestBase { ConnectionFactory factory = new ActiveMQConnectionFactory(); Connection connection = factory.createConnection(); SimpleString addressName = UUIDGenerator.getInstance().generateSimpleStringUUID(); - logger.debug("Address is " + addressName); + logger.debug("Address is {}", addressName); clientSession.createAddress(addressName, RoutingType.ANYCAST, false); Topic topic = new ActiveMQTopic(addressName.toString()); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -407,7 +407,7 @@ public class AutoCreateJmsDestinationTest extends JMSTestBase { ConnectionFactory factory = new ActiveMQConnectionFactory(); try (Connection connection = factory.createConnection()) { SimpleString addressName = UUIDGenerator.getInstance().generateSimpleStringUUID(); - logger.debug("Address is " + addressName); + logger.debug("Address is {}", addressName); javax.jms.Queue queue = new ActiveMQQueue(addressName.toString()); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(null); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/BlockingSendTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/BlockingSendTest.java index 67c8cbca4b..1fc0761522 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/BlockingSendTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/BlockingSendTest.java @@ -50,7 +50,7 @@ public class BlockingSendTest extends ActiveMQTestBase { server.start(); - logger.debug("sync = " + server.getConfiguration().isJournalSyncNonTransactional()); + logger.debug("sync = {}", server.getConfiguration().isJournalSyncNonTransactional()); locator = createInVMNonHALocator().setBlockOnDurableSend(true); factory = createSessionFactory(locator); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerFilterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerFilterTest.java index b61c43d291..9c2847601f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerFilterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerFilterTest.java @@ -275,7 +275,7 @@ public class ConsumerFilterTest extends ActiveMQTestBase { private void readConsumer(String consumerName, ClientConsumer consumer) throws Exception { ClientMessage message = consumer.receive(5000); assertNotNull(message); - logger.debug("consumer = " + consumerName + " message, color=" + message.getStringProperty("color") + ", msg = " + message.getStringProperty("value")); + logger.debug("consumer = {} message, color={}, msg = {}",consumerName, message.getStringProperty("color"), message.getStringProperty("value")); message.acknowledge(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java index 967218a95d..cb737cba08 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerStuckTest.java @@ -91,7 +91,7 @@ public class ConsumerStuckTest extends ActiveMQTestBase { try { while (!Thread.interrupted()) { ClientMessage received = consumer.receive(500); - logger.debug("Received " + received); + logger.debug("Received {}", received); if (first) { first = false; nettyConnection.getNettyChannel().config().setAutoRead(false); @@ -113,7 +113,7 @@ public class ConsumerStuckTest extends ActiveMQTestBase { assertEquals(1, server.getSessions().size()); - logger.debug("sessions = " + server.getSessions().size()); + logger.debug("sessions = {}", server.getSessions().size()); assertEquals(1, server.getConnectionCount()); @@ -125,16 +125,17 @@ public class ConsumerStuckTest extends ActiveMQTestBase { Thread.sleep(10); } - logger.debug("Time = " + System.currentTimeMillis() + " time diff = " + (System.currentTimeMillis() - timeStart) + ", connections Size = " + server.getConnectionCount() + " sessions = " + server.getSessions().size()); + logger.debug("Time = {} time diff = {}, connections Size = {} sessions = {}", + System.currentTimeMillis(), (System.currentTimeMillis() - timeStart), server.getConnectionCount(), server.getSessions().size()); if (server.getSessions().size() != 0) { System.out.println(threadDump("Thread dump")); fail("The cleanup wasn't able to finish cleaning the session. It's probably stuck, look at the thread dump generated by the test for more information"); } - logger.debug("Size = " + server.getConnectionCount()); + logger.debug("Size = {}", server.getConnectionCount()); - logger.debug("sessions = " + server.getSessions().size()); + logger.debug("sessions = {}", server.getSessions().size()); if (server.getSessions().size() != 0) { System.out.println(threadDump("Thread dump")); @@ -174,7 +175,7 @@ public class ConsumerStuckTest extends ActiveMQTestBase { try { while (!Thread.interrupted()) { ClientMessage received = consumer.receive(500); - logger.debug("Received " + received); + logger.debug("Received {}", received); if (first) { first = false; nettyConnection.getNettyChannel().config().setAutoRead(false); @@ -223,7 +224,7 @@ public class ConsumerStuckTest extends ActiveMQTestBase { assertEquals(2, server.getSessions().size()); - logger.debug("sessions = " + server.getSessions().size()); + logger.debug("sessions = {}", server.getSessions().size()); assertEquals(2, server.getConnectionCount()); @@ -233,9 +234,9 @@ public class ConsumerStuckTest extends ActiveMQTestBase { Thread.sleep(10); } - logger.debug("Size = " + server.getConnectionCount()); + logger.debug("Size = {}", server.getConnectionCount()); - logger.debug("sessions = " + server.getSessions().size()); + logger.debug("sessions = {}", server.getSessions().size()); if (server.getSessions().size() != 1) { System.out.println(threadDump("Thread dump")); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java index 121208709f..65f577593f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ConsumerTest.java @@ -209,13 +209,13 @@ public class ConsumerTest extends ActiveMQTestBase { Assert.assertNotNull(message2); - logger.debug("Id::" + message2.getMessageID()); + logger.debug("Id::{}", message2.getMessageID()); - logger.debug("Received " + message2); + logger.debug("Received {}", message2); - logger.debug("Clie:" + ByteUtil.bytesToHex(message2.getBuffer().array(), 4)); + logger.debug("Clie:{}", ByteUtil.bytesToHex(message2.getBuffer().array(), 4)); - logger.debug("String::" + message2.getReadOnlyBodyBuffer().readString()); + logger.debug("String::{}", message2.getReadOnlyBodyBuffer().readString()); Assert.assertEquals("elo", message2.getStringProperty("hello")); @@ -596,7 +596,7 @@ public class ConsumerTest extends ActiveMQTestBase { } long end = System.currentTimeMillis(); - logger.debug("Time = " + (end - time)); + logger.debug("Time = {}", (end - time)); { TextMessage dummyMessage = session.createTextMessage(); @@ -1266,11 +1266,11 @@ public class ConsumerTest extends ActiveMQTestBase { final long messagesPerRun = (forks * messages); for (int r = 0; r < runs; r++) { onStartRun.await(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); - logger.debug("started run " + r); + logger.debug("started run {}", r); final long start = System.currentTimeMillis(); onFinishRun.await(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); final long elapsedMillis = System.currentTimeMillis() - start; - logger.debug((messagesPerRun * 1000L) / elapsedMillis + " msg/sec"); + logger.debug("{} msg/sec", (messagesPerRun * 1000L) / elapsedMillis); } Stream.of(producersRunners).forEach(runner -> { try { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryLargeMessageTest.java index 24dd4e2e90..8afff013ea 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ExpiryLargeMessageTest.java @@ -160,7 +160,7 @@ public class ExpiryLargeMessageTest extends ActiveMQTestBase { assertNotNull(message); if (i % 10 == 0) { - logger.debug("Received " + i); + logger.debug("Received {}", i); } for (int location = 0; location < messageSize; location++) { @@ -210,7 +210,7 @@ public class ExpiryLargeMessageTest extends ActiveMQTestBase { assertNotNull(message); if (i % 10 == 0) { - logger.debug("Received " + i); + logger.debug("Received {}", i); } for (int location = 0; location < messageSize; location++) { @@ -447,7 +447,7 @@ public class ExpiryLargeMessageTest extends ActiveMQTestBase { assertNotNull(message); if (i % 10 == 0) { - logger.debug("Received " + i); + logger.debug("Received {}", i); } for (int location = 0; location < messageSize; location++) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FullQualifiedQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FullQualifiedQueueTest.java index db17e4b709..77285a3cd2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FullQualifiedQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/FullQualifiedQueueTest.java @@ -97,31 +97,31 @@ public class FullQualifiedQueueTest extends ActiveMQTestBase { //each anycast consumer receives one, each multicast receives three. ClientMessage m = consumer1.receive(2000); assertNotNull(m); - logger.debug("consumer1 : " + m); + logger.debug("consumer1 : {}", m); m.acknowledge(); m = consumer2.receive(2000); assertNotNull(m); - logger.debug("consumer2 : " + m); + logger.debug("consumer2 : {}", m); m.acknowledge(); m = consumer3.receive(2000); assertNotNull(m); - logger.debug("consumer3 : " + m); + logger.debug("consumer3 : {}", m); m.acknowledge(); for (int i = 0; i < num; i++) { m = consumer4.receive(2000); assertNotNull(m); - logger.debug("consumer4 : " + m); + logger.debug("consumer4 : {}", m); m.acknowledge(); m = consumer5.receive(2000); assertNotNull(m); - logger.debug("consumer5 : " + m); + logger.debug("consumer5 : {}", m); m.acknowledge(); m = consumer6.receive(2000); assertNotNull(m); - logger.debug("consumer6 : " + m); + logger.debug("consumer6 : {}", m); m.acknowledge(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java index 65bcd763c8..da54d4835c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/HangConsumerTest.java @@ -445,14 +445,14 @@ public class HangConsumerTest extends ActiveMQTestBase { int bindings = 0; for (RecordInfo info : infos) { - logger.debug("info: " + info); + logger.debug("info: {}", info); if (info.getUserRecordType() == JournalRecordIds.QUEUE_BINDING_RECORD) { bindings++; } } assertEquals(1, bindings); - logger.debug("Bindings: " + bindings); + logger.debug("Bindings: {}", bindings); messagesJournal.stop(); if (i < 4) server.start(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java index 120639ece4..4685c3e82c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/InterruptedLargeMessageTest.java @@ -452,7 +452,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { server.start(); for (int start = 0; start < 2; start++) { - log.debug("Start " + start); + log.debug("Start {}", start); sf = createSessionFactory(locator); @@ -466,7 +466,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { ClientConsumer cons1 = session.createConsumer(ADDRESS); session.start(); for (int i = 0; i < 10; i++) { - log.info("I = " + i); + log.info("I = {}", i); ClientMessage msg = cons1.receive(5000); Assert.assertNotNull(msg); Assert.assertEquals(1, msg.getIntProperty("txid").intValue()); @@ -531,7 +531,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase { @Override public void postAcknowledge(final MessageReference ref, AckReason reason) { - log.debug("Ignoring postACK on message " + ref); + log.debug("Ignoring postACK on message {}", ref); } @Override diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JMSPagingFileDeleteTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JMSPagingFileDeleteTest.java index 023d7e0998..e2974a4751 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JMSPagingFileDeleteTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/JMSPagingFileDeleteTest.java @@ -109,7 +109,7 @@ public class JMSPagingFileDeleteTest extends JMSTestBase { for (int i = 0; i < JMSPagingFileDeleteTest.MESSAGE_NUM; i++) { producer.send(bytesMessage); } - logger.debug("Sent " + JMSPagingFileDeleteTest.MESSAGE_NUM + " messages."); + logger.debug("Sent {} messages.", JMSPagingFileDeleteTest.MESSAGE_NUM); pagingStore = server.getPagingManager().getPageStore(new SimpleString("topic1")); printPageStoreInfo(pagingStore); @@ -157,7 +157,7 @@ public class JMSPagingFileDeleteTest extends JMSTestBase { for (int i = 0; i < JMSPagingFileDeleteTest.MESSAGE_NUM; i++) { producer.send(bytesMessage); } - logger.debug("Sent " + JMSPagingFileDeleteTest.MESSAGE_NUM + " messages."); + logger.debug("Sent {} messages.", JMSPagingFileDeleteTest.MESSAGE_NUM); pagingStore = server.getPagingManager().getPageStore(new SimpleString("topic1")); printPageStoreInfo(pagingStore); @@ -235,10 +235,10 @@ public class JMSPagingFileDeleteTest extends JMSTestBase { private void printPageStoreInfo(PagingStore pagingStore) throws Exception { logger.debug("---------- Paging Store Info ----------"); - logger.debug(" CurrentPage = " + pagingStore.getCurrentPage()); - logger.debug(" FirstPage = " + pagingStore.getFirstPage()); - logger.debug(" Number of Pages = " + pagingStore.getNumberOfPages()); - logger.debug(" Address Size = " + pagingStore.getAddressSize()); - logger.debug(" Is Paging = " + pagingStore.isPaging()); + logger.debug(" CurrentPage = {}", pagingStore.getCurrentPage()); + logger.debug(" FirstPage = {}", pagingStore.getFirstPage()); + logger.debug(" Number of Pages = {}", pagingStore.getNumberOfPages()); + logger.debug(" Address Size = {}", pagingStore.getAddressSize()); + logger.debug(" Is Paging = {}", pagingStore.isPaging()); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java index 4ef6f7f597..3c00fd5b8e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/MultipleThreadFilterOneTest.java @@ -152,7 +152,7 @@ public class MultipleThreadFilterOneTest extends ActiveMQTestBase { msg.acknowledge(); if (i % 500 == 0) { - logger.debug("Consumed " + i); + logger.debug("Consumed {}", i); consumerSession.commit(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java index a890c93588..d72745ce84 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/NIOvsOIOTest.java @@ -200,9 +200,6 @@ public class NIOvsOIOTest extends ActiveMQTestBase { } catch (Exception e) { log.error("Caught exception", e); } - - //log.debug(id + " sent message " + i); - } } @@ -274,9 +271,6 @@ public class NIOvsOIOTest extends ActiveMQTestBase { if (count == numMessages) { latch.countDown(); } - - //log.debug(id + " got msg " + count); - } public void terminate() throws Exception { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java index adbbd31b23..649e5e96bf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerFlowControlTest.java @@ -305,7 +305,7 @@ public class ProducerFlowControlTest extends ActiveMQTestBase { double rate = 1000 * (double) numMessages / (end - start); - logger.debug("rate is " + rate + " msgs / sec"); + logger.debug("rate is {} msgs / sec", rate); } @Test diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerTest.java index eebef061bb..09dd70d8fa 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/ProducerTest.java @@ -99,7 +99,7 @@ public class ProducerTest extends ActiveMQTestBase { for (int i = 0; i < 100; i++) { final CountDownLatch latch = new CountDownLatch(1); - logger.debug("Try " + i); + logger.debug("Try {}", i); ClientSessionFactory cf = locator.createSessionFactory(); final ClientSession session = cf.createSession(false, true, true); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java index 739f0ce759..9dd2b67151 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SelfExpandingBufferTest.java @@ -98,11 +98,13 @@ public class SelfExpandingBufferTest extends ActiveMQTestBase { byte[] receivedBytes = new byte[bytes.length]; - // log.debug("buffer start pos should be at " + PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT); + // final int bufferStartPos = PacketImpl.PACKET_HEADERS_SIZE + DataConstants.SIZE_INT; // - // log.debug("buffer pos at " + msg2.getBodyBuffer().readerIndex()); + // log.debug("buffer start pos should be at {}", bufferStartPos); // - // log.debug("buffer length should be " + msg2.getBodyBuffer().readInt(PacketImpl.PACKET_HEADERS_SIZE)); + // log.debug("buffer pos at {}", msg2.getBodyBuffer().readerIndex()); + // + // log.debug("buffer length should be {}", msg2.getBodyBuffer().readInt(PacketImpl.PACKET_HEADERS_SIZE)); msg2.getBodyBuffer().readBytes(receivedBytes); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java index 5d7ff24203..1c3a2a09c2 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SendAckFailTest.java @@ -196,14 +196,14 @@ public class SendAckFailTest extends SpawnedTestBase { ClientMessage message = consumer.receive(1000); if (message == null) { for (Integer msgi : listSent) { - logger.debug("Message " + msgi + " was lost"); + logger.debug("Message {} was lost", msgi); } fail("missed messages!"); } message.acknowledge(); if (!listSent.remove(message.getIntProperty("myid"))) { - logger.debug("Message " + message + " with id " + message.getIntProperty("myid") + " received in duplicate"); + logger.debug("Message {} with id {} received in duplicate", message, message.getIntProperty("myid")); fail("Message " + message + " with id " + message.getIntProperty("myid") + " received in duplicate"); } } @@ -276,7 +276,7 @@ public class SendAckFailTest extends SpawnedTestBase { - logger.debug("Location::" + server.getConfiguration().getJournalLocation().getAbsolutePath()); + logger.debug("Location::{}", server.getConfiguration().getJournalLocation().getAbsolutePath()); addServer(server); server.start(); return server; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/DummyInterceptor.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/DummyInterceptor.java index 9f08de8bd4..1ba2eca364 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/DummyInterceptor.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/clientcrash/DummyInterceptor.java @@ -49,7 +49,7 @@ public class DummyInterceptor implements Interceptor { @Override public boolean intercept(final Packet packet, final RemotingConnection conn) throws ActiveMQException { - log.debug("DummyFilter packet = " + packet.getClass().getName()); + log.debug("DummyFilter packet = {}", packet.getClass().getName()); syncCounter.addAndGet(1); if (sendException) { throw new ActiveMQInternalErrorException(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/crossprotocol/ProtocolsMessageLoadBalancingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/crossprotocol/ProtocolsMessageLoadBalancingTest.java index 3af67a1a42..9802255e73 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/crossprotocol/ProtocolsMessageLoadBalancingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/crossprotocol/ProtocolsMessageLoadBalancingTest.java @@ -309,7 +309,7 @@ public class ProtocolsMessageLoadBalancingTest extends ClusterTestBase { startServers(MessageLoadBalancingType.STRICT); - logger.debug("connections " + servers[1].getRemotingService().getConnections().size()); + logger.debug("connections {}", servers[1].getRemotingService().getConnections().size()); Wait.assertEquals(3, () -> servers[1].getRemotingService().getConnections().size()); Wait.assertEquals(3, () -> servers[0].getRemotingService().getConnections().size()); @@ -366,7 +366,7 @@ public class ProtocolsMessageLoadBalancingTest extends ClusterTestBase { waitForBindings(0, "queues.0", 1, 1, false); waitForBindings(1, "queues.0", 1, 1, false); - logger.debug("connections " + servers[1].getRemotingService().getConnections().size()); + logger.debug("connections {}", servers[1].getRemotingService().getConnections().size()); // sending Messages.. they should be load balanced { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java index fd3506def6..37af26ec1c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusterTestBase.java @@ -282,7 +282,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { ActiveMQServer server = servers[bNode]; if (log.isDebugEnabled()) { - log.debug("waiting for " + Arrays.toString(nodes) + " on the topology for server = " + server); + log.debug("waiting for {} on the topology for server = {}", Arrays.toString(nodes), server); } long start = System.currentTimeMillis(); @@ -389,7 +389,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { topologyDiagram.append("\n"); log.debug(topologyDiagram.toString()); } catch (Throwable e) { - log.warn("error printing the topology::" + e.getMessage(), e); + log.warn(String.format("error printing the topology::%s", e.getMessage()), e); } } @@ -444,15 +444,8 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { final int expectedConsumerCount, final boolean local) throws Exception { if (log.isDebugEnabled()) { - log.debug("waiting for bindings on node " + node + - " address " + - address + - " expectedBindingCount " + - expectedBindingCount + - " consumerCount " + - expectedConsumerCount + - " local " + - local); + log.debug("waiting for bindings on node {} address {} expectedBindingCount {} consumerCount {} local {}", + node, address, expectedBindingCount, expectedConsumerCount, local); } ActiveMQServer server = servers[node]; @@ -1269,7 +1262,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { checkMessageBody(message); - // log.debug("consumer " + consumerIDs[i] + " received message " + count); + // log.debug("consumer {} received message {}", consumerIDs[i], count); Assert.assertFalse(counts.contains(count)); @@ -2036,7 +2029,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase { protected void stopServers(final int... nodes) throws Exception { if (log.isDebugEnabled()) { - log.debug("Stopping nodes " + Arrays.toString(nodes)); + log.debug("Stopping nodes {}", Arrays.toString(nodes)); } Exception exception = null; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java index 21f67b16a7..1d25d13b4d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/ClusteredGroupingTest.java @@ -665,11 +665,11 @@ public class ClusteredGroupingTest extends ClusterTestBase { totalMessageProduced.incrementAndGet(); messageCount++; } catch (ActiveMQException e) { - log.warn("Producer thread threw exception while sending messages to " + targetServer + ": " + e.getMessage()); + log.warn("Producer thread threw exception while sending messages to {}: {}", targetServer, e.getMessage()); // in case of a failure we change the group to make possible errors more likely group = group + "afterFail"; } catch (Exception e) { - log.warn("Producer thread threw unexpected exception while sending messages to " + targetServer + ": " + e.getMessage()); + log.warn("Producer thread threw unexpected exception while sending messages to {}: {}", targetServer, e.getMessage()); group = group + "afterFail"; break; } @@ -757,10 +757,10 @@ public class ClusteredGroupingTest extends ClusterTestBase { log.trace("Consumed message {} from server {}. Total consumed: {}", m.getStringProperty(Message.HDR_DUPLICATE_DETECTION_ID), targetServer, totalMessagesConsumed.incrementAndGet()); } catch (ActiveMQException e) { errors.incrementAndGet(); - log.warn("Consumer thread threw exception while receiving messages from server " + targetServer + ".: " + e.getMessage()); + log.warn("Consumer thread threw exception while receiving messages from server {}.: {}", targetServer, e.getMessage()); } catch (Exception e) { errors.incrementAndGet(); - log.warn("Consumer thread threw unexpected exception while receiving messages from server " + targetServer + ".: " + e.getMessage()); + log.warn("Consumer thread threw unexpected exception while receiving messages from server {}.: {}", targetServer, e.getMessage()); return; } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java index 75186181a7..38b6197ad8 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/AsynchronousFailoverTest.java @@ -410,7 +410,7 @@ public class AsynchronousFailoverTest extends FailoverTestBase { Thread.sleep(2000); retry = true; } catch (ActiveMQException e) { - log.debug("#test Exception " + e, e); + log.debug("#test Exception {}", e.getMessage(), e); throw e; } } @@ -476,7 +476,7 @@ public class AsynchronousFailoverTest extends FailoverTestBase { } catch (ActiveMQException e) { // This could eventually happen // We will get rid of this when we implement 2 phase commit on failover - log.warn("exception during commit, continue " + e.getMessage(), e); + log.warn("exception during commit, continue {}", e.getMessage(), e); continue; } @@ -488,7 +488,8 @@ public class AsynchronousFailoverTest extends FailoverTestBase { } } catch (Throwable e) { if (log.isDebugEnabled()) { - log.debug(threadDump("Thread dump, messagesReceived = " + msgs.size())); + String dumpMessage = "Thread dump, messagesReceived = " + msgs.size(); + log.debug(threadDump(dumpMessage)); } logAndSystemOut(e.getMessage() + " messages received"); for (Integer msg : msgs) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ClusterWithBackupFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ClusterWithBackupFailoverTest.java index e29f7e78b9..a60c75231a 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ClusterWithBackupFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ClusterWithBackupFailoverTest.java @@ -60,8 +60,8 @@ public abstract class ClusterWithBackupFailoverTest extends ClusterWithBackupFa send(2, QUEUES_TESTADDRESS, 10, false, null); verifyReceiveRoundRobinInSomeOrder(true, 10, 0, 1, 2); Thread.sleep(1000); - log.debug("######### Topology on client = " + locators[0].getTopology().describe() + " locator = " + locators[0]); - log.debug("######### Crashing it........., sfs[0] = " + sfs[0]); + log.debug("######### Topology on client = {} locator = {}", locators[0].getTopology().describe(), locators[0]); + log.debug("######### Crashing it........., sfs[0] = {}", sfs[0]); failNode(0); waitForFailoverTopology(4, 3, 1, 2); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverListenerTest.java index 5246e8703d..c2e40ee02d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverListenerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverListenerTest.java @@ -77,7 +77,7 @@ public class FailoverListenerTest extends FailoverTestBase { assertTrue(failureLatch.await(5, TimeUnit.SECONDS)); assertEquals(FailoverEventType.FAILURE_DETECTED, listener.getFailoverEventType().get(0)); - logger.debug("backup (nowLive) topology = " + backupServer.getServer().getClusterManager().getDefaultConnection(null).getTopology().describe()); + logger.debug("backup (nowLive) topology = {}", backupServer.getServer().getClusterManager().getDefaultConnection(null).getTopology().describe()); logger.debug("Server Crash!!!"); @@ -104,7 +104,7 @@ public class FailoverListenerTest extends FailoverTestBase { //the life server should be online by now assertEquals(FailoverEventType.FAILOVER_COMPLETED, listener.getFailoverEventType().get(3)); - logger.debug("After failback: " + locator.getTopology().describe()); + logger.debug("After failback: {}", locator.getTopology().describe()); message = session.createMessage(true); @@ -271,7 +271,7 @@ public class FailoverListenerTest extends FailoverTestBase { @Override public void failoverEvent(FailoverEventType eventType) { this.failoverTypeEvent.add(eventType); - logger.debug("Failover event just happen : " + eventType.toString()); + logger.debug("Failover event just happen : {}", eventType.toString()); if (eventType == FailoverEventType.FAILURE_DETECTED) { failureLatch.countDown(); } else if (eventType == FailoverEventType.FAILOVER_COMPLETED || eventType == FailoverEventType.FAILOVER_FAILED) { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleBackupsFailoverTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleBackupsFailoverTestBase.java index 69f1c3cda5..d375ec317e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleBackupsFailoverTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/MultipleBackupsFailoverTestBase.java @@ -142,7 +142,7 @@ public abstract class MultipleBackupsFailoverTestBase extends ActiveMQTestBase { locator.removeClusterTopologyListener(topListener); if (!ok) { if (server != null) { - logger.warn("failed topology, Topology on server = " + server.getClusterManager().describe()); + logger.warn("failed topology, Topology on server = {}", server.getClusterManager().describe()); } } Assert.assertTrue("expected " + topologyMembers + " members", ok); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkFailureFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkFailureFailoverTest.java index 08e631a573..e6f0f4746b 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkFailureFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkFailureFailoverTest.java @@ -168,7 +168,7 @@ public class NetworkFailureFailoverTest extends FailoverTestBase { liveServer.addInterceptor(new Interceptor() { @Override public boolean intercept(Packet packet, RemotingConnection connection) throws ActiveMQException { - //logger.debug("Received " + packet); + //logger.debug("Received {}", packet); if (packet instanceof SessionSendMessage) { if (countSent.incrementAndGet() == 500) { @@ -253,7 +253,7 @@ public class NetworkFailureFailoverTest extends FailoverTestBase { latchReceived.countDown(); msgReceived.acknowledge(); if (received++ % 100 == 0) { - logger.debug("Received " + received); + logger.debug("Received {}", received); sessionConsumer.commit(); } } else { @@ -276,7 +276,7 @@ public class NetworkFailureFailoverTest extends FailoverTestBase { do { try { if (sentMessages.get() % 100 == 0) { - logger.debug("Sent " + sentMessages.get()); + logger.debug("Sent {}", sentMessages.get()); } producer.send(createMessage(sessionProducer, sentMessages.get(), true)); break; @@ -391,7 +391,7 @@ public class NetworkFailureFailoverTest extends FailoverTestBase { NetUtil.netDown(LIVE_IP); liveServer.crash(true, false); } - logger.debug("Received " + received); + logger.debug("Received {}", received); sessionConsumer.commit(); } } else { @@ -413,7 +413,7 @@ public class NetworkFailureFailoverTest extends FailoverTestBase { do { try { if (sentMessages.get() % 100 == 0) { - logger.debug("Sent " + sentMessages.get()); + logger.debug("Sent {}", sentMessages.get()); } producer.send(createMessage(sessionProducer, sentMessages.get(), true)); break; @@ -459,7 +459,7 @@ public class NetworkFailureFailoverTest extends FailoverTestBase { liveServer.addInterceptor(new Interceptor() { @Override public boolean intercept(Packet packet, RemotingConnection connection) throws ActiveMQException { - //logger.debug("Received " + packet); + //logger.debug("Received {}", packet); if (packet instanceof CreateSessionMessage) { if (countSent.incrementAndGet() == 50) { @@ -522,7 +522,7 @@ public class NetworkFailureFailoverTest extends FailoverTestBase { while (running.get() && received < numSessions) { try { ClientSession session = sessionFactory.createSession(); - logger.debug("Creating session, currentLatch = " + latchCreated.getCount()); + logger.debug("Creating session, currentLatch = {}", latchCreated.getCount()); session.close(); latchCreated.countDown(); } catch (Throwable e) { @@ -570,7 +570,7 @@ public class NetworkFailureFailoverTest extends FailoverTestBase { liveServer.addInterceptor(new Interceptor() { @Override public boolean intercept(Packet packet, RemotingConnection connection) throws ActiveMQException { - //logger.debug("Received " + packet); + //logger.debug("Received {}", packet); if (packet instanceof SessionSendMessage) { if (countSent.incrementAndGet() == 50) { @@ -655,7 +655,7 @@ public class NetworkFailureFailoverTest extends FailoverTestBase { while (sentMessages.get() < numMessages && running.get()) { try { if (sentMessages.get() % 10 == 0) { - logger.debug("Sent " + sentMessages.get()); + logger.debug("Sent {}", sentMessages.get()); } producer.send(createMessage(sessionProducer, sentMessages.get(), true)); sentMessages.incrementAndGet(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedDistributionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedDistributionTest.java index c5e98e2dbe..040ed0533d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedDistributionTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/ReplicatedDistributionTest.java @@ -121,13 +121,13 @@ public class ReplicatedDistributionTest extends ClusterTestBase { Assert.assertNotNull(msg); - // System.out.println(i + " msg = " + msg); + logger.trace("i msg = {}", i, msg); int received = msg.getIntProperty("key"); if (i != received) { // Shouldn't this be a failure? - logger.warn(i + "!=" + received); + logger.warn("{}!={}", i, received); } msg.acknowledge(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java index 4921479ed2..f1ce5703e1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/SingleLiveMultipleBackupsFailoverTest.java @@ -86,25 +86,25 @@ public class SingleLiveMultipleBackupsFailoverTest extends MultipleBackupsFailov session.close(); backupNode = waitForNewLive(5, true, servers, 1, 2, 3, 4, 5); session = sendAndConsume(sf, false); - logger.debug("failing node " + backupNode); + logger.debug("failing node {}", backupNode); servers.get(backupNode).crash(session); session.close(); backupNode = waitForNewLive(5, true, servers, 1, 2, 3, 4, 5); session = sendAndConsume(sf, false); - logger.debug("failing node " + backupNode); + logger.debug("failing node {}", backupNode); servers.get(backupNode).crash(session); session.close(); backupNode = waitForNewLive(5, true, servers, 1, 2, 3, 4, 5); session = sendAndConsume(sf, false); - logger.debug("failing node " + backupNode); + logger.debug("failing node {}", backupNode); servers.get(backupNode).crash(session); session.close(); backupNode = waitForNewLive(5, true, servers, 1, 2, 3, 4, 5); session = sendAndConsume(sf, false); - logger.debug("failing node " + backupNode); + logger.debug("failing node {}", backupNode); servers.get(backupNode).crash(session); session.close(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java index 762c7774d1..7bc55781d3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/MultiThreadRandomReattachTestBase.java @@ -358,7 +358,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt long end = System.currentTimeMillis(); - log.debug("duration " + (end - start)); + log.debug("duration {}", (end - start)); } protected void doTestB(final ClientSessionFactory sf, final int threadNum) throws Exception { @@ -438,7 +438,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt long end = System.currentTimeMillis(); - log.debug("duration " + (end - start)); + log.debug("duration {}", (end - start)); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/ReattachTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/ReattachTest.java index 469714ba4d..0e60e2ecf3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/ReattachTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/reattach/ReattachTest.java @@ -567,7 +567,7 @@ public class ReattachTest extends ActiveMQTestBase { try { connFailure.fail(new ActiveMQNotConnectedException()); } catch (Exception e) { - logger.warn("Error on the timer " + e); + logger.warn("Error on the timer {}", e); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/restart/ClusterRestartTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/restart/ClusterRestartTest.java index 50a88e69a5..490e9234c3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/restart/ClusterRestartTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/restart/ClusterRestartTest.java @@ -42,8 +42,8 @@ public class ClusterRestartTest extends ClusterTestBase { startServers(0, 1); - log.debug("server 0 = " + getServer(0).getNodeID()); - log.debug("server 1 = " + getServer(1).getNodeID()); + log.debug("server 0 = {}", getServer(0).getNodeID()); + log.debug("server 1 = {}", getServer(1).getNodeID()); setupSessionFactory(0, isNetty(), 15); setupSessionFactory(1, isNetty()); @@ -105,8 +105,8 @@ public class ClusterRestartTest extends ClusterTestBase { startServers(0, 1); - log.debug("server 0 = " + getServer(0).getNodeID()); - log.debug("server 1 = " + getServer(1).getNodeID()); + log.debug("server 0 = {}", getServer(0).getNodeID()); + log.debug("server 1 = {}", getServer(1).getNodeID()); setupSessionFactory(0, isNetty(), 15); setupSessionFactory(1, isNetty()); @@ -158,7 +158,7 @@ public class ClusterRestartTest extends ClusterTestBase { for (int i = 0; i < num; i++) { Collection bindings0 = getServer(i).getPostOffice().getBindingsForAddress(new SimpleString("queues.testaddress")).getBindings(); for (Binding binding : bindings0) { - log.debug(binding + " on node " + i + " at " + binding.getID()); + log.debug("{} on node {} at {}", binding, i, binding.getID()); } } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/MessageIDMultiProtocolTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/MessageIDMultiProtocolTest.java index 8978f64f2b..eb6138c7c0 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/MessageIDMultiProtocolTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/MessageIDMultiProtocolTest.java @@ -120,8 +120,8 @@ public class MessageIDMultiProtocolTest extends OpenWireTestBase { Assert.assertTrue(messageId.startsWith("ID:")); - logger.debug("[" + protocolSender + "][" + protocolConsumer + "] " + messageId); - logger.debug("[" + protocolSender + "][" + protocolConsumer + "] " + sentMid); + logger.debug("[{}][{}] {}", protocolSender, protocolConsumer, messageId); + logger.debug("[{}][{}] {}", protocolSender, protocolConsumer, sentMid); if (protocolConsumer.equals(protocolSender)) { //only same protocol we guarantee the same JMSMessageID diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/RequestReplyMultiProtocolTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/RequestReplyMultiProtocolTest.java index 33a3682ea0..7e919fe14c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/RequestReplyMultiProtocolTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/crossprotocol/RequestReplyMultiProtocolTest.java @@ -161,7 +161,7 @@ public class RequestReplyMultiProtocolTest extends OpenWireTestBase { TextMessage received = (TextMessage)consumer.receive(5000); Assert.assertNotNull(received); - logger.debug("Destination::" + received.getJMSDestination()); + logger.debug("Destination::{}", received.getJMSDestination()); if (useTopic) { Assert.assertTrue("JMSDestination type is " + received.getJMSDestination().getClass(), received.getJMSDestination() instanceof Topic); @@ -172,7 +172,7 @@ public class RequestReplyMultiProtocolTest extends OpenWireTestBase { Assert.assertNotNull(received.getJMSReplyTo()); Assert.assertEquals("hello " + (i++), received.getText()); - logger.debug("received " + received.getText() + " and " + received.getJMSReplyTo()); + logger.debug("received {} and {}", received.getText(), received.getJMSReplyTo()); if (destination instanceof Queue) { Assert.assertTrue("Type is " + received.getJMSReplyTo().getClass().toString(), received.getJMSReplyTo() instanceof Queue); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java index 329c46e76c..c53f11f4f3 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryTest.java @@ -359,7 +359,7 @@ public class DiscoveryTest extends DiscoveryBaseTest { byte[] btreceived = client.receiveBroadcast(5, TimeUnit.SECONDS); - logger.debug("BTReceived = " + Arrays.toString(btreceived)); + logger.debug("BTReceived = {}", Arrays.toString(btreceived)); assertNotNull(btreceived); @@ -397,7 +397,7 @@ public class DiscoveryTest extends DiscoveryBaseTest { InetAddress localAddress = InetAddress.getLoopbackAddress(); - logger.debug("Local address is " + localAddress); + logger.debug("Local address is {}", localAddress); bg = newBroadcast(nodeID, RandomUtil.randomString(), localAddress, -1, groupAddress, groupPort); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java index d3c30bff9f..355c3c4541 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/divert/DivertTest.java @@ -509,7 +509,7 @@ public class DivertTest extends ActiveMQTestBase { for (int i = 0; i < numMessages * 2; i++) { ClientMessage message = consumerExpiry.receive(5000); - logger.debug("Received message " + message); + logger.debug("Received message {}", message); assertNotNull(message); if (message.getStringProperty(Message.HDR_ORIGINAL_QUEUE).equals("queue1")) { @@ -517,7 +517,7 @@ public class DivertTest extends ActiveMQTestBase { } else if (message.getStringProperty(Message.HDR_ORIGINAL_QUEUE).equals("queue2")) { countOriginal2++; } else { - logger.debug("message not part of any expired queue" + message); + logger.debug("message not part of any expired queue {}", message); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java index d1a05d9959..afbe1b5ac4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/interceptors/InterceptorTest.java @@ -113,13 +113,13 @@ public class InterceptorTest extends ActiveMQTestBase { CreateQueueMessage createQueue = (CreateQueueMessage) packet; createQueue.setFilterString(new SimpleString("userName='" + userName + "'")); - logger.debug("userName on createQueue = " + userName); + logger.debug("userName on createQueue = {}", userName); } else if (packet.getType() == PacketImpl.SESS_SEND) { String userName = getUsername(packet, connection); MessagePacket msgPacket = (MessagePacket) packet; msgPacket.getMessage().putStringProperty("userName", userName); - logger.debug("userName on send = " + userName); + logger.debug("userName on send = {}", userName); } return true; @@ -143,13 +143,13 @@ public class InterceptorTest extends ActiveMQTestBase { SessionCreateConsumerMessage createQueue = (SessionCreateConsumerMessage) packet; createQueue.setFilterString(new SimpleString("userName='" + userName + "'")); - logger.debug("userName = " + userName); + logger.debug("userName = {}", userName); } else if (packet.getType() == PacketImpl.SESS_SEND) { String userName = getUsername(packet, connection); MessagePacket msgPacket = (MessagePacket) packet; msgPacket.getMessage().putStringProperty("userName", userName); - logger.debug("userName on send = " + userName); + logger.debug("userName on send = {}", userName); } return true; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/CreateQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/CreateQueueTest.java index e4d30b4706..5b08062ce4 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/CreateQueueTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/CreateQueueTest.java @@ -67,7 +67,7 @@ public class CreateQueueTest extends JMSTestBase { String queueName = queue.getQueueName(); - logger.debug("queue name is " + queueName); + logger.debug("queue name is {}", queueName); // assertFalse(queueName.startsWith(ActiveMQDestination.JMS_QUEUE_ADDRESS_PREFIX)); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverListenerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverListenerTest.java index 2b0250c105..b2d8eff0c7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverListenerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/JMSFailoverListenerTest.java @@ -152,7 +152,7 @@ public class JMSFailoverListenerTest extends ActiveMQTestBase { Wait.assertTrue(() -> FailoverEventType.FAILURE_DETECTED == listener.get(0)); for (int i = 0; i < numMessages; i++) { - logger.debug("got message " + i); + logger.debug("got message {}", i); BytesMessage bm = (BytesMessage) consumer.receive(1000); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/MultipleThreadsOpeningTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/MultipleThreadsOpeningTest.java index 0c5b3c9f9f..a5cbb10ddc 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/MultipleThreadsOpeningTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/cluster/MultipleThreadsOpeningTest.java @@ -44,7 +44,7 @@ public class MultipleThreadsOpeningTest extends JMSClusteredTestBase { final int ITERATIONS = 50; for (int i = 0; i < ITERATIONS; i++) { - logger.info("#test " + i); + logger.info("#test {}", i); internalMultipleOpen(200, 1); tearDown(); setUp(); @@ -80,7 +80,7 @@ public class MultipleThreadsOpeningTest extends JMSClusteredTestBase { for (int i = 0; i < numberOfOpens; i++) { if (i > 0 && i % 100 == 0) - logger.debug("connections created on Thread " + Thread.currentThread() + " " + i); + logger.debug("connections created on Thread {} {}", Thread.currentThread(), i); Connection conn = cf1.createConnection(); Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE); sess.close(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/JmsConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/JmsConsumerTest.java index 040033baea..db588831cf 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/JmsConsumerTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/consumer/JmsConsumerTest.java @@ -115,9 +115,9 @@ public class JmsConsumerTest extends JMSTestBase { TextMessage m3 = (TextMessage) cons.receive(2000); Assert.assertNull("m3 should be null", m3); - logger.debug("received m1: " + m1.getText()); - logger.debug("received m2: " + m2.getText()); - logger.debug("received m3: " + m3); + logger.debug("received m1: {}", m1.getText()); + logger.debug("received m2: {}", m2.getText()); + logger.debug("received m3: {}", m3); sess.commit(); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java index 295d1a6c5d..4c1d4a07a7 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/largemessage/JMSLargeMessageTest.java @@ -172,7 +172,7 @@ public class JMSLargeMessageTest extends JMSTestBase { rm.setObjectProperty("JMS_AMQ_OutputStream", new OutputStream() { @Override public void write(final int b) throws IOException { - logger.debug("b = " + b); + logger.debug("b = {}", b); } }); @@ -227,7 +227,7 @@ public class JMSLargeMessageTest extends JMSTestBase { public void write(final int b) throws IOException { numberOfBytes.incrementAndGet(); if (ActiveMQTestBase.getSamplebyte(position++) != b) { - logger.warn("Wrong byte at position " + position); + logger.warn("Wrong byte at position {}", position); numberOfErrors.incrementAndGet(); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java index 963b9cae20..09ce53f614 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/JMSServerStartStopTest.java @@ -74,7 +74,7 @@ public class JMSServerStartStopTest extends ActiveMQTestBase { final int numMessages = 5; for (int j = 0; j < numMessages; j++) { - logger.debug("Iteration " + j); + logger.debug("Iteration {}", j); server.start(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java index f93f83feda..6b831b91ea 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementHelperTest.java @@ -182,14 +182,14 @@ public class ManagementHelperTest extends Assert { String[] val1 = new String[]{"a", "b", "c"}; if (log.isDebugEnabled()) { - log.debug("val1 type is " + Arrays.toString(val1)); + log.debug("val1 type is {}", Arrays.toString(val1)); } String key2 = RandomUtil.randomString(); Long[] val2 = new Long[]{1L, 2L, 3L, 4L, 5L}; if (log.isDebugEnabled()) { - log.debug("val2 type is " + Arrays.toString(val2)); + log.debug("val2 type is {}", Arrays.toString(val2)); } map.put(key1, val1); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/MQTTTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/MQTTTest.java index e191d468be..128317e580 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/MQTTTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/mqtt/MQTTTest.java @@ -808,7 +808,7 @@ public class MQTTTest extends MQTTTestSupport { mqtt.setTracer(new Tracer() { @Override public void onReceive(MQTTFrame frame) { - log.debug("Client received:\n" + frame); + log.debug("Client received:\n{}", frame); if (frame.messageType() == PUBLISH.TYPE) { PUBLISH publish = new PUBLISH(); try { @@ -822,7 +822,7 @@ public class MQTTTest extends MQTTTestSupport { @Override public void onSend(MQTTFrame frame) { - log.debug("Client sent:\n" + frame); + log.debug("Client sent:\n{}", frame); } }); @@ -894,7 +894,7 @@ public class MQTTTest extends MQTTTestSupport { mqtt.setTracer(new Tracer() { @Override public void onReceive(MQTTFrame frame) { - log.debug("Client received:\n" + frame); + log.debug("Client received:\n{}", frame); if (frame.messageType() == PUBLISH.TYPE) { PUBLISH publish = new PUBLISH(); try { @@ -908,7 +908,7 @@ public class MQTTTest extends MQTTTestSupport { @Override public void onSend(MQTTFrame frame) { - log.debug("Client sent:\n" + frame); + log.debug("Client sent:\n{}", frame); } }); @@ -951,12 +951,12 @@ public class MQTTTest extends MQTTTestSupport { mqtt.setTracer(new Tracer() { @Override public void onReceive(MQTTFrame frame) { - log.debug("Client received:\n" + frame); + log.debug("Client received:\n{}", frame); if (frame.messageType() == PUBLISH.TYPE) { PUBLISH publish = new PUBLISH(); try { publish.decode(frame); - log.debug("PUBLISH " + publish); + log.debug("PUBLISH {}", publish); } catch (ProtocolException e) { fail("Error decoding publish " + e.getMessage()); } @@ -969,7 +969,7 @@ public class MQTTTest extends MQTTTestSupport { @Override public void onSend(MQTTFrame frame) { - log.debug("Client sent:\n" + frame); + log.debug("Client sent:\n{}", frame); } }); @@ -1031,12 +1031,12 @@ public class MQTTTest extends MQTTTestSupport { mqtts[i].setTracer(new Tracer() { @Override public void onReceive(MQTTFrame frame) { - log.debug("Client received:\n" + frame); + log.debug("Client received:\n{}", frame); if (frame.messageType() == PUBLISH.TYPE) { PUBLISH publish = new PUBLISH(); try { publish.decode(frame); - log.debug("PUBLISH " + publish); + log.debug("PUBLISH {}", publish); } catch (ProtocolException e) { fail("Error decoding publish " + e.getMessage()); } @@ -1049,7 +1049,7 @@ public class MQTTTest extends MQTTTestSupport { @Override public void onSend(MQTTFrame frame) { - log.debug("Client sent:\n" + frame); + log.debug("Client sent:\n{}", frame); } }); } @@ -1546,7 +1546,7 @@ public class MQTTTest extends MQTTTestSupport { received++; payload = message.getPayload(); String messageContent = new String(payload); - log.debug("Received message from topic: " + message.getTopic() + " Message content: " + messageContent); + log.debug("Received message from topic: {} Message content: {}", message.getTopic(), messageContent); message.ack(); } @@ -1692,7 +1692,7 @@ public class MQTTTest extends MQTTTestSupport { for (int i = 0; i < 5; ++i) { Message message = connectionSub.receive(5, TimeUnit.SECONDS); assertNotNull("Missing message " + i, message); - log.debug("Message is " + new String(message.getPayload())); + log.debug("Message is {}", new String(message.getPayload())); received++; message.ack(); } @@ -1741,7 +1741,7 @@ public class MQTTTest extends MQTTTestSupport { // @Override // public void onReceive(MQTTFrame frame) { // if (frame.messageType() == PUBLISH.TYPE) { - // log.debug("Received message with retain=" + frame.retain()); + // log.debug("Received message with retain={}", frame.retain()); // if (frame.retain()) { // retain[0]++; // } else { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/FQQNOpenWireTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/FQQNOpenWireTest.java index e45debcd8d..c5790f03dd 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/FQQNOpenWireTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/FQQNOpenWireTest.java @@ -112,7 +112,7 @@ public class FQQNOpenWireTest extends OpenWireTestBase { Bindings bindings = server.getPostOffice().getBindingsForAddress(multicastAddress); for (Binding b : bindings.getBindings()) { - logger.debug("checking binidng " + b.getUniqueName() + " " + ((LocalQueueBinding)b).getQueue().getDeliveringMessages()); + logger.debug("checking binidng {} {}", b.getUniqueName(), ((LocalQueueBinding)b).getQueue().getDeliveringMessages()); SimpleString qName = b.getUniqueName(); //do FQQN query QueueQueryResult result = server.queueQuery(CompositeAddress.toFullyQualified(multicastAddress, qName)); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveTest.java index 9e76a84d47..6a8c2f6520 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/openwire/amq/JmsTopicSendReceiveTest.java @@ -55,8 +55,6 @@ public class JmsTopicSendReceiveTest extends JmsSendReceiveTestSupport { consumer = createConsumer(); consumer.setMessageListener(this); connection.start(); - - // log.debug("Created connection: " + connection); } protected String getConsumerSubject() { diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MaxMessagesPagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MaxMessagesPagingTest.java index 322c51b72b..b2dd4d727e 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MaxMessagesPagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/MaxMessagesPagingTest.java @@ -466,8 +466,7 @@ public class MaxMessagesPagingTest extends ActiveMQTestBase { final int MESSAGES = 1000; - logger.info("\n********************************************************************************\nSending " + protocolSend + ", Receiving " + protocolReceive + - "\n********************************************************************************"); + logger.info("\n{}\nSending {}, Receiving {}\n{}", "*".repeat(80), protocolSend, protocolReceive, "*".repeat(80)); final String ADDRESS = "FAIL_MAX_MESSAGES_" + protocolSend + "_" + protocolReceive; @@ -575,8 +574,7 @@ public class MaxMessagesPagingTest extends ActiveMQTestBase { final int MESSAGES = 20; - logger.info("\n********************************************************************************\nSending " + protocolSend + ", Receiving " + protocolReceive + - "\n********************************************************************************"); + logger.info("\n{}\nSending {}, Receiving {}\n", "*".repeat(80), protocolSend, protocolReceive, "*".repeat(80)); final String ADDRESS = "FAIL_MAX_MESSAGES_" + protocolSend + "_" + protocolReceive; diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java index f8820f965d..0f55504fe1 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java @@ -2198,7 +2198,7 @@ public class PagingTest extends ActiveMQTestBase { if (!deletedQueueReferences.isEmpty()) { for (Long value : deletedQueueReferences) { - log.warn("Deleted Queue still has a reference:" + value); + log.warn("Deleted Queue still has a reference:{}", value); } fail("Deleted queue still have references"); @@ -2562,7 +2562,7 @@ public class PagingTest extends ActiveMQTestBase { sessionConsumer.start(); ClientConsumer consumer = sessionConsumer.createConsumer(PagingTest.ADDRESS); for (int msgCount = 0; msgCount < numberOfMessages; msgCount++) { - log.debug("Received " + msgCount); + log.debug("Received {}", msgCount); msgReceived++; ClientMessage msg = consumer.receiveImmediate(); if (msg == null) { @@ -3474,7 +3474,7 @@ public class PagingTest extends ActiveMQTestBase { if (i % 100 == 0) { if (i % 5000 == 0) { - log.debug(addressToSubscribe + " consumed " + i + " messages"); + log.debug("{} consumed {} messages", addressToSubscribe, i); } session.commit(); } @@ -3482,8 +3482,10 @@ public class PagingTest extends ActiveMQTestBase { try { assertBodiesEqual(body, message2.getBodyBuffer()); } catch (AssertionError e) { - PagingTest.log.debug("Expected buffer:" + ActiveMQTestBase.dumpBytesHex(body, 40)); - PagingTest.log.debug("Arriving buffer:" + ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); + if (log.isDebugEnabled()) { + log.debug("Expected buffer:{}", ActiveMQTestBase.dumpBytesHex(body, 40)); + log.debug("Arriving buffer:{}", ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); + } throw e; } } @@ -3642,8 +3644,10 @@ public class PagingTest extends ActiveMQTestBase { try { assertBodiesEqual(body, message2.getBodyBuffer()); } catch (AssertionError e) { - log.debug("Expected buffer: {}", ActiveMQTestBase.dumpBytesHex(body, 40)); - log.debug("Arriving buffer: {}", ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); + if (log.isDebugEnabled()) { + log.debug("Expected buffer: {}", ActiveMQTestBase.dumpBytesHex(body, 40)); + log.debug("Arriving buffer: {}", ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); + } throw e; } } @@ -3768,8 +3772,10 @@ public class PagingTest extends ActiveMQTestBase { try { assertBodiesEqual(body, message2.getBodyBuffer()); } catch (AssertionError e) { - PagingTest.log.debug("Expected buffer:" + ActiveMQTestBase.dumpBytesHex(body, 40)); - PagingTest.log.debug("Arriving buffer:" + ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); + if (log.isDebugEnabled()) { + log.debug("Expected buffer:{}", ActiveMQTestBase.dumpBytesHex(body, 40)); + log.debug("Arriving buffer:{}", ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); + } throw e; } } @@ -4385,8 +4391,10 @@ public class PagingTest extends ActiveMQTestBase { try { assertBodiesEqual(body, message2.getBodyBuffer()); } catch (AssertionError e) { - log.debug("Expected buffer:" + ActiveMQTestBase.dumpBytesHex(body, 40)); - log.debug("Arriving buffer:" + ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); + if (log.isDebugEnabled()) { + log.debug("Expected buffer: {}", ActiveMQTestBase.dumpBytesHex(body, 40)); + log.debug("Arriving buffer: {}", ActiveMQTestBase.dumpBytesHex(message2.getBodyBuffer().toByteBuffer().array(), 40)); + } throw e; } } @@ -6013,12 +6021,16 @@ public class PagingTest extends ActiveMQTestBase { try { if (!message.waitOutputStreamCompletion(10000)) { - log.debug(threadDump("dump")); + if (log.isDebugEnabled()) { + log.debug(threadDump("dump")); + } fail("Couldn't finish large message receiving"); } } catch (Throwable e) { - log.debug("output bytes = {}", bytesOutput); - log.debug(threadDump("dump")); + if (log.isDebugEnabled()) { + log.debug("output bytes = {}", bytesOutput); + log.debug(threadDump("dump")); + } fail("Couldn't finish large message receiving for id=" + message.getStringProperty("id") + " with messageID=" + message.getMessageID()); } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java index 00d8798dc5..a30e32e58c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingWithFailoverAndCountersTest.java @@ -211,10 +211,10 @@ public class PagingWithFailoverAndCountersTest extends ActiveMQTestBase { } if (msgcount % 100 == 0) { - logger.debug("received " + msgcount + " on " + queueName); + logger.debug("received {} on {}", msgcount, queueName); } } catch (Throwable e) { - logger.warn("=====> expected Error at " + currentMsg + " with lastCommit=" + lastCommit); + logger.warn("=====> expected Error at {} with lastCommit={}", currentMsg, lastCommit); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java index 2513bca266..a37b690d4d 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/LVQTest.java @@ -187,7 +187,7 @@ public class LVQTest extends ActiveMQTestBase { producer.send(m1); clientSessionTxReceives.start(); for (int i = 0; i < 10; i++) { - logger.debug("#Deliver " + i); + logger.debug("#Deliver {}", i); ClientMessage m = consumer.receive(5000); Assert.assertNotNull(m); m.acknowledge(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownRemoveSFTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownRemoveSFTest.java index a194624e00..d9c7223149 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownRemoveSFTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ScaleDownRemoveSFTest.java @@ -107,7 +107,7 @@ public class ScaleDownRemoveSFTest extends ClusterTestBase { ClusterConnectionImpl clusterconn1 = (ClusterConnectionImpl) servers[1].getClusterManager().getClusterConnection("cluster0"); SimpleString sfQueueName = clusterconn1.getSfQueueName(servers[0].getNodeID().toString()); - logger.debug("[sf queue on server 1]: " + sfQueueName); + logger.debug("[sf queue on server 1]: {}", sfQueueName); Assert.assertTrue(servers[1].queueQuery(sfQueueName).isExists()); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/FQQNStompTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/FQQNStompTest.java index cae2b88aec..3c08eae648 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/FQQNStompTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/FQQNStompTest.java @@ -88,7 +88,7 @@ public class FQQNStompTest extends StompTestBase { ClientStompFrame frame = conn.receiveFrame(2000); assertNotNull(frame); assertEquals("Hello World!", frame.getBody()); - logger.debug("frame: " + frame); + logger.debug("frame: {}", frame); unsubscribe(conn, "sub-01"); } @@ -189,7 +189,7 @@ public class FQQNStompTest extends StompTestBase { ClientStompFrame frame = conn.receiveFrame(2000); assertNotNull(frame); assertEquals("Hello World!", frame.getBody()); - logger.debug("frame: " + frame); + logger.debug("frame: {}", frame); unsubscribe(conn, "sub-01"); //queue:: diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java index b10b86249d..738d3fa219 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompTest.java @@ -107,7 +107,7 @@ public class StompTest extends StompTestBase { public void tearDown() throws Exception { try { boolean connected = conn != null && conn.isConnected(); - log.debug("Connection 1.0 connected: " + connected); + log.debug("Connection 1.0 connected: {}", connected); if (connected) { try { conn.disconnect(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWithLargeMessagesTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWithLargeMessagesTest.java index 4b05d50c8a..3740447518 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWithLargeMessagesTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/StompWithLargeMessagesTest.java @@ -387,7 +387,7 @@ public class StompWithLargeMessagesTest extends StompTestBase { // this.sendJmsMessage(msg); // } // -// IntegrationTestLogger.LOGGER.info("Message count for " + getQueueName() + ": " + server.getActiveMQServer().locateQueue(SimpleString.toSimpleString(getQueueName())).getMessageCount()); +// IntegrationTestLogger.LOGGER.info("Message count for {}: {}", getQueueName(), server.getActiveMQServer().locateQueue(SimpleString.toSimpleString(getQueueName())).getMessageCount()); // // StompClientConnection connV12 = StompClientConnectionFactory.createClientConnection("1.2", hostname, port); // connV12.connect(defUser, defPass); @@ -450,7 +450,7 @@ public class StompWithLargeMessagesTest extends StompTestBase { ClientStompFrame frame = conn.receiveFrame(60000); Assert.assertNotNull(frame); logger.debug(frame.toString()); - logger.debug("part of frame: " + frame.getBody().substring(0, 250)); + logger.debug("part of frame: {}", frame.getBody().substring(0, 250)); Assert.assertTrue(frame.getCommand().equals("MESSAGE")); Assert.assertTrue(frame.getHeader("destination").equals(getQueuePrefix() + getQueueName())); int index = frame.getBody().toString().indexOf(leadingPart); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java index 3edf01403d..4754d6eb25 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v11/StompV11Test.java @@ -236,7 +236,7 @@ public class StompV11Test extends StompTestBase { assertEquals(Stomp.Responses.ERROR, reply.getCommand()); - logger.debug("Got error frame " + reply); + logger.debug("Got error frame {}", reply); } @@ -287,7 +287,7 @@ public class StompV11Test extends StompTestBase { ClientStompFrame frame = newConn.receiveFrame(); - logger.debug("received " + frame); + logger.debug("received {}", frame); assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); @@ -301,7 +301,7 @@ public class StompV11Test extends StompTestBase { frame = newConn.receiveFrame(); - logger.debug("received " + frame); + logger.debug("received {}", frame); unsubscribe(newConn, "a-sub"); @@ -321,7 +321,7 @@ public class StompV11Test extends StompTestBase { ClientStompFrame frame = newConn.receiveFrame(); - logger.debug("received " + frame); + logger.debug("received {}", frame); assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); @@ -356,7 +356,7 @@ public class StompV11Test extends StompTestBase { frame = newConn.receiveFrame(); - logger.debug("received " + frame); + logger.debug("received {}", frame); assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); @@ -383,7 +383,7 @@ public class StompV11Test extends StompTestBase { .addHeader(Stomp.Headers.CONTENT_LENGTH, cLen) .addHeader(hKey, hVal); - logger.debug("key: |" + hKey + "| val: |" + hVal + "|"); + logger.debug("key: |{}| val: |{}|", hKey, hVal); frame.setBody(body); @@ -397,7 +397,7 @@ public class StompV11Test extends StompTestBase { frame = newConn.receiveFrame(); - logger.debug("received " + frame); + logger.debug("received {}", frame); assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); @@ -430,7 +430,7 @@ public class StompV11Test extends StompTestBase { String hVal = "is\\ttab"; frame.addHeader(hKey, hVal); - logger.debug("key: |" + hKey + "| val: |" + hVal + "|"); + logger.debug("key: |{}| val: |{}|", hKey, hVal); frame.setBody(body); @@ -438,7 +438,7 @@ public class StompV11Test extends StompTestBase { ClientStompFrame error = conn.receiveFrame(); - logger.debug("received " + error); + logger.debug("received {}", error); String desc = "Should have received an ERROR for undefined escape sequence"; Assert.assertNotNull(desc, error); @@ -583,7 +583,7 @@ public class StompV11Test extends StompTestBase { //now check the frame size int size = conn.getServerPingNumber(); - logger.debug("ping received: " + size); + logger.debug("ping received: {}", size); assertTrue(size > 5); @@ -790,7 +790,7 @@ public class StompV11Test extends StompTestBase { reply = connection.sendFrame(frame); - logger.debug("Reply: " + reply); + logger.debug("Reply: {}", reply); assertEquals(Stomp.Responses.CONNECTED, reply.getCommand()); @@ -987,7 +987,7 @@ public class StompV11Test extends StompTestBase { ClientStompFrame error = conn.receiveFrame(); - logger.debug("Receiver error: " + error); + logger.debug("Receiver error: {}", error); unsubscribe(conn, "sub1"); @@ -1015,7 +1015,7 @@ public class StompV11Test extends StompTestBase { ClientStompFrame error = conn.receiveFrame(); - logger.debug("Receiver error: " + error); + logger.debug("Receiver error: {}", error); unsubscribe(conn, "sub1"); @@ -1067,7 +1067,7 @@ public class StompV11Test extends StompTestBase { ClientStompFrame error = conn.receiveFrame(); - logger.debug("Receiver error: " + error); + logger.debug("Receiver error: {}", error); unsubscribe(conn, "sub1"); @@ -1095,7 +1095,7 @@ public class StompV11Test extends StompTestBase { ClientStompFrame error = conn.receiveFrame(); - logger.debug("Receiver error: " + error); + logger.debug("Receiver error: {}", error); unsubscribe(conn, "sub1"); @@ -1127,7 +1127,7 @@ public class StompV11Test extends StompTestBase { ClientStompFrame error = conn.sendFrame(ackFrame); - logger.debug("Receiver error: " + error); + logger.debug("Receiver error: {}", error); assertEquals(Stomp.Responses.ERROR, error.getCommand()); @@ -1163,7 +1163,7 @@ public class StompV11Test extends StompTestBase { ClientStompFrame error = conn.sendFrame(ackFrame); - logger.debug("Receiver error: " + error); + logger.debug("Receiver error: {}", error); assertEquals(Stomp.Responses.ERROR, error.getCommand()); @@ -1295,7 +1295,7 @@ public class StompV11Test extends StompTestBase { frame = conn.receiveFrame(); assertNotNull(frame); - logger.debug(i + " == received: " + frame); + logger.debug("{} == received: {}", i, frame); //ack on even numbers if (i % 2 == 0) { ack(conn, "sub1", frame); @@ -1313,7 +1313,7 @@ public class StompV11Test extends StompTestBase { for (int i = 0; i < num / 2; i++) { message = (TextMessage) consumer.receive(1000); Assert.assertNotNull(message); - logger.debug("Legal: " + message.getText()); + logger.debug("Legal: {}", message.getText()); } message = (TextMessage) consumer.receive(100); @@ -1337,13 +1337,13 @@ public class StompV11Test extends StompTestBase { // receive message from socket ClientStompFrame frame = conn.receiveFrame(5000); - logger.debug("received frame : " + frame); + logger.debug("received frame : {}", frame); assertEquals("Hello World", frame.getBody()); assertEquals("sub1", frame.getHeader(Stomp.Headers.Message.SUBSCRIPTION)); frame = newConn.receiveFrame(5000); - logger.debug("received 2 frame : " + frame); + logger.debug("received 2 frame : {}", frame); assertEquals("Hello World", frame.getBody()); assertEquals("sub2", frame.getHeader(Stomp.Headers.Message.SUBSCRIPTION)); @@ -1965,7 +1965,7 @@ public class StompV11Test extends StompTestBase { assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); - logger.debug("Message: " + frame); + logger.debug("Message: {}", frame); assertEquals("5", frame.getHeader(Stomp.Headers.CONTENT_LENGTH)); @@ -2242,7 +2242,7 @@ public class StompV11Test extends StompTestBase { ClientStompFrame reply = conn.sendFrame(frame); - logger.debug("Reply: " + reply.toString()); + logger.debug("Reply: {}", reply.toString()); assertEquals("CONNECTED", reply.getCommand()); @@ -2274,7 +2274,7 @@ public class StompV11Test extends StompTestBase { f = conn.sendFrame(subFrame); f = conn.receiveFrame(1000); - logger.debug("Received " + f.toString()); + logger.debug("Received {}", f.toString()); Assert.assertTrue(f.getCommand().equals("ERROR")); conn.stopPinger(); diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v12/StompV12Test.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v12/StompV12Test.java index 8fec2435cf..4a5aa45b58 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v12/StompV12Test.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/stomp/v12/StompV12Test.java @@ -91,7 +91,7 @@ public class StompV12Test extends StompTestBase { public void tearDown() throws Exception { try { boolean connected = conn != null && conn.isConnected(); - log.debug("Connection 1.2 : " + connected); + log.debug("Connection 1.2 : {}", connected); if (connected) { conn.disconnect(); } @@ -266,7 +266,7 @@ public class StompV12Test extends StompTestBase { conn.disconnect(); - log.debug("Got error frame " + reply); + log.debug("Got error frame {}", reply); } @@ -287,7 +287,7 @@ public class StompV12Test extends StompTestBase { ClientStompFrame frame = newConn.receiveFrame(); - log.debug("received " + frame); + log.debug("received {}", frame); Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); @@ -302,7 +302,7 @@ public class StompV12Test extends StompTestBase { frame = newConn.receiveFrame(); - log.debug("received " + frame); + log.debug("received {}", frame); //unsub unsubscribe(newConn, "a-sub"); @@ -323,7 +323,7 @@ public class StompV12Test extends StompTestBase { ClientStompFrame frame = newConn.receiveFrame(); - log.debug("received " + frame); + log.debug("received {}", frame); Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); @@ -421,7 +421,7 @@ public class StompV12Test extends StompTestBase { Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); Assert.assertEquals(body, frame.getBody()); - log.debug("received: " + frame); + log.debug("received: {}", frame); Assert.assertEquals("value1", frame.getHeader("foo")); //unsub @@ -479,7 +479,7 @@ public class StompV12Test extends StompTestBase { Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); Assert.assertEquals(body, frame.getBody()); - log.debug("received: " + frame); + log.debug("received: {}", frame); Assert.assertEquals(null, frame.getHeader("header1")); Assert.assertEquals("value1 ", frame.getHeader(" header1")); Assert.assertEquals("value2 ", frame.getHeader(" header2")); @@ -512,7 +512,7 @@ public class StompV12Test extends StompTestBase { .addHeader(hKey, hVal) .setBody(body); - log.debug("key: |" + hKey + "| val: |" + hVal + "|"); + log.debug("key: |{}| val: |{}|", hKey, hVal); conn.sendFrame(frame); @@ -524,7 +524,7 @@ public class StompV12Test extends StompTestBase { frame = newConn.receiveFrame(); - log.debug("received " + frame); + log.debug("received {}", frame); Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); @@ -556,7 +556,7 @@ public class StompV12Test extends StompTestBase { String hVal = "is\\ttab"; frame.addHeader(hKey, hVal); - log.debug("key: |" + hKey + "| val: |" + hVal + "|"); + log.debug("key: |{}| val: |{}|", hKey, hVal); frame.setBody(body); @@ -564,7 +564,7 @@ public class StompV12Test extends StompTestBase { ClientStompFrame error = conn.receiveFrame(); - log.debug("received " + error); + log.debug("received {}", error); String desc = "Should have received an ERROR for undefined escape sequence"; Assert.assertNotNull(desc, error); @@ -707,7 +707,7 @@ public class StompV12Test extends StompTestBase { //now check the frame size int size = conn.getServerPingNumber(); - log.debug("ping received: " + size); + log.debug("ping received: {}", size); Assert.assertTrue("size: " + size, size > 5); @@ -936,7 +936,7 @@ public class StompV12Test extends StompTestBase { ClientStompFrame error = conn.receiveFrame(); - log.debug("Receiver error: " + error); + log.debug("Receiver error: {}", error); waitDisconnect(conn); Assert.assertFalse("Should be disconnected in STOMP 1.2 after ERROR", conn.isConnected()); @@ -1020,7 +1020,7 @@ public class StompV12Test extends StompTestBase { ClientStompFrame error = conn.receiveFrame(); - log.debug("Receiver error: " + error); + log.debug("Receiver error: {}", error); waitDisconnect(conn); Assert.assertFalse("Should be disconnected in STOMP 1.2 after ERROR", conn.isConnected()); @@ -1051,7 +1051,7 @@ public class StompV12Test extends StompTestBase { ClientStompFrame error = conn.sendFrame(ackFrame); - log.debug("Receiver error: " + error); + log.debug("Receiver error: {}", error); Assert.assertEquals(Stomp.Responses.ERROR, error.getCommand()); @@ -1086,7 +1086,7 @@ public class StompV12Test extends StompTestBase { ClientStompFrame error = conn.sendFrame(ackFrame); - log.debug("Receiver error: " + error); + log.debug("Receiver error: {}", error); Assert.assertEquals(Stomp.Responses.ERROR, error.getCommand()); @@ -1254,7 +1254,7 @@ public class StompV12Test extends StompTestBase { frame = conn.receiveFrame(); Assert.assertNotNull(frame); - log.debug(i + " == received: " + frame); + log.debug("{} == received: {}", i, frame); //ack on even numbers if (i % 2 == 0) { ack(conn, frame); @@ -1272,7 +1272,7 @@ public class StompV12Test extends StompTestBase { for (int i = 0; i < num / 2; i++) { message = (TextMessage) consumer.receive(1000); Assert.assertNotNull(message); - log.debug("Legal: " + message.getText()); + log.debug("Legal: {}", message.getText()); } message = (TextMessage) consumer.receiveNoWait(); @@ -1296,13 +1296,13 @@ public class StompV12Test extends StompTestBase { // receive message from socket ClientStompFrame frame = conn.receiveFrame(1000); - log.debug("received frame : " + frame); + log.debug("received frame : {}", frame); Assert.assertEquals("Hello World", frame.getBody()); Assert.assertEquals("sub1", frame.getHeader(Stomp.Headers.Message.SUBSCRIPTION)); frame = newConn.receiveFrame(1000); - log.debug("received 2 frame : " + frame); + log.debug("received 2 frame : {}", frame); Assert.assertEquals("Hello World", frame.getBody()); Assert.assertEquals("sub2", frame.getHeader(Stomp.Headers.Message.SUBSCRIPTION)); @@ -1705,7 +1705,7 @@ public class StompV12Test extends StompTestBase { TextMessage m = (TextMessage) arg0; latch.countDown(); try { - log.debug("___> latch now: " + latch.getCount() + " m: " + m.getText()); + log.debug("___> latch now: {} m: {}", latch.getCount(), m.getText()); } catch (JMSException e) { Assert.fail("here failed"); e.printStackTrace(); @@ -1996,7 +1996,7 @@ public class StompV12Test extends StompTestBase { Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); - log.debug("Message: " + frame); + log.debug("Message: {}", frame); Assert.assertEquals("5", frame.getHeader(Stomp.Headers.CONTENT_LENGTH)); @@ -2352,7 +2352,7 @@ public class StompV12Test extends StompTestBase { ClientStompFrame frame = conn.receiveFrame(); - log.debug("Received: " + frame); + log.debug("Received: {}", frame); Assert.assertEquals(Stomp.Responses.MESSAGE, frame.getCommand()); Assert.assertEquals("ID:MYMACHINE-50616-635482262727823605-1:1:1:1", frame.getHeader(Stomp.Headers.Message.SUBSCRIPTION)); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AcknowledgementTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AcknowledgementTest.java index 9c396a5842..81167981b7 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AcknowledgementTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AcknowledgementTest.java @@ -258,7 +258,7 @@ public class AcknowledgementTest extends JMSTestCase { assertRemainingMessages(NUM_MESSAGES); - logger.trace("Received " + count + " messages"); + logger.trace("Received {} messages", count); ProxyAssertSupport.assertEquals(count, NUM_MESSAGES); @@ -273,7 +273,7 @@ public class AcknowledgementTest extends JMSTestCase { int i = 0; for (; i < NUM_MESSAGES; i++) { m = consumer.receive(); - logger.trace("Received message " + i); + logger.trace("Received message {}", i); } @@ -281,7 +281,7 @@ public class AcknowledgementTest extends JMSTestCase { // if I don't receive enough messages, the test will timeout - logger.trace("Received " + i + " messages after recover"); + logger.trace("Received {} messages after recover", i); m.acknowledge(); @@ -381,7 +381,7 @@ public class AcknowledgementTest extends JMSTestCase { assertRemainingMessages(0); - logger.trace("Received " + count + " messages"); + logger.trace("Received {} messages", count); ProxyAssertSupport.assertEquals(count, NUM_MESSAGES); @@ -391,7 +391,7 @@ public class AcknowledgementTest extends JMSTestCase { m = consumer.receiveNoWait(); - logger.trace("Message is:" + m); + logger.trace("Message is: {}", m); ProxyAssertSupport.assertNull(m); } @@ -443,7 +443,7 @@ public class AcknowledgementTest extends JMSTestCase { ProxyAssertSupport.assertNotNull(m); - logger.trace("Received " + count + " messages"); + logger.trace("Received {} messages", count); ProxyAssertSupport.assertEquals(count, NUM_MESSAGES); @@ -516,7 +516,7 @@ public class AcknowledgementTest extends JMSTestCase { ProxyAssertSupport.assertNotNull(m); - logger.trace("Received " + count + " messages"); + logger.trace("Received {} messages", count); ProxyAssertSupport.assertEquals(count, NUM_MESSAGES); @@ -526,7 +526,7 @@ public class AcknowledgementTest extends JMSTestCase { m = consumer.receiveNoWait(); - logger.trace("Message is:" + m); + logger.trace("Message is: {}", m); ProxyAssertSupport.assertNull(m); } @@ -570,7 +570,7 @@ public class AcknowledgementTest extends JMSTestCase { ProxyAssertSupport.assertNotNull(m); - logger.trace("Received " + count + " messages"); + logger.trace("Received {} messages", count); ProxyAssertSupport.assertEquals(count, NUM_MESSAGES); @@ -580,7 +580,7 @@ public class AcknowledgementTest extends JMSTestCase { m = consumer.receiveNoWait(); - logger.trace("Message is:" + m); + logger.trace("Message is: {}", m); ProxyAssertSupport.assertNull(m); @@ -676,7 +676,7 @@ public class AcknowledgementTest extends JMSTestCase { assertRemainingMessages(NUM_MESSAGES); - logger.trace("Received " + count + " messages"); + logger.trace("Received {} messages", count); ProxyAssertSupport.assertEquals(count, NUM_MESSAGES); @@ -686,7 +686,7 @@ public class AcknowledgementTest extends JMSTestCase { m = consumer.receiveNoWait(); - logger.trace("Message is:" + m); + logger.trace("Message is: {}", m); ProxyAssertSupport.assertNull(m); @@ -787,7 +787,7 @@ public class AcknowledgementTest extends JMSTestCase { messageReceived = (TextMessage) consumer.receiveNoWait(); if (messageReceived != null) { - logger.debug("Message received " + messageReceived.getText()); + logger.debug("Message received {}", messageReceived.getText()); } Assert.assertNull(messageReceived); @@ -1069,7 +1069,7 @@ public class AcknowledgementTest extends JMSTestCase { if (count == 1) { assertRemainingMessages(3); if (!"a".equals(tm.getText())) { - logger.trace("Expected a but got " + tm.getText()); + logger.trace("Expected a but got {}", tm.getText()); failed = true; latch.countDown(); } @@ -1077,7 +1077,7 @@ public class AcknowledgementTest extends JMSTestCase { if (count == 2) { assertRemainingMessages(3); if (!"b".equals(tm.getText())) { - logger.trace("Expected b but got " + tm.getText()); + logger.trace("Expected b but got {}", tm.getText()); failed = true; latch.countDown(); } @@ -1085,7 +1085,7 @@ public class AcknowledgementTest extends JMSTestCase { if (count == 3) { assertRemainingMessages(3); if (!"c".equals(tm.getText())) { - logger.trace("Expected c but got " + tm.getText()); + logger.trace("Expected c but got {}", tm.getText()); failed = true; latch.countDown(); } @@ -1095,7 +1095,7 @@ public class AcknowledgementTest extends JMSTestCase { if (count == 4) { assertRemainingMessages(3); if (!"a".equals(tm.getText())) { - logger.trace("Expected a but got " + tm.getText()); + logger.trace("Expected a but got {}", tm.getText()); failed = true; latch.countDown(); } @@ -1108,7 +1108,7 @@ public class AcknowledgementTest extends JMSTestCase { if (count == 5) { assertRemainingMessages(2); if (!"b".equals(tm.getText())) { - logger.trace("Expected b but got " + tm.getText()); + logger.trace("Expected b but got {}", tm.getText()); failed = true; latch.countDown(); } @@ -1118,7 +1118,7 @@ public class AcknowledgementTest extends JMSTestCase { if (count == 6) { assertRemainingMessages(2); if (!"b".equals(tm.getText())) { - logger.trace("Expected b but got " + tm.getText()); + logger.trace("Expected b but got {}", tm.getText()); failed = true; latch.countDown(); } @@ -1126,7 +1126,7 @@ public class AcknowledgementTest extends JMSTestCase { if (count == 7) { assertRemainingMessages(2); if (!"c".equals(tm.getText())) { - logger.trace("Expected c but got " + tm.getText()); + logger.trace("Expected c but got {}", tm.getText()); failed = true; latch.countDown(); } @@ -1313,8 +1313,8 @@ public class AcknowledgementTest extends JMSTestCase { long time1 = consume(cf1, queue1, messageCount); long time2 = consume(cf2, queue2, messageCount); - logger.debug("BlockOnAcknowledge=false MessageCount=" + messageCount + " TimeToConsume=" + time1); - logger.debug("BlockOnAcknowledge=true MessageCount=" + messageCount + " TimeToConsume=" + time2); + logger.debug("BlockOnAcknowledge=false MessageCount={} TimeToConsume={}", messageCount, time1); + logger.debug("BlockOnAcknowledge=true MessageCount={} TimeToConsume={}", messageCount, time2); Assert.assertTrue(time1 < (time2 / 2)); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ActiveMQServerTestCase.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ActiveMQServerTestCase.java index 49be1b7fe0..2a65b4135c 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ActiveMQServerTestCase.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/ActiveMQServerTestCase.java @@ -262,7 +262,7 @@ public abstract class ActiveMQServerTestCase { MessageConsumer cons = sess.createConsumer(dest); Message m = null; conn.start(); - logger.trace("Draining messages from " + dest); + logger.trace("Draining messages from {}", dest); while (true) { m = cons.receive(DRAIN_WAIT_TIME); if (m == null) { diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AutoAckMessageListenerTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AutoAckMessageListenerTest.java index e71dee0645..75efe229af 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AutoAckMessageListenerTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/AutoAckMessageListenerTest.java @@ -117,7 +117,7 @@ public class AutoAckMessageListenerTest extends JMSTestCase { } } } catch (JMSException e) { - logger.warn("Exception caught in message listener:\n" + e); + logger.warn("Exception caught in message listener:", e); passed = false; monitor.countDown(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java index 17b80316a1..a0c779fc7f 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/MessageConsumerTest.java @@ -2022,9 +2022,7 @@ public class MessageConsumerTest extends JMSTestCase { // This is a really weird test - the received object is always going to be null since no message is sent!! ActiveMQServerTestCase.forceGC(); // / If A GC need to be executed, it' s better to be executed now - if (logger.isTraceEnabled()) { - logger.trace("testTimeoutReceiveOnClose"); - } + logger.trace("testTimeoutReceiveOnClose"); Object monitor = new Object(); ThreadCloser closer = null; @@ -2299,9 +2297,7 @@ public class MessageConsumerTest extends JMSTestCase { @Test public void testStopConnectionDuringOnMessage() throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("testStopConnectionWhileOnMessageIsExecuting"); - } + logger.trace("testStopConnectionWhileOnMessageIsExecuting"); final AtomicInteger messagesReceived = new AtomicInteger(0); @@ -2544,9 +2540,7 @@ public class MessageConsumerTest extends JMSTestCase { @Test public void testNoLocal() throws Exception { - if (logger.isTraceEnabled()) { - logger.trace("testNoLocal"); - } + logger.trace("testNoLocal"); Connection conn1 = null; Connection conn2 = null; @@ -2835,7 +2829,7 @@ public class MessageConsumerTest extends JMSTestCase { Message m2 = theConsumer.receive(1500); - logger.trace("m2 is " + m2); + logger.trace("m2 is {}", m2); ProxyAssertSupport.assertNotNull(m2); @@ -2963,7 +2957,7 @@ public class MessageConsumerTest extends JMSTestCase { } Assert.assertNull(durable3.receiveNoWait()); - logger.debug("received " + NUM_MESSAGES + " messages"); + logger.debug("received {} messages", NUM_MESSAGES); MessageConsumer durable4 = sess3.createDurableSubscriber(ActiveMQServerTestCase.topic1, "mySubscription1"); @@ -3064,7 +3058,7 @@ public class MessageConsumerTest extends JMSTestCase { MessageProducer prod5 = sess5.createProducer(null); prod5.setDeliveryMode(DeliveryMode.PERSISTENT); - logger.debug("sending.1 " + NUM_MESSAGES + " messages"); + logger.debug("sending.1 {} messages", NUM_MESSAGES); for (int i = 0; i < NUM_MESSAGES; i++) { TextMessage tm2 = sess5.createTextMessage("hello"); prod5.send(ActiveMQServerTestCase.topic1, tm2); @@ -3975,7 +3969,7 @@ public class MessageConsumerTest extends JMSTestCase { @Override public void onMessage(final Message m) { messages.add(m); - logger.trace("Added message " + m + " to my list"); + logger.trace("Added message {} to my list", m); latch.countDown(); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java index 9e60068ed6..84dc4c3099 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/JMSExpirationHeaderTest.java @@ -169,7 +169,7 @@ public class JMSExpirationHeaderTest extends MessageHeaderTestBase { ActiveMQMessage msg = (ActiveMQMessage) m; if (!msg.getCoreMessage().isExpired()) { - logger.error("The message " + m + " should have expired"); + logger.error("The message {} should have expired", m); testFailed = true; return; } @@ -190,7 +190,7 @@ public class JMSExpirationHeaderTest extends MessageHeaderTestBase { ProxyAssertSupport.fail("Test failed by the sender thread. Watch for exception in logs"); } - logger.trace("planned waiting time: " + timeToWaitForReceive + " effective waiting time " + effectiveReceiveTime); + logger.trace("planned waiting time: {} effective waiting time {}", timeToWaitForReceive, effectiveReceiveTime); ProxyAssertSupport.assertTrue(effectiveReceiveTime >= timeToWaitForReceive); ProxyAssertSupport.assertTrue(effectiveReceiveTime < timeToWaitForReceive * 1.5); // well, how exactly I did come // up with this coeficient is @@ -232,7 +232,7 @@ public class JMSExpirationHeaderTest extends MessageHeaderTestBase { expectedMessage = queueConsumer.receive(); // NOTE on close, the receive() call will return with null - logger.trace("Receive exited without exception:" + expectedMessage); + logger.trace("Receive exited without exception:{}", expectedMessage); if (expectedMessage == null) { received.set(false); @@ -258,7 +258,7 @@ public class JMSExpirationHeaderTest extends MessageHeaderTestBase { // wait for the reading thread to conclude ActiveMQTestBase.waitForLatch(latch); - logger.trace("Expected message:" + expectedMessage); + logger.trace("Expected message:{}", expectedMessage); ProxyAssertSupport.assertFalse(received.get()); } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageBodyTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageBodyTest.java index 02ba6e9ff1..57addae368 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageBodyTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageBodyTest.java @@ -65,7 +65,7 @@ public class MessageBodyTest extends MessageBodyTestCase { float myFloat = Float.MAX_VALUE - 23465; double myDouble = Double.MAX_VALUE - 72387633; String myString = "abcdef&^*&!^ghijkl\uD5E2\uCAC7\uD2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5"; - logger.trace("String is length:" + myString.length()); + logger.trace("String is length:{}", myString.length()); char myChar = 'q'; byte[] myBytes = new byte[]{-23, 114, -126, -12, 74, 87}; diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTest.java index b4ca0283c2..4b04c10be8 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/MessageHeaderTest.java @@ -612,7 +612,7 @@ public class MessageHeaderTest extends MessageHeaderTestBase { logger.trace("Sent message"); Message m2 = queueConsumer.receive(3000); - logger.trace("The message is " + m2); + logger.trace("The message is {}", m2); ProxyAssertSupport.assertNotNull(m2); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignBytesMessageTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignBytesMessageTest.java index 45f3591bc3..76ab724c8b 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignBytesMessageTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignBytesMessageTest.java @@ -37,7 +37,7 @@ public class ForeignBytesMessageTest extends ForeignMessageTest { protected Message createForeignMessage() throws Exception { SimpleJMSBytesMessage m = new SimpleJMSBytesMessage(); - logger.debug("creating JMS Message type " + m.getClass().getName()); + logger.debug("creating JMS Message type {}", m.getClass().getName()); String bytes = "ActiveMQ"; m.writeBytes(bytes.getBytes()); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignMapMessageTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignMapMessageTest.java index 447af21511..53626a9dd8 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignMapMessageTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignMapMessageTest.java @@ -39,7 +39,7 @@ public class ForeignMapMessageTest extends ForeignMessageTest { protected Message createForeignMessage() throws Exception { SimpleJMSMapMessage m = new SimpleJMSMapMessage(); - logger.debug("creating JMS Message type " + m.getClass().getName()); + logger.debug("creating JMS Message type {}", m.getClass().getName()); m.setBoolean("boolean1", true); m.setChar("char1", 'c'); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignMessageTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignMessageTest.java index 5d02e64037..86bee14a96 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignMessageTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignMessageTest.java @@ -55,7 +55,7 @@ public class ForeignMessageTest extends MessageTestBase { protected Message createForeignMessage() throws Exception { SimpleJMSMessage m = new SimpleJMSMessage(); - logger.debug("creating JMS Message type " + m.getClass().getName()); + logger.debug("creating JMS Message type {}", m.getClass().getName()); return m; } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignObjectMessageTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignObjectMessageTest.java index 74ee0abcc8..635d03a226 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignObjectMessageTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignObjectMessageTest.java @@ -56,7 +56,7 @@ public class ForeignObjectMessageTest extends ForeignMessageTest { protected Message createForeignMessage() throws Exception { SimpleJMSObjectMessage m = new SimpleJMSObjectMessage(); - logger.debug("creating JMS Message type " + m.getClass().getName()); + logger.debug("creating JMS Message type {}", m.getClass().getName()); m.setObject(testObj); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignStreamMessageTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignStreamMessageTest.java index 16f34210ad..2fdec30edd 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignStreamMessageTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/message/foreign/ForeignStreamMessageTest.java @@ -37,7 +37,7 @@ public class ForeignStreamMessageTest extends ForeignMessageTest { protected Message createForeignMessage() throws Exception { SimpleJMSStreamMessage m = new SimpleJMSStreamMessage(); - logger.debug("creating JMS Message type " + m.getClass().getName()); + logger.debug("creating JMS Message type {}", m.getClass().getName()); m.writeBoolean(true); m.writeBytes("jboss".getBytes()); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java index 95717491d1..862be3ff45 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/selector/SelectorTest.java @@ -196,7 +196,7 @@ public class SelectorTest extends ActiveMQServerTestCase { ProxyAssertSupport.assertEquals("john", m.getStringProperty("beatle")); - logger.debug("Got message " + j); + logger.debug("Got message {}", j); } Message m = cons1.receiveNoWait(); @@ -907,38 +907,38 @@ public class SelectorTest extends ActiveMQServerTestCase { tm.setText("1"); tm.setStringProperty("PROP1", "VALUE1"); msgProducer.send(tm); - logger.debug("Sent message with id [" + tm.getJMSMessageID() + "]"); + logger.debug("Sent message with id [{}]", tm.getJMSMessageID()); tm = session.createTextMessage(); tm.setText("2"); tm.setStringProperty("PROP1", "VALUE1"); msgProducer.send(tm); - logger.debug("Sent message with id [" + tm.getJMSMessageID() + "]"); + logger.debug("Sent message with id [{}]", tm.getJMSMessageID()); tm = session.createTextMessage(); tm.setText("3"); tm.setStringProperty("PROP2", "VALUE2"); msgProducer.send(tm); - logger.debug("Sent message with id [" + tm.getJMSMessageID() + "]"); + logger.debug("Sent message with id [{}]", tm.getJMSMessageID()); tm = session.createTextMessage(); tm.setText("4"); tm.setStringProperty("PROP2", "VALUE2"); msgProducer.send(tm); - logger.debug("Sent message with id [" + tm.getJMSMessageID() + "]"); + logger.debug("Sent message with id [{}]", tm.getJMSMessageID()); tm = session.createTextMessage(); tm.setText("5"); tm.setStringProperty("PROP1", "VALUE1"); msgProducer.send(tm); - logger.debug("Sent message with id [" + tm.getJMSMessageID() + "]"); + logger.debug("Sent message with id [{}]", tm.getJMSMessageID()); tm = session.createTextMessage(); tm.setText("6"); tm.setStringProperty("PROP1", "VALUE1"); tm.setStringProperty("PROP2", "VALUE2"); msgProducer.send(tm); - logger.debug("Sent message with id [" + tm.getJMSMessageID() + "]"); + logger.debug("Sent message with id [{}]", tm.getJMSMessageID()); msgProducer.close(); msgProducer = null; diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/ServerManagement.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/ServerManagement.java index 4cb804c2a4..6fba8aa992 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/ServerManagement.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/ServerManagement.java @@ -90,11 +90,10 @@ public class ServerManagement { } if (i > ServerManagement.servers.size()) { - logger.error("server " + i + - " has not been created or has already been killed, so it cannot be killed"); + logger.error("server {} has not been created or has already been killed, so it cannot be killed", i); } else { Server server = ServerManagement.servers.get(i); - logger.debug("invoking kill() on server " + i); + logger.debug("invoking kill() on server {}", i); try { server.kill(); } catch (Throwable t) { @@ -106,7 +105,7 @@ public class ServerManagement { try { while (true) { server.ping(); - logger.debug("server " + i + " still alive ..."); + logger.debug("server {} still alive ...", i); Thread.sleep(100); } } catch (Throwable e) { @@ -115,7 +114,7 @@ public class ServerManagement { Thread.sleep(300); - logger.debug("server " + i + " killed and dead"); + logger.debug("server {} killed and dead", i); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMContext.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMContext.java index c3f17aa9e9..ac75283606 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMContext.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMContext.java @@ -286,7 +286,7 @@ public class InVMContext implements Context, Serializable { } private void internalBind(String name, final Object obj, final boolean rebind) throws NamingException { - InVMContext.logger.debug("Binding " + name + " obj " + obj + " rebind " + rebind); + InVMContext.logger.debug("Binding {} obj {} rebind {}", name, obj, rebind); name = trimSlashes(name); int i = name.lastIndexOf("/"); InVMContext c = this; diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactoryBuilder.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactoryBuilder.java index 5f60ba8d27..6ef9d657ec 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactoryBuilder.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/InVMInitialContextFactoryBuilder.java @@ -29,9 +29,6 @@ public class InVMInitialContextFactoryBuilder implements InitialContextFactoryBu private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - - public InVMInitialContextFactoryBuilder() { } @@ -49,17 +46,17 @@ public class InVMInitialContextFactoryBuilder implements InitialContextFactoryBu try { c = Class.forName(icfName); } catch (ClassNotFoundException e) { - logger.error("\"" + icfName + "\" cannot be loaded", e); + logger.error("\"{}\" cannot be loaded", icfName, e); throw new NamingException("\"" + icfName + "\" cannot be loaded"); } try { icf = (InitialContextFactory) c.newInstance(); } catch (InstantiationException e) { - logger.error(c.getName() + " cannot be instantiated", e); + logger.error("{} cannot be instantiated", c.getName(), e); throw new NamingException(c.getName() + " cannot be instantiated"); } catch (IllegalAccessException e) { - logger.error(c.getName() + " instantiation generated an IllegalAccessException", e); + logger.error("{} instantiation generated an IllegalAccessException", c.getName(), e); throw new NamingException(c.getName() + " instantiation generated an IllegalAccessException"); } } diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/LocalTestServer.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/LocalTestServer.java index 6cae9e8037..52986b413d 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/LocalTestServer.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/tools/container/LocalTestServer.java @@ -102,7 +102,7 @@ public class LocalTestServer implements Server, Runnable { boolean deleted = LocalTestServer.deleteDirectory(dir); - logger.info("Deleted dir: " + dir.getAbsolutePath() + " deleted: " + deleted); + logger.info("Deleted dir: {} deleted: {}", dir.getAbsolutePath(), deleted); } javax.management.MBeanServer beanServer = java.lang.management.ManagementFactory.getPlatformMBeanServer(); diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/ProxyAssertSupport.java b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/ProxyAssertSupport.java index 134669d4e5..b2bfff157c 100644 --- a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/ProxyAssertSupport.java +++ b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/util/ProxyAssertSupport.java @@ -32,7 +32,7 @@ public class ProxyAssertSupport { try { Assert.assertTrue(string, b); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -41,7 +41,7 @@ public class ProxyAssertSupport { try { Assert.assertTrue(b); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -50,7 +50,7 @@ public class ProxyAssertSupport { try { Assert.assertFalse(string, b); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -59,7 +59,7 @@ public class ProxyAssertSupport { try { Assert.assertFalse(b); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -68,7 +68,7 @@ public class ProxyAssertSupport { try { Assert.fail(string); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -77,7 +77,7 @@ public class ProxyAssertSupport { try { Assert.fail(); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -88,7 +88,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(string, object, object1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -97,7 +97,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(object, object1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -108,7 +108,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(string, string1, string2); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -117,7 +117,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(string, string1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -126,7 +126,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(string, v, v1, v2); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -135,7 +135,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(v, v1, v2); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -144,7 +144,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(string, v, v1, v2); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -153,7 +153,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(v, v1, v2); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -162,7 +162,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(string, l, l1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -171,7 +171,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(l, l1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -180,7 +180,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(string, b, b1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -189,7 +189,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(b, b1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -198,7 +198,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(string, b, b1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -207,7 +207,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(b, b1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -216,7 +216,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(string, c, c1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -225,7 +225,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(c, c1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -234,7 +234,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(string, i, i1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -243,7 +243,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(i, i1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -252,7 +252,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(string, i, i1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -261,7 +261,7 @@ public class ProxyAssertSupport { try { Assert.assertEquals(i, i1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -270,7 +270,7 @@ public class ProxyAssertSupport { try { Assert.assertNotNull(object); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -279,7 +279,7 @@ public class ProxyAssertSupport { try { Assert.assertNotNull(string, object); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -288,7 +288,7 @@ public class ProxyAssertSupport { try { Assert.assertNull(object); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -297,7 +297,7 @@ public class ProxyAssertSupport { try { Assert.assertNull(string, object); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -308,7 +308,7 @@ public class ProxyAssertSupport { try { Assert.assertSame(string, object, object1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -317,7 +317,7 @@ public class ProxyAssertSupport { try { Assert.assertSame(object, object1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -328,7 +328,7 @@ public class ProxyAssertSupport { try { Assert.assertNotSame(string, object, object1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } @@ -337,7 +337,7 @@ public class ProxyAssertSupport { try { Assert.assertNotSame(object, object1); } catch (AssertionError e) { - logger.warn("AssertionFailure::" + e.toString(), e); + logger.warn("AssertionFailure::", e); throw e; } } diff --git a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContext.java b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContext.java index f28679f899..c96d63c1ec 100644 --- a/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContext.java +++ b/tests/joram-tests/src/test/java/org/apache/activemq/artemis/common/testjndi/TestContext.java @@ -107,7 +107,7 @@ public class TestContext implements Context, Serializable { try { internalBind(binding.getKey(), binding.getValue()); } catch (Throwable e) { - logger.error("Failed to bind " + binding.getKey() + "=" + binding.getValue(), e); + logger.error("Failed to bind {}={}", binding.getKey(), binding.getValue(), e); } } } diff --git a/tests/karaf-server-integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java b/tests/karaf-server-integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java index e67a82888e..cf423eaf18 100644 --- a/tests/karaf-server-integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java +++ b/tests/karaf-server-integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/karaf/ArtemisFeatureTest.java @@ -130,7 +130,7 @@ public class ArtemisFeatureTest extends Assert { String type = "xml/features"; UrlReference urlReference = mavenBundle().groupId("org.apache.activemq"). artifactId("artemis-features").versionAsInProject().type(type); - log.debug("FeatureURL: " + urlReference.getURL()); + log.debug("FeatureURL: {}", urlReference.getURL()); return urlReference; } @@ -148,7 +148,7 @@ public class ArtemisFeatureTest extends Assert { Object service = waitForService("(objectClass=org.apache.activemq.artemis.core.server.ActiveMQServer)", 30000); assertNotNull(service); - log.debug("have service " + service); + log.debug("have service {}", service); executeCommand("service:list -n"); @@ -237,7 +237,7 @@ public class ArtemisFeatureTest extends Assert { e.printStackTrace(System.err); response = "SHELL COMMAND TIMED OUT: "; } - log.debug("Execute: " + command + " - Response:" + response); + log.debug("Execute: {} - Response:{}", command, response); return response; } @@ -264,7 +264,7 @@ public class ArtemisFeatureTest extends Assert { public boolean verifyBundleInstalled(final String bundleName) throws Exception { boolean found = false; for (Bundle bundle : bundleContext.getBundles()) { - log.debug("Checking: " + bundle.getSymbolicName()); + log.debug("Checking: {}", bundle.getSymbolicName()); if (bundle.getSymbolicName().contains(bundleName)) { found = true; break; diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/dnsswitch/DNSSwitchTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/dnsswitch/DNSSwitchTest.java index 080a1ebe26..04f2cae66c 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/dnsswitch/DNSSwitchTest.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/dnsswitch/DNSSwitchTest.java @@ -1047,7 +1047,7 @@ public class DNSSwitchTest extends SmokeTestBase { String configLocation = "-Dartemis.config.location=" + location; String temporaryLocation = "-Djava.io.tmpdir=" + System.getProperty("java.io.tmpdir"); - logger.info("if you would like to run without Spawn for debugging purposes, add these properties to your VM arguments on this test: " + securityProperties + " " + hostProperties); + logger.info("if you would like to run without Spawn for debugging purposes, add these properties to your VM arguments on this test: {} {}", securityProperties, hostProperties); Process p = SpawnedVMSupport.spawnVM(DNSSwitchTest.class.getName(), new String[]{securityProperties, hostProperties, configLocation, temporaryLocation}, args); addProcess(p); Assert.assertEquals(1, p.waitFor()); diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/quorum/PluggableQuorumSinglePairTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/quorum/PluggableQuorumSinglePairTest.java index 0de7005a6e..636da6338e 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/quorum/PluggableQuorumSinglePairTest.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/quorum/PluggableQuorumSinglePairTest.java @@ -389,7 +389,7 @@ public abstract class PluggableQuorumSinglePairTest extends SmokeTestBase { logger.info("restarting primary"); Process restartedPrimary = primary.startServer(this, 0); - logger.info("restarted primary, " + restartedPrimary); + logger.info("restarted primary, {}", restartedPrimary); Wait.assertFalse("Primary shouldn't activate", () -> primary.isActive().orElse(false), 5000); diff --git a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/MultipleConsumersPageStressTest.java b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/MultipleConsumersPageStressTest.java index b3492e3f37..eefd325f22 100644 --- a/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/MultipleConsumersPageStressTest.java +++ b/tests/stress-tests/src/test/java/org/apache/activemq/artemis/tests/stress/paging/MultipleConsumersPageStressTest.java @@ -317,11 +317,7 @@ public class MultipleConsumersPageStressTest extends ActiveMQTestBase { for (int i = 0; i < numberOfMessages; i++) { ClientMessage msg = consumer.receive(10000); if (msg == null) { - log.warn("msg " + count + - " was null, currentBatchSize=" + - numberOfMessages + - ", current msg being read=" + - i); + log.warn("msg {} was null, currentBatchSize={}, current msg being read={}", count, numberOfMessages, i); } Assert.assertNotNull("msg " + count + " was null, currentBatchSize=" + diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/JournalImplTestUnit.java b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/JournalImplTestUnit.java index 5fa8b80c97..2ceea94553 100644 --- a/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/JournalImplTestUnit.java +++ b/tests/timing-tests/src/test/java/org/apache/activemq/artemis/tests/timing/core/journal/impl/JournalImplTestUnit.java @@ -151,9 +151,9 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { double rate = 1000 * (double) NUMBER_OF_RECORDS / (end - start); - log.debug("Rate of " + rate + " adds/removes per sec"); + log.debug("Rate of {} adds/removes per sec", rate); - log.debug("Reclaim status = " + debugJournal()); + log.debug("Reclaim status = {}", debugJournal()); stopJournal(); createJournal(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/AllClassesTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/AllClassesTest.java index bb3a497622..63e65e16b1 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/AllClassesTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/AllClassesTest.java @@ -58,9 +58,7 @@ public class AllClassesTest { parameters.add(loadedClass); } } catch (Throwable loadThrowable) { - if (log.isDebugEnabled()) { - log.debug("cannot load " + classInfo.getName() + ": " + loadThrowable); - } + log.debug("cannot load {} : {}", classInfo.getName(), loadThrowable); } } } @@ -69,7 +67,7 @@ public class AllClassesTest { return parameters; } catch (Exception e) { - log.warn("Exception on loading all classes: " + e); + log.warn("Exception on loading all classes: {}", e.toString()); } return parameters; @@ -89,7 +87,7 @@ public class AllClassesTest { try { targetInstance = newInstance(targetClass); } catch (Throwable t) { - log.debug("Error creating a new instance of " + targetClass.getName() + ": " + t); + log.debug("Error creating a new instance of {}: {}", targetClass.getName(), t); } Assume.assumeTrue("Cannot create " + targetClass.getName(), targetInstance != null); @@ -102,7 +100,7 @@ public class AllClassesTest { try { ((AutoCloseable)targetInstance).close(); } catch (Throwable t) { - log.debug("Error closing the instance of " + targetClass.getName() + ": " + t); + log.debug("Error closing the instance of {}: {}", targetClass.getName(), t); } } } @@ -145,7 +143,7 @@ public class AllClassesTest { return targetConstructor.newInstance(initArgs.toArray()); } catch (Throwable t) { if (log.isDebugEnabled()) { - log.debug("Cannot construct " + targetClass.getName() + ": " + t); + log.debug("Cannot construct {}: {}", targetClass.getName(), t); } } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java index ca67a3fad6..a121f73222 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/asyncio/MultiThreadAsynchronousFileTest.java @@ -66,10 +66,6 @@ public class MultiThreadAsynchronousFileTest extends AIOTestBase { ExecutorService pollerExecutor; - private static void debug(final String msg) { - log.info(msg); - } - @Override @Before public void setUp() throws Exception { @@ -97,7 +93,8 @@ public class MultiThreadAsynchronousFileTest extends AIOTestBase { } private void executeTest(final boolean sync) throws Throwable { - MultiThreadAsynchronousFileTest.debug(sync ? "Sync test:" : "Async test"); + log.debug(sync ? "Sync test:" : "Async test"); + AIOSequentialFileFactory factory = new AIOSequentialFileFactory(getTestDirfile(), 100); factory.start(); factory.disableBufferReuse(); @@ -105,11 +102,11 @@ public class MultiThreadAsynchronousFileTest extends AIOTestBase { AIOSequentialFile file = (AIOSequentialFile) factory.createSequentialFile(fileName); file.open(); try { - MultiThreadAsynchronousFileTest.debug("Preallocating file"); + log.debug("Preallocating file"); file.fill(MultiThreadAsynchronousFileTest.NUMBER_OF_THREADS * MultiThreadAsynchronousFileTest.SIZE * MultiThreadAsynchronousFileTest.NUMBER_OF_LINES); - MultiThreadAsynchronousFileTest.debug("Done Preallocating file"); + log.debug("Done Preallocating file"); CountDownLatch latchStart = new CountDownLatch(MultiThreadAsynchronousFileTest.NUMBER_OF_THREADS + 1); @@ -131,16 +128,13 @@ public class MultiThreadAsynchronousFileTest extends AIOTestBase { throw producer.failed; } } - long endTime = System.currentTimeMillis(); - MultiThreadAsynchronousFileTest.debug((sync ? "Sync result:" : "Async result:") + " Records/Second = " + - MultiThreadAsynchronousFileTest.NUMBER_OF_THREADS * - MultiThreadAsynchronousFileTest.NUMBER_OF_LINES * - 1000 / (endTime - startTime) + - " total time = " + - (endTime - startTime) + - " total number of records = " + - MultiThreadAsynchronousFileTest.NUMBER_OF_THREADS * MultiThreadAsynchronousFileTest.NUMBER_OF_LINES); + long endTime = System.currentTimeMillis(); + long duration = endTime - startTime; + long numRecords = NUMBER_OF_THREADS * NUMBER_OF_LINES; + long rate = numRecords * 1000 / duration; + + log.info("{} result: Records/Second = {} total time = {} total number of records = {}", (sync ? "Sync" : "Async"), rate, duration, numRecords); } finally { file.close(); factory.stop(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java index eb8758a718..301d8cc73c 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/AlignedJournalImplTest.java @@ -261,7 +261,7 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { Assert.assertEquals(2, factory.listFiles("tt").size()); - log.debug("Initial:--> " + journalImpl.debug()); + log.debug("Initial:--> {}", journalImpl.debug()); log.debug("_______________________________"); @@ -305,7 +305,7 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { Assert.assertEquals(2, factory.listFiles("tt").size()); - log.debug("Initial:--> " + journalImpl.debug()); + log.debug("Initial:--> {}", journalImpl.debug()); log.debug("_______________________________"); @@ -343,11 +343,11 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { journalImpl.debugWait(); - log.debug("Final:--> " + journalImpl.debug()); + log.debug("Final:--> {}", journalImpl.debug()); log.debug("_______________________________"); - log.debug("Files bufferSize:" + factory.listFiles("tt").size()); + log.debug("Files bufferSize: {}", factory.listFiles("tt").size()); Assert.assertEquals(2, factory.listFiles("tt").size()); @@ -423,7 +423,7 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { // forgotten (interrupted by a reload). Assert.fail("Supposed to throw exception"); } catch (Exception e) { - log.debug("Expected exception " + e, e); + log.debug("Got an expected exception:", e); } setupAndLoadJournal(JOURNAL_SIZE, 100); @@ -530,7 +530,7 @@ public class AlignedJournalImplTest extends ActiveMQTestBase { journalImpl.debugWait(); - log.debug("Files = " + factory.listFiles("tt")); + log.debug("Files = {}", factory.listFiles("tt")); SequentialFile file = factory.createSequentialFile("tt-1.tt"); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FileFactoryTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FileFactoryTestBase.java index 5d29205c98..4d81c077e9 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FileFactoryTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/FileFactoryTestBase.java @@ -62,7 +62,7 @@ public abstract class FileFactoryTestBase extends ActiveMQTestBase { bb.get(bytes); for (int i = 0; i < size; i++) { - // log.debug(" i is " + i); + // log.debug(" i is {}", i); Assert.assertEquals(0, bytes[i]); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java index fab9f266e9..ea785146af 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java @@ -255,7 +255,7 @@ public abstract class JournalImplTestBase extends ActiveMQTestBase { * @throws Exception */ protected void exportImportJournal() throws Exception { - log.debug("Exporting to " + getTestDir() + "/output.log"); + log.debug("Exporting to {}/output.log", getTestDir()); EncodeJournal.exportJournal(getTestDir(), this.filePrefix, this.fileExtension, this.minFiles, this.fileSize, getTestDir() + "/output.log"); @@ -268,12 +268,12 @@ public abstract class JournalImplTestBase extends ActiveMQTestBase { } }; - log.debug("file = " + dir); + log.debug("file = {}", dir); File[] files = dir.listFiles(fnf); for (File file : files) { - log.debug("Deleting " + file); + log.debug("Deleting {}", file); file.delete(); } @@ -679,7 +679,7 @@ public abstract class JournalImplTestBase extends ActiveMQTestBase { expectedSet.removeAll(actualSet); for (RecordInfo info : expectedSet) { - log.warn("The following record is missing:: " + info); + log.warn("The following record is missing:: {}", info); } Assert.assertEquals("There are duplicates on the actual list", actualSet.size(), actualSet.size()); @@ -698,23 +698,23 @@ public abstract class JournalImplTestBase extends ActiveMQTestBase { log.debug("#Summary **********************************************************************************************************************"); for (RecordInfo r : hashActual) { if (!hashExpected.contains(r)) { - log.debug("Record " + r + " was supposed to be removed and it exists"); + log.debug("Record {} was supposed to be removed and it exists", r); } } for (RecordInfo r : hashExpected) { if (!hashActual.contains(r)) { - log.debug("Record " + r + " was not found on actual list"); + log.debug("Record {} was not found on actual list", r); } } log.debug("#expected **********************************************************************************************************************"); for (RecordInfo recordInfo : expected) { - log.debug("Record::" + recordInfo); + log.debug("Record::{}", recordInfo); } log.debug("#actual ************************************************************************************************************************"); for (RecordInfo recordInfo : actual) { - log.debug("Record::" + recordInfo); + log.debug("Record::{}", recordInfo); } log.debug("#records ***********************************************************************************************************************"); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java index fccb6009dc..e1429f3ccb 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestUnit.java @@ -735,7 +735,7 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { int addRecordsPerFile = calculateRecordsPerFile(10 * 1024, journal.getAlignment(), JournalImpl.SIZE_ADD_RECORD + 1 + recordLength); - log.debug(String.valueOf(JournalImpl.SIZE_ADD_RECORD + 1 + recordLength)); + log.debug("{}", (JournalImpl.SIZE_ADD_RECORD + 1 + recordLength)); // Fills exactly 10 files int initialNumberOfAddRecords = addRecordsPerFile * 10; @@ -1084,7 +1084,9 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { journal.debugWait(); - log.debug("journal tmp :" + journal.debug()); + if (log.isDebugEnabled()) { + log.debug("journal tmp : {}", journal.debug()); + } journal.processBackup(); List files2 = fileFactory.listFiles(fileExtension); @@ -1102,7 +1104,9 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { journal.debugWait(); - log.debug("journal tmp2 :" + journal.debug()); + if (log.isDebugEnabled()) { + log.debug("journal tmp2 : {}", journal.debug()); + } journal.processBackup(); List files3 = fileFactory.listFiles(fileExtension); @@ -1110,8 +1114,8 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { Assert.assertEquals(4, files3.size()); Assert.assertEquals(1, journal.getOpenedFilesCount()); - log.debug("data files count " + journal.getDataFilesCount()); - log.debug("free files count " + journal.getFreeFilesCount()); + log.debug("data files count {}", journal.getDataFilesCount()); + log.debug("free files count {}", journal.getFreeFilesCount()); Assert.assertEquals(2, journal.getDataFilesCount()); Assert.assertEquals(0, journal.getFreeFilesCount()); @@ -1161,8 +1165,9 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { journal.checkReclaimStatus(); - log.debug("journal:" + journal.debug()); - + if (log.isDebugEnabled()) { + log.debug("journal: {}", journal.debug()); + } stopJournal(false); createJournal(); startJournal(); @@ -2020,7 +2025,9 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { addWithSize(1024 - JournalImpl.SIZE_ADD_RECORD, 6); - log.debug("Debug journal on testPrepareReclaim ->\n" + debugJournal()); + if (log.isDebugEnabled()) { + log.debug("Debug journal on testPrepareReclaim ->\n{}", debugJournal()); + } Assert.assertEquals(1, journal.getOpenedFilesCount()); Assert.assertEquals(0, journal.getFreeFilesCount()); @@ -3060,7 +3067,9 @@ public abstract class JournalImplTestUnit extends JournalImplTestBase { addTx(4, 31); commit(3); - log.debug("Debug on Journal before stopJournal - \n" + debugJournal()); + if (log.isDebugEnabled()) { + log.debug("Debug on Journal before stopJournal - \n{}", debugJournal()); + } stopJournal(); createJournal(); diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java index a3adc82ca6..2da04fb2de 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java @@ -400,7 +400,7 @@ public abstract class SequentialFileFactoryTestBase extends ActiveMQTestBase { Assert.assertEquals(calculateRecordSize(size, factory.getAlignment()), bytesRead); for (int i = 0; i < size; i++) { - // log.debug(" i is " + i); + // log.debug(" i is {}", i); Assert.assertEquals(0, bb.get(i)); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java index f393ad752d..710536f4a8 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/fakes/FakeSequentialFileFactory.java @@ -344,13 +344,13 @@ public class FakeSequentialFileFactory implements SequentialFileFactory { checkAndResize(size); - // log.debug("size is " + size + " pos is " + pos); + // log.debug("size is {} pos is {}", size, pos); for (int i = 0; i < size; i++) { byte[] array = data.array(); array[i] = 0; - // log.debug("Filling " + pos + " with char " + fillCharacter); + // log.debug("Filling {} with char {}", pos, fillCharacter); } } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java index af9de78d28..e93203c002 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/util/MemorySizeTest.java @@ -30,14 +30,14 @@ public class MemorySizeTest extends Assert { @Test public void testObjectSizes() throws Exception { - log.info("Server message size is " + MemorySize.calculateSize(new MemorySize.ObjectFactory() { + log.info("Server message size is {}", MemorySize.calculateSize(new MemorySize.ObjectFactory() { @Override public Object createObject() { return new CoreMessage(1, 1000); } })); - log.info("Message reference size is " + MemorySize.calculateSize(new MemorySize.ObjectFactory() { + log.info("Message reference size is {}", MemorySize.calculateSize(new MemorySize.ObjectFactory() { @Override public Object createObject() { return new MessageReferenceImpl();