Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
<sonar-java-frontend.version>8.2.0.36672</sonar-java-frontend.version>
<sonar-orchestrator.version>5.6.0.2578</sonar-orchestrator.version>

<errorprone.version>2.39.0</errorprone.version>
<errorprone.version>2.42.0</errorprone.version>
<nullaway.version>0.12.7</nullaway.version>
<errorprone.slf4j.version>0.1.29</errorprone.slf4j.version>
<picnic.errorprone.support.version>0.23.0</picnic.errorprone.support.version>
<picnic.errorprone.support.version>0.25.0</picnic.errorprone.support.version>

<protobuf.version>4.30.1</protobuf.version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public final class ErrorAwayRulesMapping {
public static final String ERRORPRONE_SLF4J_REPOSITORY = "errorprone-slf4j";
public static final String PICNIC_REPOSITORY = "picnic-errorprone";

public static final int ERRORPRONE_REPOSITORY_RULES_COUNT = 471;
public static final int ERRORPRONE_REPOSITORY_RULES_COUNT = 475;
public static final int NULLAWAY_REPOSITORY_RULES_COUNT = 1;
public static final int ERRORPRONE_SLF4J_REPOSITORY_RULES_COUNT = 8;
public static final int PICNIC_REPOSITORY_RULES_COUNT = 45;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,6 @@ if (set.contains(hi)) {
}
```

[equalstester]: https://static.javadoc.io/com.google.guava/guava-testlib/19.0/com/google/common/testing/EqualsTester.html
[objeq]: https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)
[av]: https://github.com/google/auto/blob/master/value/userguide/index.md
[equalstester]: https://www.javadoc.io/doc/com.google.guava/guava-testlib/latest/com/google/common/testing/EqualsTester.html
[objeq]: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)
[av]: https://github.com/google/auto/blob/main/value/userguide/index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
If a test subject and the argument to `isEqualTo` are the same instance (e.g.
`assertThat(x).isEqualTo(x)`), then the assertion will always pass. Truth
implements `isEqualTo` using [`Objects#equal`] , which tests its arguments for
reference equality and returns true without calling `equals()` if both arguments
are the same instance.
When using Truth, if a test subject and the argument to `isEqualTo` are the same
instance (for example `assertThat(x).isEqualTo(x)`), then the assertion will
always pass. Truth implements `isEqualTo` using [`Objects#equal`] , which tests
its arguments for reference equality and returns true without calling `equals()`
if both arguments are the same instance.

JUnit's `assertEquals` (and similar) methods are implemented in terms of
`Object#equals`. However, this is not explicitly documented, so isn't a
Expand All @@ -14,4 +14,8 @@ To test the implementation of an `equals` method, use
[Guava's EqualsTester][javadoc], or explicitly call `equals` as part of the
test.

In our experience, `assertThat(x).isEqualTo(x)` and similar are *more likely to
be typos* than assertions about an `equals` method. This alone is sufficient
motivation to choose a dedicated approach for testing `equals` implementations.

[javadoc]: https://static.javadoc.io/com.google.guava/guava-testlib/21.0/com/google/common/testing/EqualsTester.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Null-checking `System.console()` is not a reliable way to detect if the console
is connected to a terminal.

See
See JDK 22
[Release Note: JLine As The Default Console Provider](https://bugs.openjdk.org/browse/JDK-8309155):

> `System.console()` now returns a `Console` object when the standard streams
Expand All @@ -15,6 +15,18 @@ See
> A new method `Console.isTerminal()` has been added to test if console is
> connected to a terminal.
and JDK 25 release note
[Release Note: Default Console Implementation No Longer Based On JLine](https://bugs.openjdk.org/browse/JDK-8351576):

> The default Console obtained via `System.console()` is no longer based on
> JLine. Since JDK 20, the JDK has included a JLine-based Console
> implementation, offering a richer user experience and better support for
> virtual terminal environments, such as IDEs. This implementation was initially
> opt-in via a system property in JDK 20 and JDK 21 and became the default in
> JDK 22. However, maintaining the JLine-based Console proved challenging. As a
> result, in JDK 25, it has reverted to being opt-in, as it was in JDK 20 and
> JDK 21.
To prepare for this change while remaining compatible with JDK versions prior to
JDK 22, consider using reflection to call `Console#isTerminal` on JDK versions
that support it:
Expand All @@ -23,7 +35,7 @@ that support it:
@SuppressWarnings("SystemConsoleNull") // https://errorprone.info/bugpattern/SystemConsoleNull
private static boolean systemConsoleIsTerminal() {
Console systemConsole = System.console();
if (Runtime.version().feature() < 22) {
if (Runtime.version().feature() < 22 || systemConsole == null) {
return systemConsole != null;
}
try {
Expand Down