[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.29-30-g9c732c9
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Mon Sep 19 13:17:54 CEST 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via 9c732c91bbed4acc059d2242e76ed18ac6e7194b (commit)
via 904ba967f62651a3ae1163d18303afe412a7102c (commit)
via 082d5df90dc5e5a7181998134f59582274e53000 (commit)
via 1d001fc4640fc42b3bb1a34eafe492d62f55c17b (commit)
via 2ac4ee863fc4d3c74439a91a0d327e2aaf93543a (commit)
from 513fb2d00fecf03dc8bc561f9cdc2e49bc0d80df (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=9c732c91bbed4acc059d2242e76ed18ac6e7194b
http://github.com/ceki/logback/commit/9c732c91bbed4acc059d2242e76ed18ac6e7194b
commit 9c732c91bbed4acc059d2242e76ed18ac6e7194b
Author: Ceki Gulcu <ceki at qos.ch>
Date: Mon Sep 19 13:16:13 2011 +0200
disallow empty values to be returned by ILoggingEvent#getMDCPropertyMap
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java
index 4b169bd..ce64e2f 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/ILoggingEvent.java
@@ -70,7 +70,7 @@ public interface ILoggingEvent extends DeferredProcessingAware {
public Marker getMarker();
/**
- * Returns the MDC map.
+ * Returns the MDC map. The returned value can be an empty map but not null.
*/
public Map<String, String> getMDCPropertyMap();
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
index 59dcf09..9581dc1 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
@@ -25,6 +25,7 @@ import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.util.LogbackMDCAdapter;
+import org.slf4j.spi.MDCAdapter;
/**
* The internal representation of logging events. When an affirmative decision
@@ -205,11 +206,7 @@ public class LoggingEvent implements ILoggingEvent {
this.getFormattedMessage();
this.getThreadName();
// fixes http://jira.qos.ch/browse/LBCLASSIC-104
- if (mdcPropertyMap == null) {
- mdcPropertyMap = MDC.getCopyOfContextMap();
- if (mdcPropertyMap == null)
- mdcPropertyMap = CACHED_NULL_MAP;
- }
+ this.getMDCPropertyMap();
}
public LoggerContextVO getLoggerContextVO() {
@@ -307,17 +304,19 @@ public class LoggingEvent implements ILoggingEvent {
}
public Map<String, String> getMDCPropertyMap() {
+ // populate mdcPropertyMap if null
if (mdcPropertyMap == null) {
MDCAdapter mdc = MDC.getMDCAdapter();
if (mdc instanceof LogbackMDCAdapter)
- return ((LogbackMDCAdapter)mdc).getPropertyMap();
- else {
+ mdcPropertyMap = ((LogbackMDCAdapter)mdc).getPropertyMap();
+ else
mdcPropertyMap = mdc.getCopyOfContextMap();
- if (mdcPropertyMap == null)
- mdcPropertyMap = CACHED_NULL_MAP;
- }
}
- return mdcPropertyMap == CACHED_NULL_MAP ? null : mdcPropertyMap;
+ // mdcPropertyMap still null, use CACHED_NULL_MAP
+ if (mdcPropertyMap == null)
+ mdcPropertyMap = CACHED_NULL_MAP;
+
+ return mdcPropertyMap;
}
/**
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
index bfaa7de..02e5ba7 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/boolex/JaninoEventEvaluatorTest.java
@@ -265,7 +265,7 @@ public class JaninoEventEvaluatorTest {
@Test
public void nullMDC() throws EvaluationException {
MDC.clear();
- jee.setExpression("mdc == null");
+ jee.setExpression("mdc.isEmpty()");
jee.start();
LoggingEvent event = makeLoggingEvent(null);
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/sift/MDCBasedDiscriminatorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/sift/MDCBasedDiscriminatorTest.java
index 395f542..edd0013 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/sift/MDCBasedDiscriminatorTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/sift/MDCBasedDiscriminatorTest.java
@@ -25,6 +25,8 @@ import org.junit.Test;
import org.slf4j.MDC;
+import java.util.HashMap;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -71,7 +73,7 @@ public class MDCBasedDiscriminatorTest {
@Test
public void nullMDC() {
event = new LoggingEvent("a", logger, Level.DEBUG, "", null, null);
- assertNull(event.getMdc());
+ assertEquals(new HashMap(), event.getMDCPropertyMap());
String discriminatorValue = discriminator.getDiscriminatingValue(event);
assertEquals(DEFAULT_VAL, discriminatorValue);
}
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java
index e3f62c6..f759df2 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationPerfTest.java
@@ -100,7 +100,7 @@ public class LoggingEventSerializationPerfTest {
long averageSize = (long) (noos.size() / (LOOP_LEN));
System.out.println("noos size " + noos.size() + " average size="
+ averageSize);
- double averageSizeLimit = 60;
+ double averageSizeLimit = 62.1;
assertTrue("average size " + averageSize + " should be less than "
+ averageSizeLimit, averageSizeLimit > averageSize);
diff --git a/logback-site/src/site/pages/manual/filters.html b/logback-site/src/site/pages/manual/filters.html
index bb931b7..0e67022 100644
--- a/logback-site/src/site/pages/manual/filters.html
+++ b/logback-site/src/site/pages/manual/filters.html
@@ -479,9 +479,9 @@ public class SampleFilter extends Filter>ILoggingEvent> {
<td><code>Map</code></td>
<td>A map containing all the MDC values at the time of the
creation of the logging event. A value can be accessed by
- using the following expression: <em>mdc.get("myKey")</em>. The
- 'mdc' variable can be null and this possibility should be
- checked for in evaluator expressions.
+ using the following expression: <em>mdc.get("myKey")</em>. As
+ of logback-classic version 0.9.30, the 'mdc' variable will
+ never be null.
<p>The <code>java.util.Map</code> type is non-parameterized
because Janino does not support generics. It follows that the
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 97ae9ad..2233c5e 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -44,6 +44,13 @@
of the <code>ILoggingEvent</code> interface in prior versions of
logback-classic.</p>
+ <p><code>LoggingEvent</code> no longer assumes that
+ <code>LogbackMDCAdapter</code> is the only possible implementation
+ of the <code>MDCAdapter</code> interface. This fixes <a
+ href="http://jira.qos.ch/browse/LBCLASSIC-275">LBCLASSIC-275</a>
+ reported by Chris Dolan.
+ </p>
+
<p>It is now possible to specify multiple destination addresses
separated by commas in the the <span class="option">to</span>
property of <code>SMTPAppender</code>. This fixes <a
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=904ba967f62651a3ae1163d18303afe412a7102c
http://github.com/ceki/logback/commit/904ba967f62651a3ae1163d18303afe412a7102c
commit 904ba967f62651a3ae1163d18303afe412a7102c
Merge: 513fb2d 082d5df
Author: Ceki Gulcu <ceki at qos.ch>
Date: Mon Sep 19 03:03:31 2011 -0700
Merge pull request #17 from chrisdolan/master
LBCLASSIC-275 - LoggingEvent casts to LogbackMDCAdapter without checking
diff --cc logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
index c2a0e1b,141ed3f..59dcf09
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
@@@ -309,15 -307,21 +307,25 @@@ public class LoggingEvent implements IL
}
public Map<String, String> getMDCPropertyMap() {
- return mdcPropertyMap;
+ if (mdcPropertyMap == null) {
+ MDCAdapter mdc = MDC.getMDCAdapter();
+ if (mdc instanceof LogbackMDCAdapter)
+ return ((LogbackMDCAdapter)mdc).getPropertyMap();
+ else {
+ mdcPropertyMap = mdc.getCopyOfContextMap();
+ if (mdcPropertyMap == null)
+ mdcPropertyMap = CACHED_NULL_MAP;
+ }
+ }
+ return mdcPropertyMap == CACHED_NULL_MAP ? null : mdcPropertyMap;
}
+ /**
+ * Synonym for [@link #getMDCPropertyMap}.
+ * @deprecated Replaced by [@link #getMDCPropertyMap}
+ */
public Map<String, String> getMdc() {
- return mdcPropertyMap;
+ return getMDCPropertyMap();
}
@Override
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=082d5df90dc5e5a7181998134f59582274e53000
http://github.com/ceki/logback/commit/082d5df90dc5e5a7181998134f59582274e53000
commit 082d5df90dc5e5a7181998134f59582274e53000
Author: Chris Dolan <chris at chrisdolan.net>
Date: Mon Jun 13 14:29:50 2011 -0500
proper handling of null MDC in LoggingEvent caching
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
index 6090f02..141ed3f 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
@@ -89,6 +89,7 @@ public class LoggingEvent implements ILoggingEvent {
private Marker marker;
private Map<String, String> mdcPropertyMap;
+ private static final Map<String, String> CACHED_NULL_MAP = new HashMap<String, String>();
/**
* The number of milliseconds elapsed from 1/1/1970 until logging event was
@@ -206,6 +207,8 @@ public class LoggingEvent implements ILoggingEvent {
// fixes http://jira.qos.ch/browse/LBCLASSIC-104
if (mdcPropertyMap == null) {
mdcPropertyMap = MDC.getCopyOfContextMap();
+ if (mdcPropertyMap == null)
+ mdcPropertyMap = CACHED_NULL_MAP;
}
}
@@ -308,10 +311,13 @@ public class LoggingEvent implements ILoggingEvent {
MDCAdapter mdc = MDC.getMDCAdapter();
if (mdc instanceof LogbackMDCAdapter)
return ((LogbackMDCAdapter)mdc).getPropertyMap();
- else
+ else {
mdcPropertyMap = mdc.getCopyOfContextMap();
+ if (mdcPropertyMap == null)
+ mdcPropertyMap = CACHED_NULL_MAP;
+ }
}
- return mdcPropertyMap;
+ return mdcPropertyMap == CACHED_NULL_MAP ? null : mdcPropertyMap;
}
public Map<String, String> getMdc() {
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=1d001fc4640fc42b3bb1a34eafe492d62f55c17b
http://github.com/ceki/logback/commit/1d001fc4640fc42b3bb1a34eafe492d62f55c17b
commit 1d001fc4640fc42b3bb1a34eafe492d62f55c17b
Author: Chris Dolan <chris at chrisdolan.net>
Date: Mon Jun 13 14:15:30 2011 -0500
fix typo: mdcPropertyMap != null should have been mdcPropertyMap == null
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
index c792217..6090f02 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
@@ -204,7 +204,7 @@ public class LoggingEvent implements ILoggingEvent {
this.getFormattedMessage();
this.getThreadName();
// fixes http://jira.qos.ch/browse/LBCLASSIC-104
- if (mdcPropertyMap != null) {
+ if (mdcPropertyMap == null) {
mdcPropertyMap = MDC.getCopyOfContextMap();
}
}
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=2ac4ee863fc4d3c74439a91a0d327e2aaf93543a
http://github.com/ceki/logback/commit/2ac4ee863fc4d3c74439a91a0d327e2aaf93543a
commit 2ac4ee863fc4d3c74439a91a0d327e2aaf93543a
Author: Chris Dolan <chris at chrisdolan.net>
Date: Mon Jun 13 09:34:05 2011 -0500
http://jira.qos.ch/browse/LBCLASSIC-275 - LoggingEvent casts to LogbackMDCAdapter without checking
Implementation of the proposal in the first comment of that issue: defer reading the MDC until as late as possible
diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
index d68e448..c792217 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggingEvent.java
@@ -128,11 +128,6 @@ public class LoggingEvent implements ILoggingEvent {
}
timeStamp = System.currentTimeMillis();
-
- // ugly but under the circumstances acceptable
- LogbackMDCAdapter logbackMDCAdapter = (LogbackMDCAdapter) MDC
- .getMDCAdapter();
- mdcPropertyMap = logbackMDCAdapter.getPropertyMap();
}
public void setArgumentArray(Object[] argArray) {
@@ -210,7 +205,7 @@ public class LoggingEvent implements ILoggingEvent {
this.getThreadName();
// fixes http://jira.qos.ch/browse/LBCLASSIC-104
if (mdcPropertyMap != null) {
- mdcPropertyMap = new HashMap<String, String>(mdcPropertyMap);
+ mdcPropertyMap = MDC.getCopyOfContextMap();
}
}
@@ -309,11 +304,18 @@ public class LoggingEvent implements ILoggingEvent {
}
public Map<String, String> getMDCPropertyMap() {
+ if (mdcPropertyMap == null) {
+ MDCAdapter mdc = MDC.getMDCAdapter();
+ if (mdc instanceof LogbackMDCAdapter)
+ return ((LogbackMDCAdapter)mdc).getPropertyMap();
+ else
+ mdcPropertyMap = mdc.getCopyOfContextMap();
+ }
return mdcPropertyMap;
}
public Map<String, String> getMdc() {
- return mdcPropertyMap;
+ return getMDCPropertyMap();
}
@Override
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/classic/spi/ILoggingEvent.java | 2 +-
.../ch/qos/logback/classic/spi/LoggingEvent.java | 25 ++++++++++++-------
.../classic/boolex/JaninoEventEvaluatorTest.java | 2 +-
.../classic/sift/MDCBasedDiscriminatorTest.java | 4 ++-
.../spi/LoggingEventSerializationPerfTest.java | 2 +-
logback-site/src/site/pages/manual/filters.html | 6 ++--
logback-site/src/site/pages/news.html | 7 +++++
7 files changed, 32 insertions(+), 16 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list