Skip to content

Commit

Permalink
Fix NullPointerException in ConfigCommand.diffOptions()
Browse files Browse the repository at this point in the history
`@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.

Closes #13434.

PiperOrigin-RevId: 372635712
  • Loading branch information
moroten authored and copybara-github committed May 7, 2021
1 parent 329ff01 commit 8a42645
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -655,9 +656,13 @@ private static Table<String, String, Pair<Object, Object>> diffConfigurations(

private static Map<String, Pair<Object, Object>> diffOptions(
@Nullable FragmentOptionsForOutput options1, @Nullable FragmentOptionsForOutput options2) {
Set<String> optionNames1 =
options1 == null ? Collections.<String>emptySet() : options1.optionNames();
Set<String> optionNames2 =
options2 == null ? Collections.<String>emptySet() : options2.optionNames();
Map<String, Pair<Object, Object>> diffs = new HashMap<>();

for (String optionName : Sets.union(options1.optionNames(), options2.optionNames())) {
for (String optionName : Sets.union(optionNames1, optionNames2)) {
String value1 = options1 == null ? null : options1.getOption(optionName);
String value2 = options2 == null ? null : options2.getOption(optionName);

Expand Down

0 comments on commit 8a42645

Please sign in to comment.