You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2020/07/05 20:58:44 UTC

[httpcomponents-client] branch master updated: HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager boxed primitive reference equality

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/master by this push:
     new 1572f55  HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager boxed primitive reference equality
1572f55 is described below

commit 1572f5568730362aa4f5bdf052503db52c643bab
Author: Carter Kozak <ck...@apache.org>
AuthorDate: Sun Jul 5 13:10:25 2020 -0400

    HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager boxed primitive reference equality
---
 .../hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
index cd0e6b0..80d05c2 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
@@ -252,7 +252,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
 
                                     @Override
                                     public void execute(final Boolean result) {
-                                        if (result == Boolean.FALSE) {
+                                        if (!result) {
                                             if (log.isDebugEnabled()) {
                                                 log.debug("{}: connection {} is stale", id, ConnPoolSupport.getId(connection));
                                             }


Re: [httpcomponents-client] branch master updated: HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager boxed primitive reference equality

Posted by Carter Kozak <ck...@ckozak.net>.
I've opened this PR to prevent exceptions when null values are received:
https://github.com/apache/httpcomponents-client/pull/237

-ck

On Mon, Jul 6, 2020, at 02:35, Michael Osipov wrote:
> Am 2020-07-06 um 04:03 schrieb Gary Gregory:
> > I would expect null to be like false.
> > 
> > The more important point is that the change is a potential NPE.
> 
> It was prone to NPE before: result == Bolean.FALSE. You'd have to reject 
> null args with the Args class.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
> 
> 

Re: [httpcomponents-client] branch master updated: HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager boxed primitive reference equality

Posted by Michael Osipov <mi...@apache.org>.
Am 2020-07-06 um 04:03 schrieb Gary Gregory:
> I would expect null to be like false.
> 
> The more important point is that the change is a potential NPE.

It was prone to NPE before: result == Bolean.FALSE. You'd have to reject 
null args with the Args class.

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


Re: [httpcomponents-client] branch master updated: HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager boxed primitive reference equality

Posted by Gary Gregory <ga...@gmail.com>.
I would expect null to be like false.

The more important point is that the change is a potential NPE.

Gary

On Sun, Jul 5, 2020, 20:58 Carter Kozak <ck...@ckozak.net> wrote:

> Hi Gary,
>
> Is null a valid input? As far as I could tell nothing currently produced
> null, but if it did, what behavior would we expect? My guess is that we
> would want null to follow the opposite path and close the connection.
> Perhaps it would be helpful if we handle null separately while logging a
> warning if one is unexpectedly received?
>
> -ck
>
> On Sun, Jul 5, 2020, at 19:19, Gary Gregory wrote:
> > If the input is a null result, you will get an NPE where you did not
> before
> > this change. A safer bet would be Boolean.FALSE.equals(result).
> >
> > Gary
> >
> > On Sun, Jul 5, 2020, 16:58 <ol...@apache.org> wrote:
> >
> > > This is an automated email from the ASF dual-hosted git repository.
> > >
> > > olegk pushed a commit to branch master
> > > in repository
> > > https://gitbox.apache.org/repos/asf/httpcomponents-client.git
> > >
> > >
> > > The following commit(s) were added to refs/heads/master by this push:
> > > new 1572f55 HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager
> > > boxed primitive reference equality
> > > 1572f55 is described below
> > >
> > > commit 1572f5568730362aa4f5bdf052503db52c643bab
> > > Author: Carter Kozak <ck...@apache.org>
> > > AuthorDate: Sun Jul 5 13:10:25 2020 -0400
> > >
> > > HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager boxed
> > > primitive reference equality
> > > ---
> > > .../hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java |
> > > 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git
> > >
> a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> > >
> b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> > > index cd0e6b0..80d05c2 100644
> > > ---
> > >
> a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> > > +++
> > >
> b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> > > @@ -252,7 +252,7 @@ public class PoolingAsyncClientConnectionManager
> > > implements AsyncClientConnectio
> > >
> > > @Override
> > > public void execute(final Boolean
> > > result) {
> > > - if (result == Boolean.FALSE) {
> > > + if (!result) {
> > > if (log.isDebugEnabled()) {
> > > log.debug("{}: connection
> > > {} is stale", id, ConnPoolSupport.getId(connection));
> > > }
> > >
> > >
> >
>

Re: [httpcomponents-client] branch master updated: HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager boxed primitive reference equality

Posted by Carter Kozak <ck...@ckozak.net>.
Hi Gary,

Is null a valid input? As far as I could tell nothing currently produced null, but if it did, what behavior would we expect? My guess is that we would want null to follow the opposite path and close the connection. Perhaps it would be helpful if we handle null separately while logging a warning if one is unexpectedly received?

-ck

On Sun, Jul 5, 2020, at 19:19, Gary Gregory wrote:
> If the input is a null result, you will get an NPE where you did not before
> this change. A safer bet would be Boolean.FALSE.equals(result).
> 
> Gary
> 
> On Sun, Jul 5, 2020, 16:58 <ol...@apache.org> wrote:
> 
> > This is an automated email from the ASF dual-hosted git repository.
> >
> > olegk pushed a commit to branch master
> > in repository
> > https://gitbox.apache.org/repos/asf/httpcomponents-client.git
> >
> >
> > The following commit(s) were added to refs/heads/master by this push:
> > new 1572f55 HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager
> > boxed primitive reference equality
> > 1572f55 is described below
> >
> > commit 1572f5568730362aa4f5bdf052503db52c643bab
> > Author: Carter Kozak <ck...@apache.org>
> > AuthorDate: Sun Jul 5 13:10:25 2020 -0400
> >
> > HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager boxed
> > primitive reference equality
> > ---
> > .../hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java |
> > 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git
> > a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> > b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> > index cd0e6b0..80d05c2 100644
> > ---
> > a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> > +++
> > b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> > @@ -252,7 +252,7 @@ public class PoolingAsyncClientConnectionManager
> > implements AsyncClientConnectio
> >
> > @Override
> > public void execute(final Boolean
> > result) {
> > - if (result == Boolean.FALSE) {
> > + if (!result) {
> > if (log.isDebugEnabled()) {
> > log.debug("{}: connection
> > {} is stale", id, ConnPoolSupport.getId(connection));
> > }
> >
> >
> 

Re: [httpcomponents-client] branch master updated: HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager boxed primitive reference equality

Posted by Gary Gregory <ga...@gmail.com>.
If the input is a null result, you will get an NPE where you did not before
this change.  A safer bet would be Boolean.FALSE.equals(result).

Gary

On Sun, Jul 5, 2020, 16:58 <ol...@apache.org> wrote:

> This is an automated email from the ASF dual-hosted git repository.
>
> olegk pushed a commit to branch master
> in repository
> https://gitbox.apache.org/repos/asf/httpcomponents-client.git
>
>
> The following commit(s) were added to refs/heads/master by this push:
>      new 1572f55  HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager
> boxed primitive reference equality
> 1572f55 is described below
>
> commit 1572f5568730362aa4f5bdf052503db52c643bab
> Author: Carter Kozak <ck...@apache.org>
> AuthorDate: Sun Jul 5 13:10:25 2020 -0400
>
>     HTTPCLIENT-2097: Fix PoolingAsyncClientConnectionManager boxed
> primitive reference equality
> ---
>  .../hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java   |
> 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git
> a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> index cd0e6b0..80d05c2 100644
> ---
> a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> +++
> b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java
> @@ -252,7 +252,7 @@ public class PoolingAsyncClientConnectionManager
> implements AsyncClientConnectio
>
>                                      @Override
>                                      public void execute(final Boolean
> result) {
> -                                        if (result == Boolean.FALSE) {
> +                                        if (!result) {
>                                              if (log.isDebugEnabled()) {
>                                                  log.debug("{}: connection
> {} is stale", id, ConnPoolSupport.getId(connection));
>                                              }
>
>