Skip to content

Commit 3c72073

Browse files
committed
Internal: when corruption strikes, don't create exceptions with circular references
Closes #8331
1 parent a6d7742 commit 3c72073

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,10 @@ public void run() {
230230
if ((corruptIndexException = ExceptionsHelper.unwrap(e, CorruptIndexException.class)) != null) {
231231
if (store.checkIntegrity(md) == false) { // we are corrupted on the primary -- fail!
232232
logger.warn("{} Corrupted file detected {} checksum mismatch", shard.shardId(), md);
233-
CorruptIndexException current = corruptedEngine.get();
234-
if (current != null || corruptedEngine.compareAndSet(null, corruptIndexException)) {
235-
current = corruptedEngine.get();
236-
assert current != null;
237-
current.addSuppressed(e);
233+
if (corruptedEngine.compareAndSet(null, corruptIndexException) == false) {
234+
// if we are not the first exception, add ourselves as suppressed to the main one:
235+
corruptedEngine.get().addSuppressed(e);
238236
}
239-
240237
} else { // corruption has happened on the way to replica
241238
RemoteTransportException exception = new RemoteTransportException("File corruption occured on recovery but checksums are ok", null);
242239
exception.addSuppressed(e);

0 commit comments

Comments
 (0)