[pgjdbc/pgjdbc] cea523: fix: NPE in PGXAConnection$ConnectionHandler.invok...

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: pgsql-jdbc(at)lists(dot)postgresql(dot)org
Subject: [pgjdbc/pgjdbc] cea523: fix: NPE in PGXAConnection$ConnectionHandler.invok...
Date: 2018-12-08 10:44:28
Message-ID: 5c0ba08c18c2c_7e872b13463a45747716@hookshot-fe-88eb02d.cp1-iad.github.net.mail
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Branch: refs/heads/master
Home: https://github.com/pgjdbc/pgjdbc
Commit: cea5231ba794c362cbd5285b299ba3f82ad29e73
https://github.com/pgjdbc/pgjdbc/commit/cea5231ba794c362cbd5285b299ba3f82ad29e73
Author: Craig Ringer <craig(at)2ndquadrant(dot)com>
Date: 2018-12-08 (Sat, 08 Dec 2018)

Changed paths:
M pgjdbc/src/main/java/org/postgresql/xa/PGXAConnection.java
M pgjdbc/src/test/java/org/postgresql/test/xa/XADataSourceTest.java

Log Message:
-----------
fix: NPE in PGXAConnection$ConnectionHandler.invoke() of .equals(null) (#1365)

The PGXAConnection inner class call-filtering proxy ConnectionHandler
special cases calls to equals() by testing if the argument is itself
a proxy that should be unwrapped.

However it fails to test if the argument is null before calling getClass()
on it, resulting in an NPE like

java.lang.NullPointerException: null
at org.postgresql.xa.PGXAConnection$ConnectionHandler.invoke(PGXAConnection.java:139)

Fix by testing for null. While we're at it, also defensively check to ensure
there's exactly one argument to .equals. It's not sensible to pass more and
will error later anyway.

**NOTE:** This service has been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

Functionality will be removed from GitHub.com on January 31st, 2019.

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2018-12-08 10:46:16 [pgjdbc/pgjdbc] 467855: Update pull_request_template.md
Previous Message Vladimir Sitnikov 2018-12-08 10:43:44 [pgjdbc/pgjdbc] cdfd49: chore: use openjdk7 to boostrap Travis CI images f...