Skip to content

Commit 996a844

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Remove more copies of a workaround for an ancient Android bug.
(followup to cl/604677493) RELNOTES=n/a PiperOrigin-RevId: 609415936
1 parent a43223e commit 996a844

2 files changed

Lines changed: 2 additions & 30 deletions

File tree

core/src/main/java/com/google/common/truth/AssertionErrorWithFacts.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,12 @@
2929
final class AssertionErrorWithFacts extends AssertionError implements ErrorWithFacts {
3030
private final ImmutableList<Fact> facts;
3131

32-
/** Separate cause field, in case initCause() fails. */
33-
private final @Nullable Throwable cause;
34-
3532
AssertionErrorWithFacts(
3633
ImmutableList<String> messages, ImmutableList<Fact> facts, @Nullable Throwable cause) {
3734
super(makeMessage(messages, facts));
3835
this.facts = checkNotNull(facts);
3936

40-
this.cause = cause;
41-
try {
42-
initCause(cause);
43-
} catch (IllegalStateException alreadyInitializedBecauseOfHarmonyBug) {
44-
// See Truth.SimpleAssertionError.
45-
}
46-
}
47-
48-
@Override
49-
@SuppressWarnings("UnsynchronizedOverridesSynchronized")
50-
public @Nullable Throwable getCause() {
51-
return cause;
37+
initCause(cause);
5238
}
5339

5440
@Override

core/src/main/java/com/google/common/truth/Platform.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -165,33 +165,19 @@ private static ImmutableList<String> splitLines(String s) {
165165
abstract static class PlatformComparisonFailure extends ComparisonFailure {
166166
private final String message;
167167

168-
/** Separate cause field, in case initCause() fails. */
169-
private final @Nullable Throwable cause;
170-
171168
PlatformComparisonFailure(
172169
String message, String expected, String actual, @Nullable Throwable cause) {
173170
super(message, expected, actual);
174171
this.message = message;
175-
this.cause = cause;
176172

177-
try {
178-
initCause(cause);
179-
} catch (IllegalStateException alreadyInitializedBecauseOfHarmonyBug) {
180-
// See Truth.SimpleAssertionError.
181-
}
173+
initCause(cause);
182174
}
183175

184176
@Override
185177
public final String getMessage() {
186178
return message;
187179
}
188180

189-
@Override
190-
@SuppressWarnings("UnsynchronizedOverridesSynchronized")
191-
public final @Nullable Throwable getCause() {
192-
return cause;
193-
}
194-
195181
// To avoid printing the class name before the message.
196182
// TODO(cpovirk): Write a test that fails without this. Ditto for SimpleAssertionError.
197183
@Override

0 commit comments

Comments
 (0)