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 NullPointerException in ConfigCommand.diffOptions() #13434

Conversation

moroten
Copy link
Contributor

@moroten moroten commented May 6, 2021

@Nullable FragmentOptionsForOutput options1 should be checked for being null before use. bazel config can otherwise crash, e.g. as the test configuration nowadays is trimmed.

`@Nullable FragmentOptionsForOutput options1` should be checked for
being null before use. `bazel config` can otherwise crash, e.g. as the
test configuration nowadays is trimmed.
@google-cla google-cla bot added the cla: yes label May 6, 2021
@sventiffe sventiffe requested a review from gregestren May 7, 2021 11:52
@gregestren
Copy link
Contributor

@sdtwigg

Interesting observation. Does this apply to both printing and diffing a configuration? i.e. both bazel config foo and bazel config foo bar?

@moroten
Copy link
Contributor Author

moroten commented May 7, 2021

I only tried bazel config foo bar for diffing and is now running my patched version ;)

@gregestren
Copy link
Contributor

gregestren commented May 7, 2021

Do you mind trying bazel config foo too for one of the trimmed configs?

I don't know how familiar you are with the config command, but running it with no options shows all configs in the bazel process.

@moroten
Copy link
Contributor Author

moroten commented May 7, 2021

bazel config, bazel config foo and bazel config bar works, but bazel config foo bar crashes.

@gregestren
Copy link
Contributor

I'm sorry, but to be clear, you mean on the unpatched version? If all of those work with your patch that's all I'm asking for. :)

@moroten
Copy link
Contributor Author

moroten commented May 7, 2021

Sorry for being unclear. I've now also run all four variants with both patched and unpatched version.
Unpatched version: bazel config, bazel config foo and bazel config bar works, but bazel config foo bar crashes.
Patched version: bazel config, bazel config foo, bazel config bar and bazel config foo bar all works.

Instead of crashing with NullPointerException, the patched version outputs:

Displaying diff between configs a8aaf8d028e4c9ba3ee0518043a87e8f514729d15df0ef0dd0f49bd0918cf512 and 9029ef98aed4ba5e0c34310cde7197acbdcf8a841fc6d5a90ca6303fd6d78a87
FragmentOptions com.google.devtools.build.lib.analysis.test.TestConfiguration$TestOptions {
  cache_test_results: null, AUTO
  coverage_report_generator: null, @bazel_tools//tools/test:coverage_report_generator
  coverage_support: null, @bazel_tools//tools/test:coverage_support
  experimental_cancel_concurrent_tests: null, false
  experimental_fetch_all_coverage_outputs: null, false
...
  trim_test_configuration: null, true
}

Copy link
Contributor

@gregestren gregestren left a comment

Choose a reason for hiding this comment

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

Thanks so much!

@bazel-io bazel-io closed this in 8a42645 May 7, 2021
@moroten moroten deleted the diff-options-null-pointer-exception-fix branch May 8, 2021 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants