This commit is contained in:
Phillip Webb
2025-01-13 12:11:37 -08:00
parent 87a485f5da
commit 59bcaaf7c0
3 changed files with 9 additions and 8 deletions

View File

@@ -111,6 +111,12 @@ public class ProcessInfo {
}
}
@SuppressWarnings("unchecked")
private <T> T invokeMethod(Class<?> mxbeanClass, Object mxbean, String name) throws ReflectiveOperationException {
Method method = mxbeanClass.getMethod(name);
return (T) method.invoke(mxbean);
}
public long getPid() {
return this.pid;
}
@@ -123,12 +129,6 @@ public class ProcessInfo {
return this.owner;
}
@SuppressWarnings("unchecked")
private <T> T invokeMethod(Class<?> mxbeanClass, Object mxbean, String name) throws ReflectiveOperationException {
Method method = mxbeanClass.getMethod(name);
return (T) method.invoke(mxbean);
}
/**
* Virtual threads information.
*

View File

@@ -495,8 +495,7 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF
FilteringStatusListener listener = new FilteringStatusListener(new OnErrorConsoleStatusListener(),
Status.ERROR);
listener.setContext(context);
boolean effectivelyAdded = context.getStatusManager().add(listener);
if (effectivelyAdded) {
if (context.getStatusManager().add(listener)) {
listener.start();
}
}

View File

@@ -678,10 +678,12 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
assertThat(statusListener).hasFieldOrPropertyWithValue("levelThreshold", Status.ERROR);
assertThat(statusListener).extracting("delegate").isInstanceOf(OnErrorConsoleStatusListener.class);
AppenderBase<ILoggingEvent> appender = new AppenderBase<>() {
@Override
protected void append(ILoggingEvent eventObject) {
throw new IllegalStateException("Fail to append");
}
};
this.logger.addAppender(appender);
appender.setContext(loggerContext);