logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickwilli...@apache.org
Subject svn commit: r1561937 - in /logging/log4j/log4j2/trunk: log4j-core/src/main/java/org/apache/logging/log4j/core/web/ log4j-core/src/test/java/org/apache/logging/log4j/core/web/ src/changes/
Date Tue, 28 Jan 2014 05:03:28 GMT
Author: nickwilliams
Date: Tue Jan 28 05:03:27 2014
New Revision: 1561937

URL: http://svn.apache.org/r1561937
Log:
Fixed LOG4J2-344: Changed the Servlet 3.0 auto-initializer to add the filter by class to get
around a WebLogic bug.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jServletContainerInitializer.java
    logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/web/Log4jServletContainerInitializerTest.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jServletContainerInitializer.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jServletContainerInitializer.java?rev=1561937&r1=1561936&r2=1561937&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jServletContainerInitializer.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jServletContainerInitializer.java
Tue Jan 28 05:03:27 2014
@@ -41,7 +41,7 @@ public class Log4jServletContainerInitia
             servletContext.log("Log4jServletContainerInitializer starting up Log4j in Servlet
3.0+ environment.");
 
             final FilterRegistration.Dynamic filter =
-                    servletContext.addFilter("log4jServletFilter", new Log4jServletFilter());
+                    servletContext.addFilter("log4jServletFilter", Log4jServletFilter.class);
             if (filter == null) {
                 servletContext.log("WARNING: In a Servlet 3.0+ application, you should not
define a " +
                         "log4jServletFilter in web.xml. Log4j 2 normally does this for you
automatically. Log4j 2 " +

Modified: logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/web/Log4jServletContainerInitializerTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/web/Log4jServletContainerInitializerTest.java?rev=1561937&r1=1561936&r2=1561937&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/web/Log4jServletContainerInitializerTest.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/test/java/org/apache/logging/log4j/core/web/Log4jServletContainerInitializerTest.java
Tue Jan 28 05:03:27 2014
@@ -75,7 +75,7 @@ public class Log4jServletContainerInitia
         final FilterRegistration.Dynamic registration = createStrictMock(FilterRegistration.Dynamic.class);
 
         final Capture<EventListener> listenerCapture = new Capture<EventListener>();
-        final Capture<Filter> filterCapture = new Capture<Filter>();
+        final Capture<Class<? extends Filter>> filterCapture = new Capture<Class<?
extends Filter>>();
 
         expect(this.servletContext.getMajorVersion()).andReturn(3);
         expect(this.servletContext.getEffectiveMajorVersion()).andReturn(3);
@@ -101,14 +101,14 @@ public class Log4jServletContainerInitia
                 listenerCapture.getValue().getClass());
 
         assertNotNull("The filter should not be null.", filterCapture.getValue());
-        assertSame("The filter is not correct.", Log4jServletFilter.class, filterCapture.getValue().getClass());
+        assertSame("The filter is not correct.", Log4jServletFilter.class, filterCapture.getValue());
 
         verify(registration);
     }
 
     @Test
     public void testOnStartupCanceledDueToPreExistingFilter() throws Exception {
-        final Capture<Filter> filterCapture = new Capture<Filter>();
+        final Capture<Class<? extends Filter>> filterCapture = new Capture<Class<?
extends Filter>>();
         final Capture<String> logCapture = new Capture<String>();
 
         expect(this.servletContext.getMajorVersion()).andReturn(3);
@@ -123,7 +123,7 @@ public class Log4jServletContainerInitia
         this.containerInitializer.onStartup(null, this.servletContext);
 
         assertNotNull("The filter should not be null.", filterCapture.getValue());
-        assertSame("The filter is not correct.", Log4jServletFilter.class, filterCapture.getValue().getClass());
+        assertSame("The filter is not correct.", Log4jServletFilter.class, filterCapture.getValue());
 
         assertNotNull("The second log message should not be null.", logCapture.getValue());
         assertTrue("The second log message (" + logCapture.getValue() + ") is not correct.",
@@ -134,7 +134,7 @@ public class Log4jServletContainerInitia
     public void testOnStartupFailedDueToInitializerFailure() throws Exception {
         final FilterRegistration.Dynamic registration = createStrictMock(FilterRegistration.Dynamic.class);
 
-        final Capture<Filter> filterCapture = new Capture<Filter>();
+        final Capture<Class<? extends Filter>> filterCapture = new Capture<Class<?
extends Filter>>();
         final UnavailableException exception = new UnavailableException("");
 
         expect(this.servletContext.getMajorVersion()).andReturn(3);
@@ -156,7 +156,7 @@ public class Log4jServletContainerInitia
         }
 
         assertNotNull("The filter should not be null.", filterCapture.getValue());
-        assertSame("The filter is not correct.", Log4jServletFilter.class, filterCapture.getValue().getClass());
+        assertSame("The filter is not correct.", Log4jServletFilter.class, filterCapture.getValue());
 
         verify(registration);
     }

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1561937&r1=1561936&r2=1561937&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Tue Jan 28 05:03:27 2014
@@ -163,6 +163,9 @@
         ensures behavioral consistency across containers. This includes additional fixes
to abort initialization if a
         duplicate filter already exists and to check the actual Servlet EFFECTIVE version.
       </action>
+      <action issue="LOG4J2-344" dev="nickwilliams" type="fix" due-to="Keir Lawson, Tomasz
Wladzinski">
+        Changed the Servlet 3.0 auto-initializer to add the filter by class to get around
a WebLogic bug.
+      </action>
     </release>
     <release version="2.0-beta9" date="2013-09-14" description="Bug fixes and enhancements">
       <action issue="LOG4J2-317" dev="ggregory" type="update">



Mime
View raw message