Skip to content

Commit

Permalink
[AMQ-9258] Update kahadb corruption test to account for new fix from …
Browse files Browse the repository at this point in the history
…AMQ-9254 (apache#1007)
  • Loading branch information
mattrpav authored and NikitaShupletsov committed Sep 1, 2023
1 parent df07079 commit cecc2d9
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -239,14 +240,20 @@ public void testRecoveryAfterCorruptionMetadataLocation() throws Exception {
final var appender = new AbstractAppender("testAppender", new AbstractFilter() {}, new MessageLayout(), false, new Property[0]) {
@Override
public void append(LogEvent event) {
/**
* NOTE: As of JDK v11.0.19 RandomAccessFile throws a messageless EOFException when read fails
*
* throw new EOFException();
*/
if (event != null
&& event.getLevel() == Level.WARN
&& event.getMessage() != null
&& event.getMessage().getFormattedMessage() != null
&& event.getMessage().getFormattedMessage().contains("Cannot recover message audit")
&& event.getThrown() != null
&& event.getThrown().getLocalizedMessage() != null
&& event.getThrown().getLocalizedMessage().contains("Invalid location size")) {
&& event.getThrown() instanceof EOFException
&& event.getThrown().getMessage() == null) {

trappedExpectedLogMessage.set(true);
}
}
Expand All @@ -263,6 +270,8 @@ public void append(LogEvent event) {
}

assertEquals("no missing message", 50, broker.getAdminView().getTotalMessageCount());
assertEquals("Drain", 50, drainQueue(50));
assertEquals("no problem draining messages", 0, broker.getAdminView().getTotalMessageCount());
assertTrue("Did replay records on invalid location size", trappedExpectedLogMessage.get());
}

Expand Down

0 comments on commit cecc2d9

Please sign in to comment.