Copilot commented on code in PR #8137:
URL: https://github.com/apache/incubator-seata/pull/8137#discussion_r3471700925
##########
server/src/test/java/org/apache/seata/server/logging/AppenderTest.java:
##########
@@ -24,33 +24,37 @@
import org.apache.seata.server.BaseSpringBootTest;
import org.apache.seata.server.logging.logback.appender.MetricLogbackAppender;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.slf4j.impl.StaticLoggerBinder;
+import org.slf4j.LoggerFactory;
+import org.springframework.test.context.TestPropertySource;
import java.lang.reflect.Field;
import java.util.Iterator;
+@TestPropertySource(
+ properties = {
+ "logging.extend.logstash-appender.enabled=true",
+ "logging.extend.kafka-appender.enabled=true",
+ "logging.extend.kafka-appender.topic=test",
+ "logging.extend.metric-appender.enabled=true"
+ })
public class AppenderTest extends BaseSpringBootTest {
- @BeforeAll
- public static void init() {
- System.setProperty("logging.extend.logstash-appender.enabled", "true");
- System.setProperty("logging.extend.kafka-appender.enabled", "true");
- System.setProperty("logging.extend.kafka-appender.topic", "test");
- System.setProperty("logging.extend.metric-appender.enabled", "true");
- }
-
@Test
public void testAppenderEnabled() {
- LoggerContext lc = (LoggerContext)
StaticLoggerBinder.getSingleton().getLoggerFactory();
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
Iterator<Appender<ILoggingEvent>> appenderIterator =
lc.getLogger("ROOT").iteratorForAppenders();
+ boolean kafkaFound = false;
+ boolean metricFound = false;
+ boolean logstashFound = false;
+
while (appenderIterator.hasNext()) {
Appender<ILoggingEvent> appender = appenderIterator.next();
if (appender.getName().equals("KAFKA")) {
KafkaAppender<ILoggingEvent> kafkaAppender =
(KafkaAppender<ILoggingEvent>) appender;
+ kafkaFound = true;
Review Comment:
This cast happens before any type check, so a misconfigured appender named
"KAFKA" would fail the test with a `ClassCastException` rather than a clear
assertion failure. Add an `assertInstanceOf` (or `instanceof` guard) before the
cast to make failures deterministic and easier to diagnose.
##########
changes/en-us/2.x.md:
##########
@@ -30,6 +30,7 @@ Add changes here for all PR submitted to the 2.x branch.
### optimize:
+- [[#8137](https://github.com/apache/incubator-seata/pull/8137)] server
modules:spring-boot upgrade to 4.0.6
Review Comment:
The English changelog entry uses a full-width colon (`:`) and the phrase
"server modules" reads awkwardly in this context. Using an ASCII colon and
singular "module" matches typical English changelog style.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]