Skip to content

Bump Error Prone to 2.49.0 and fix new warnings#3030

Merged
eamonnmcmanus merged 2 commits into
google:mainfrom
Marcono1234:marcono1234/error-prone-update
Jun 1, 2026
Merged

Bump Error Prone to 2.49.0 and fix new warnings#3030
eamonnmcmanus merged 2 commits into
google:mainfrom
Marcono1234:marcono1234/error-prone-update

Conversation

@Marcono1234

Copy link
Copy Markdown
Contributor

Bumps Error Prone to 2.49.0 and fixes the new warnings it reports.

This should fix the build error of #3022.

The largest changes are:

  • Refactoring LinkedTreeMap to remove NATURAL_ORDER and related reference equality checks (first commit)
  • Extracting code out of assertThrows(...) calls
    Please let me know if you would prefer other local variable names (currently I mostly used "value" for the object to be serialized) or if you have any suggestions for changes.

Previously `NATURAL_ORDER` was never properly used, it was only checked using
reference equality but its `compare` method was not called at all.
Future Error Prone versions also warned about this reference equality check.

Therefore simplify the implementation by using `null` for natural order.
Comment on lines 75 to +76
/** See {@link AccessibleObject#canAccess(Object)} (Java >= 9) */
@SuppressWarnings("InvalidLink") // suppress Error Prone warning about link to Java 9 method

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Refers to the {@link AccessibleObject#canAccess(Object)} in the line above

Comment on lines -241 to +244
assertThrows(IllegalArgumentException.class, () -> writer.value(Float.valueOf(Float.NaN)));
assertThrows(IllegalArgumentException.class, () -> writer.value((Number) Float.NaN));

@Marcono1234 Marcono1234 May 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Used (Number) ... casts here to point out that the main purpose is to call the value(Number) overload instead of value(double) or value(float).

The previous code using Double.valueOf and Float.valueOf was achieving the same; but Error Prone reported AssertThrowsMinimizer warnings there.
(It still reports those warnings for (Number) ... though.)

Comment on lines +256 to +257
@Test
public void testStrictLazyNansAndInfinities() throws IOException {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Noticed that unlike JsonWriterTest the test here did not check LazilyParsedNumber, so I added this new method.

// Should contain entries in same order
assertThat(new ArrayList<>(entrySet)).isEqualTo(expectedEntrySet);

Map.Entry<String, JsonElement> dummyEntry = new SimpleEntry<>("c", new JsonPrimitive(3));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Used the name dummyEntry instead of entry because a few lines below there is already a local variable named entry.

Comment on lines -318 to +320
() -> {
runTest(
className,
c -> {
fail("Class should have been removed during shrinking: " + c);
});
});
() ->
runTest(
className, c -> fail("Class should have been removed during shrinking: " + c)));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Converted block -> { ... } to -> ....

Was reported by Error Prone AssertThrowsBlockToExpression.

@eamonnmcmanus eamonnmcmanus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is fantastic, thanks for doing it! I wasn't looking forward to fixing all those problems.

@eamonnmcmanus eamonnmcmanus merged commit 9eb61b3 into google:main Jun 1, 2026
20 checks passed
@Marcono1234 Marcono1234 deleted the marcono1234/error-prone-update branch June 1, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants