Skip to content

Commit 2c98c1b

Browse files
committed
Relaxed assertion in NotificationPublisherAwareLazyTargetSource
Issue: SPR-17592
1 parent 7b9c30f commit 2c98c1b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -939,9 +939,9 @@ private boolean isBeanDefinitionAbstract(ListableBeanFactory beanFactory, String
939939
* {@link org.springframework.jmx.export.notification.NotificationPublisher} is injected.
940940
*/
941941
private void injectNotificationPublisherIfNecessary(
942-
Object managedResource, ModelMBean modelMBean, ObjectName objectName) {
942+
Object managedResource, @Nullable ModelMBean modelMBean, @Nullable ObjectName objectName) {
943943

944-
if (managedResource instanceof NotificationPublisherAware) {
944+
if (managedResource instanceof NotificationPublisherAware && modelMBean != null && objectName != null) {
945945
((NotificationPublisherAware) managedResource).setNotificationPublisher(
946946
new ModelMBeanNotificationPublisher(modelMBean, objectName, managedResource));
947947
}
@@ -1112,7 +1112,6 @@ public Object getTarget() {
11121112

11131113
@Override
11141114
protected void postProcessTargetObject(Object targetObject) {
1115-
Assert.state(this.modelMBean != null && this.objectName != null, "Not initialized");
11161115
injectNotificationPublisherIfNecessary(targetObject, this.modelMBean, this.objectName);
11171116
}
11181117
}

0 commit comments

Comments
 (0)