mirror of https://github.com/apache/nifi.git
NIFI-12025: Fixed duplicated bulletin messages (#7670)
This commit is contained in:
parent
1449325027
commit
6cffc78ad2
|
@ -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);
|
||||
|
|
|
@ -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<>();
|
||||
|
||||
|
|
Loading…
Reference in New Issue