NIFI-12025: Fixed duplicated bulletin messages (#7670)

This commit is contained in:
Peter Turcsanyi 2023-09-08 19:16:44 +02:00 committed by GitHub
parent 1449325027
commit 6cffc78ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -127,6 +127,7 @@ public class StandardLogRepository implements LogRepository {
try {
final Set<LogObserver> observersCopy = new HashSet<>(observers);
observers.clear();
observersPerLogLevel.clear();
for (final LogObserver observer : observersCopy) {
addObserver(level, observer);

View File

@ -66,11 +66,27 @@ public class TestStandardLogRepository {
MockFlowFile mockFlowFile1 = new MockFlowFile(1L);
MockFlowFile mockFlowFile2 = new MockFlowFile(2L);
repo.addLogMessage(LogLevel.INFO, "Testing {} {} flowfiles are not being shown in exception message", new Object[]{mockFlowFile1, mockFlowFile2});
repo.addLogMessage(LogLevel.INFO, "Testing {} {} FlowFiles are not being shown in exception message", new Object[]{mockFlowFile1, mockFlowFile2});
assertNull(observer.getMessages().get(0).getFlowFileUuid());
}
@Test
public void testLogRepositoryAfterLogLevelChange() {
StandardLogRepository repo = new StandardLogRepository();
MockLogObserver observer = new MockLogObserver();
repo.addObserver(LogLevel.ERROR, observer);
repo.setObservationLevel(LogLevel.ERROR);
IOException exception = new IOException("exception");
repo.addLogMessage(LogLevel.ERROR, "Testing {} to get exception message <{}>", new Object[]{observer.getClass().getName(), exception});
assertEquals(1, observer.getMessages().size());
assertEquals("Testing org.apache.nifi.logging.TestStandardLogRepository$MockLogObserver to get exception message <exception>", observer.getMessages().get(0).getMessage());
}
private static class MockLogObserver implements LogObserver {
private final List<LogMessage> messages = new ArrayList<>();