Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

fix: prevent npe caused by missing parentheses #1198

Merged
merged 2 commits into from Oct 12, 2020

Conversation

Gerschtli
Copy link
Contributor

@Gerschtli Gerschtli commented Oct 2, 2020

Currently I can't set the log level lower than FINER because this library throws a NPE. The cause of this problem is a missing pair of parentheses.

This is the current snippet:

"enclosingMethod: " + callable.getClass().getEnclosingMethod() != null
  ? callable.getClass().getEnclosingMethod().getName()
  : ""

Which is equivalent to:

("enclosingMethod: " + callable.getClass().getEnclosingMethod()) != null
  ? callable.getClass().getEnclosingMethod().getName()
  : ""

This results in calling callable.getClass().getEnclosingMethod().getName() even if callable.getClass().getEnclosingMethod() is null.

Fixes #1198.

@Gerschtli Gerschtli requested a review from a team October 2, 2020 12:34
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 2, 2020
@codecov
Copy link

codecov bot commented Oct 2, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@88328eb). Click here to learn what that means.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1198   +/-   ##
=========================================
  Coverage          ?   79.18%           
  Complexity        ?     1199           
=========================================
  Files             ?      205           
  Lines             ?     5270           
  Branches          ?      436           
=========================================
  Hits              ?     4173           
  Misses            ?      924           
  Partials          ?      173           
Impacted Files Coverage Δ Complexity Δ
...m/google/api/gax/retrying/BasicRetryingFuture.java 93.13% <66.66%> (ø) 25.00 <0.00> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88328eb...783d53f. Read the comment docs.

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. This could use an issue and a test.

@Gerschtli
Copy link
Contributor Author

@elharo Hey, thank you for your feedback!

I can create an issue for this PR in a bit. For the tests: Unfortunately I don't understand what is going on in this class (and what it is for) so it would cost me several hours to set up a working test case for it (AFAICT there aren't any tests for this class yet). I think that would not be worth it. What do you think?

Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Fixes" without tests are too risky. If you don't have the time to write a test, please file an issue and close this PR. We'll triage and get to it when we can.

@Gerschtli Gerschtli force-pushed the fix-npe branch 2 times, most recently from b1390bc to af11f2d Compare October 5, 2020 22:10
@Gerschtli
Copy link
Contributor Author

Created an issue and a basic minimal test case for my fix. PTAL

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants