logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: logging-log4j2 git commit: Null comparison always yields false, so return false.
Date Mon, 10 Aug 2015 03:19:33 GMT
Let's walk through it.

First, obj is final and:

        if (obj == null) {
            return false;
        }

After that obj is _never_ null. Then. later:

        final ThreadContextStack other = (ThreadContextStack) obj;

So other is _never_ null, then finally:

        return other == null;

which is never true, hence return false;

Check?

Gary


On Sun, Aug 9, 2015 at 7:59 PM, Remko Popma <remko.popma@gmail.com> wrote:

> Hang on, this changes the semantics!
> If value is null and other is null we want to return true, not false.
>
> Sent from my iPhone
>
> > On 2015/08/10, at 11:16, ggregory@apache.org wrote:
> >
> > Repository: logging-log4j2
> > Updated Branches:
> >  refs/heads/master 3eeb2f6c9 -> cbab41909
> >
> >
> > Null comparison always yields false, so return false.
> >
> >
> > Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> > Commit:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/cbab4190
> > Tree:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/cbab4190
> > Diff:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/cbab4190
> >
> > Branch: refs/heads/master
> > Commit: cbab4190931af2f28935fd7b3503e2c78efaed79
> > Parents: 3eeb2f6
> > Author: ggregory <ggregory@apache.org>
> > Authored: Sun Aug 9 19:15:59 2015 -0700
> > Committer: ggregory <ggregory@apache.org>
> > Committed: Sun Aug 9 19:15:59 2015 -0700
> >
> > ----------------------------------------------------------------------
> > .../org/apache/logging/log4j/spi/DefaultThreadContextStack.java    | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > ----------------------------------------------------------------------
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/cbab4190/log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextStack.java
> > ----------------------------------------------------------------------
> > diff --git
> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextStack.java
> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextStack.java
> > index 12229ca..5e2921b 100644
> > ---
> a/log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextStack.java
> > +++
> b/log4j-api/src/main/java/org/apache/logging/log4j/spi/DefaultThreadContextStack.java
> > @@ -128,7 +128,7 @@ public class DefaultThreadContextStack implements
> ThreadContextStack {
> >         final ThreadContextStack other = (ThreadContextStack) obj;
> >         final MutableThreadContextStack values = stack.get();
> >         if (values == null) {
> > -            return other == null;
> > +            return false;
> >         }
> >         return values.equals(other);
> >     }
> >
>
> ---------------------------------------------------------------------
> 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
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
View raw message