You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/03/03 15:43:37 UTC
logging-log4j2 git commit: LOG4J2-1296 simplified ReusableMessage
interface
Repository: logging-log4j2
Updated Branches:
refs/heads/master f030c68fb -> 406158c25
LOG4J2-1296 simplified ReusableMessage interface
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/406158c2
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/406158c2
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/406158c2
Branch: refs/heads/master
Commit: 406158c25a71b8f5c8e9d60760bc6ce30d8b84c9
Parents: f030c68
Author: rpopma <rp...@apache.org>
Authored: Thu Mar 3 23:43:49 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Thu Mar 3 23:43:49 2016 +0900
----------------------------------------------------------------------
.../org/apache/logging/log4j/message/ReusableMessage.java | 9 ++-------
.../logging/log4j/message/ReusableParameterizedMessage.java | 5 -----
.../org/apache/logging/log4j/core/async/AsyncLogger.java | 4 ++--
.../apache/logging/log4j/core/async/RingBufferLogEvent.java | 9 ++-------
4 files changed, 6 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/406158c2/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
index 46e94f2..2613104 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableMessage.java
@@ -19,16 +19,11 @@ package org.apache.logging.log4j.message;
import org.apache.logging.log4j.util.StringBuilderFormattable;
/**
- * Messages implementing this interface may or may not be reused.
+ * Messages implementing this interface are reused.
* <p>
- * If a Message is reused, downstream components should not hand over this instance to another thread, but extract its
+ * If a Message is reusable, downstream components should not hand over this instance to another thread, but extract its
* content (via the {@link StringBuilderFormattable#formatTo(StringBuilder)} method) instead.
* </p>
*/
public interface ReusableMessage extends Message, StringBuilderFormattable {
- /**
- * Returns {@code true} if this instance is and will be reused
- * @return whether this is a reused instance
- */
- boolean isReused();
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/406158c2/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
index b4a1e5c..79cca35 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableParameterizedMessage.java
@@ -71,11 +71,6 @@ public class ReusableParameterizedMessage implements ReusableMessage {
public ReusableParameterizedMessage() {
}
- @Override
- public boolean isReused() {
- return true;
- }
-
private InternalState getState() {
InternalState result = state.get();
if (result == null) {
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/406158c2/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
index 1a060d2..226ba08 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLogger.java
@@ -166,7 +166,7 @@ public class AsyncLogger extends Logger implements EventTranslatorVararg<RingBuf
}
private boolean isReused(final Message message) {
- return message instanceof ReusableMessage && ((ReusableMessage) message).isReused();
+ return message instanceof ReusableMessage;
}
/**
@@ -253,7 +253,7 @@ public class AsyncLogger extends Logger implements EventTranslatorVararg<RingBuf
currentThread.getPriority(), //
// location (expensive to calculate)
- calcLocationIfRequested(fqcn),
+ calcLocationIfRequested(fqcn),
eventTimeMillis(message), nanoClock.nanoTime() //
);
}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/406158c2/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
index 37c7be0..a78582f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java
@@ -67,11 +67,6 @@ public class RingBufferLogEvent implements LogEvent {
private StringBuilder stringBuilder;
@Override
- public boolean isReused() {
- return true;
- }
-
- @Override
public String getFormattedMessage() {
return null;
}
@@ -137,7 +132,7 @@ public class RingBufferLogEvent implements LogEvent {
this.marker = aMarker;
this.fqcn = theFqcn;
this.level = aLevel;
- if (msg instanceof ReusableMessage && ((ReusableMessage) msg).isReused()) {
+ if (msg instanceof ReusableMessage) {
if (messageText == null) {
// Should never happen:
// only happens if user logs a custom reused message when Constants.ENABLE_THREADLOCALS is false
@@ -336,7 +331,7 @@ public class RingBufferLogEvent implements LogEvent {
0, // threadName
null, // location
0, // currentTimeMillis
- null,
+ null,
0, 0 // nanoTime
);
}