You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2012/12/07 03:23:16 UTC

svn commit: r1418170 - /logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java

Author: ggregory
Date: Fri Dec  7 02:23:16 2012
New Revision: 1418170

URL: http://svn.apache.org/viewvc?rev=1418170&view=rev
Log:
Remove extra code that is not needed.

Modified:
    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java

Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java?rev=1418170&r1=1418169&r2=1418170&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java (original)
+++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java Fri Dec  7 02:23:16 2012
@@ -99,9 +99,8 @@ public class SimpleLoggerContext impleme
             return loggers.get(name);
         }
 
-        loggers.putIfAbsent(name, new SimpleLogger(name, defaultLevel, showLogName, showShortName, showDateTime,
+        return loggers.putIfAbsent(name, new SimpleLogger(name, defaultLevel, showLogName, showShortName, showDateTime,
             showContextMap, dateTimeFormat, props, stream));
-        return loggers.get(name);
     }
 
     public boolean hasLogger(String name) {



Re: svn commit: r1418170 - /logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java

Posted by Gary Gregory <ga...@gmail.com>.
On Fri, Dec 7, 2012 at 11:52 AM, Ralph Goers <ra...@dslextreme.com>wrote:

> According to the javadoc for ConcurrentMap this change is in error.  The
> result of putIfAbseent is the previous value, not the new value.  So if the
> map previously did not contain the key the returned value will now be null,
> not the new value.
>

I reverted the commit. Thank you for catching my mistake.


>
> Ralph
>
> On Dec 6, 2012, at 6:23 PM, ggregory@apache.org wrote:
>
> > Author: ggregory
> > Date: Fri Dec  7 02:23:16 2012
> > New Revision: 1418170
> >
> > URL: http://svn.apache.org/viewvc?rev=1418170&view=rev
> > Log:
> > Remove extra code that is not needed.
> >
> > Modified:
> >
>  logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
> >
> > Modified:
> logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
> > URL:
> http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java?rev=1418170&r1=1418169&r2=1418170&view=diff
> >
> ==============================================================================
> > ---
> logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
> (original)
> > +++
> logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
> Fri Dec  7 02:23:16 2012
> > @@ -99,9 +99,8 @@ public class SimpleLoggerContext impleme
> >             return loggers.get(name);
> >         }
> >
> > -        loggers.putIfAbsent(name, new SimpleLogger(name, defaultLevel,
> showLogName, showShortName, showDateTime,
> > +        return loggers.putIfAbsent(name, new SimpleLogger(name,
> defaultLevel, showLogName, showShortName, showDateTime,
> >             showContextMap, dateTimeFormat, props, stream));
> > -        return loggers.get(name);
> >     }
> >
> >     public boolean hasLogger(String name) {
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: svn commit: r1418170 - /logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java

Posted by Ralph Goers <ra...@dslextreme.com>.
According to the javadoc for ConcurrentMap this change is in error.  The result of putIfAbseent is the previous value, not the new value.  So if the map previously did not contain the key the returned value will now be null, not the new value.

Ralph

On Dec 6, 2012, at 6:23 PM, ggregory@apache.org wrote:

> Author: ggregory
> Date: Fri Dec  7 02:23:16 2012
> New Revision: 1418170
> 
> URL: http://svn.apache.org/viewvc?rev=1418170&view=rev
> Log:
> Remove extra code that is not needed.
> 
> Modified:
>    logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
> 
> Modified: logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java
> URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java?rev=1418170&r1=1418169&r2=1418170&view=diff
> ==============================================================================
> --- logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java (original)
> +++ logging/log4j/log4j2/trunk/api/src/main/java/org/apache/logging/log4j/simple/SimpleLoggerContext.java Fri Dec  7 02:23:16 2012
> @@ -99,9 +99,8 @@ public class SimpleLoggerContext impleme
>             return loggers.get(name);
>         }
> 
> -        loggers.putIfAbsent(name, new SimpleLogger(name, defaultLevel, showLogName, showShortName, showDateTime,
> +        return loggers.putIfAbsent(name, new SimpleLogger(name, defaultLevel, showLogName, showShortName, showDateTime,
>             showContextMap, dateTimeFormat, props, stream));
> -        return loggers.get(name);
>     }
> 
>     public boolean hasLogger(String name) {
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org