[AMQ-9258] Update kahadb corruption test to account for new fix from AMQ-9254 (#1007)

This commit is contained in:
Matt Pavlovich 2023-05-18 11:29:01 -05:00 committed by GitHub
parent 0a042964c8
commit cfbea60d6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
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;
@ -239,14 +240,20 @@ public class JournalCorruptionEofIndexRecoveryTest {
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);
}
}
@ -263,6 +270,8 @@ public class JournalCorruptionEofIndexRecoveryTest {
}
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());
}