Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARTEMIS-4020: Remove string appends and various isXEnabled logger che… #4247

Merged
merged 1 commit into from Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Expand Up @@ -250,14 +250,11 @@ private File processMessageBody(final ICoreMessage message, boolean decodeTextMe
}
}
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);
}
Expand Down
Expand Up @@ -248,9 +248,7 @@ public int compare(XMLMessageImporter.MessageInfo o1, XMLMessageImporter.Message
}
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
Expand Down Expand Up @@ -315,17 +313,13 @@ private void sendMessage(List<String> queues, Message message, File tempFileName
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
}

Expand Down Expand Up @@ -425,13 +419,9 @@ private void oldBinding() throws Exception {

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);
}
}

Expand Down Expand Up @@ -467,13 +457,9 @@ private void bindQueue() throws Exception {

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);
Expand Down Expand Up @@ -503,13 +489,9 @@ private void bindAddress() throws Exception {
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);
}
}

Expand Down
Expand Up @@ -359,9 +359,7 @@ private InetAddress internalCheck(String straddress) {

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);
Expand All @@ -376,9 +374,7 @@ public boolean purePing(InetAddress address) throws IOException, InterruptedExce
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());
Expand All @@ -398,10 +394,7 @@ public boolean purePing(InetAddress address) throws IOException, InterruptedExce
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;
Expand Down
Expand Up @@ -65,9 +65,9 @@ public static void outFrame(Logger logger, String message, ByteBuf byteIn, boole

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);
Expand Down
Expand Up @@ -143,7 +143,7 @@ private class BlowfishAlgorithm extends CodecAlgorithm {
} 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);
}
}
Expand Down Expand Up @@ -199,7 +199,7 @@ public boolean verify(char[] inputValue, String storedValue) {
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;
}
}
Expand Down
Expand Up @@ -91,7 +91,7 @@ public static void saveUTF(final ByteBuf out, final String str) {

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()) {
Expand Down Expand Up @@ -189,7 +189,7 @@ public static String readUTF(final ActiveMQBuffer input) {

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();
Expand Down
Expand Up @@ -127,7 +127,7 @@ public byte[] generateDummyAddress() {
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;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ public static byte[] getHardwareAddress() {
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;
}
Expand Down
Expand Up @@ -203,7 +203,7 @@ private void onAddedTaskIfNotRunning(int state) {

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"));
}
}

Expand Down
Expand Up @@ -70,8 +70,8 @@ protected final void doTask(Object task) {
} 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);
}
}
}
Expand All @@ -83,8 +83,8 @@ public void act(T message) {
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);
}
Expand Down
Expand Up @@ -437,7 +437,7 @@ static int alignToPowerOfTwo(int n) {

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;
Expand Down
Expand Up @@ -110,8 +110,8 @@ protected void leaveCritical() {
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;
Expand All @@ -137,9 +137,9 @@ public boolean checkExpiration(long timeout, boolean reset) {
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) {
Expand Down
Expand Up @@ -37,7 +37,7 @@ public class FluentPropertyBeanIntrospectorWithIgnores extends FluentPropertyBea
private static ConcurrentHashSet<Pair<String, String>> 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));
}

Expand All @@ -53,7 +53,7 @@ public void introspect(IntrospectionContext icontext) throws IntrospectionExcept
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 {
Expand Down
Expand Up @@ -54,7 +54,7 @@ private void testAlgorithm(String algorithm) throws Exception {

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
Expand All @@ -65,7 +65,7 @@ private void testAlgorithm(String algorithm) throws Exception {
}
} else {
String decoded = codec.decode(maskedText);
log.debug("encoded value: " + maskedText);
log.debug("encoded value: {}", maskedText);

assertEquals("decoded result not match: " + decoded, decoded, plainText);
}
Expand All @@ -91,7 +91,7 @@ private void testCompareWithAlgorithm(String algorithm) throws Exception {

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));

Expand Down
Expand Up @@ -179,7 +179,7 @@ public void testMeasure() throws InterruptedException {

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();
Expand Down
Expand Up @@ -52,9 +52,9 @@ public void testMultiThread() throws Throwable {

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
Expand Down
Expand Up @@ -45,7 +45,7 @@ public ChannelBroadcastEndpointFactory(JChannel channel, String channelName) {

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;
Expand Down
Expand Up @@ -52,8 +52,10 @@ public JGroupsBroadcastEndpoint(JChannelManager manager, String channelName) {

@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();

Expand All @@ -65,8 +67,10 @@ public void broadcast(final byte[] data) throws Exception {

@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 {
Expand All @@ -76,8 +80,10 @@ public byte[] receiveBroadcast() throws Exception {

@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 {
Expand Down
Expand Up @@ -75,12 +75,11 @@ public synchronized JChannelWrapper getJChannel(String channelName,
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();
}

Expand Down