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: prevent npe caused by missing parentheses #1198

Merged
merged 2 commits into from Oct 12, 2020
Merged

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 Oct 2, 2020
@google-cla google-cla bot added the cla: yes label Oct 2, 2020
@codecov
Copy link

@codecov 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

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

@Gerschtli
Copy link
Contributor Author

@Gerschtli Gerschtli commented Oct 5, 2020

@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

"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 Oct 5, 2020
@Gerschtli
Copy link
Contributor Author

@Gerschtli Gerschtli commented Oct 5, 2020

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

elharo
elharo approved these changes Oct 12, 2020
@elharo elharo merged commit b856351 into googleapis:master Oct 12, 2020
8 checks passed
@Gerschtli Gerschtli deleted the fix-npe branch Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants