Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE in PGXAConnection$ConnectionHandler.invoke() of .equals(null) #1365

Merged
merged 1 commit into from Dec 8, 2018

Conversation

Projects
None yet
3 participants
@ringerc
Copy link
Member

commented Dec 8, 2018

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.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Does mvn checkstyle:check pass ?

Changes to Existing Features:

  • Does this break existing behaviour? If so please explain.
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?
@ringerc

This comment has been minimized.

Copy link
Member Author

commented Dec 8, 2018

The link to CONTRIBUTING in the checklist is broken by the way. It should probably point to https://github.com/pgjdbc/pgjdbc/blob/master/CONTRIBUTING.md.

@ringerc

This comment has been minimized.

Copy link
Member Author

commented Dec 8, 2018

I'm on a flight so I can't do a build right now, but the change is trivial. The issue was originally observed in 9.4-1201-jdbc41 but is still present in master.

@ringerc ringerc force-pushed the ringerc:dev/connectionhandler-npe-equals branch 2 times, most recently from f9b7163 to 431f40b Dec 8, 2018

fix: NPE in PGXAConnection$ConnectionHandler.invoke() of .equals(null)
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.

@ringerc ringerc force-pushed the ringerc:dev/connectionhandler-npe-equals branch from 431f40b to 10e3daa Dec 8, 2018

@codecov-io

This comment has been minimized.

Copy link

commented Dec 8, 2018

Codecov Report

Merging #1365 into master will increase coverage by <.01%.
The diff coverage is 50%.

@@             Coverage Diff              @@
##             master    #1365      +/-   ##
============================================
+ Coverage     68.68%   68.69%   +<.01%     
  Complexity     3893     3893              
============================================
  Files           179      179              
  Lines         16398    16398              
  Branches       2670     2670              
============================================
+ Hits          11263    11264       +1     
  Misses         3886     3886              
+ Partials       1249     1248       -1

@davecramer davecramer merged commit cea5231 into pgjdbc:master Dec 8, 2018

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
codecov/project 68.69% (+<.01%) compared to 7be21fc
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.