lhotari commented on code in PR #25098:
URL: https://github.com/apache/pulsar/pull/25098#discussion_r2639009804


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesServiceTest.java:
##########
@@ -480,18 +476,12 @@ public void 
testCreateNamespaceEventsSystemTopicFactoryException() throws Except
     @Test
     public void 
testPrepareInitPoliciesCacheAsyncThrowExceptionAfterCreateReader() throws 
Exception {
         // catch the log output in SystemTopicBasedTopicPoliciesService
-        Logger logger = (Logger) 
LogManager.getLogger(SystemTopicBasedTopicPoliciesService.class);
-        List<String> logMessages = new ArrayList<>();
-        AbstractAppender appender = new AbstractAppender("TestAppender", null, 
null) {
-            @Override
-            public void append(LogEvent event) {
-                logMessages.add(event.getMessage().getFormattedMessage());
-            }
-        };
-        appender.start();
-        logger.addAppender(appender);
+        @Cleanup
+        TestLogAppender testLogAppender =
+                
TestLogAppender.create(Optional.of("SystemTopicBasedTopicPoliciesService"));

Review Comment:
   That would work, but please modify `TestLogAppender`and add a new method 
there (`.create(Class<?> loggerNameClass)`). That way it will be cleaner. 
`TestLogAppender` can be improved in PRs when there are new use cases for 
improvements.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to