@@ -197,7 +197,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
197197	 * Bean instances are typically linked in through bean references. 
198198	 * Bean names will be resolved as beans in the current factory, respecting 
199199	 * lazy-init markers (that is, not triggering initialization of such beans). 
200- 	 * @param beans Map with JMX names as keys and bean instances or bean names 
200+ 	 * @param beans a  Map with JMX names as keys and bean instances or bean names 
201201	 * as values 
202202	 * @see #setNamingStrategy 
203203	 * @see org.springframework.jmx.export.naming.KeyNamingStrategy 
@@ -509,7 +509,7 @@ public void unregisterManagedResource(ObjectName objectName) {
509509	/** 
510510	 * Register the defined beans with the {@link MBeanServer}. 
511511	 * <p>Each bean is exposed to the {@code MBeanServer} via a 
512- 	 * {@code ModelMBean}. The actual implemetation  of the 
512+ 	 * {@code ModelMBean}. The actual implementation  of the 
513513	 * {@code ModelMBean} interface used depends on the implementation of 
514514	 * the {@code ModelMBeanProvider} interface that is configured. By 
515515	 * default the {@code RequiredModelMBean} class that is supplied with 
@@ -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		}
@@ -1029,7 +1029,7 @@ protected void onUnregister(ObjectName objectName) {
10291029	}
10301030
10311031
1032-      /** 
1032+ 	 /** 
10331033	 * Notifies all registered {@link MBeanExporterListener MBeanExporterListeners} of the 
10341034	 * registration of the MBean identified by the supplied {@link ObjectName}. 
10351035	 */ 
@@ -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