提交 93f7ec53 编写于 作者: J jbachorik

8009038: Improve JMX notification support

Summary: Disallowing access to mutable shared arrays
Reviewed-by: dfuchs, mchung, skoivu
上级 4a77202b
......@@ -64,6 +64,9 @@ package javax.management;
public class StandardEmitterMBean extends StandardMBean
implements NotificationEmitter {
private static final MBeanNotificationInfo[] NO_NOTIFICATION_INFO =
new MBeanNotificationInfo[0];
private final NotificationEmitter emitter;
private final MBeanNotificationInfo[] notificationInfo;
......@@ -99,11 +102,7 @@ public class StandardEmitterMBean extends StandardMBean
*/
public <T> StandardEmitterMBean(T implementation, Class<T> mbeanInterface,
NotificationEmitter emitter) {
super(implementation, mbeanInterface, false);
if (emitter == null)
throw new IllegalArgumentException("Null emitter");
this.emitter = emitter;
this.notificationInfo = emitter.getNotificationInfo();
this(implementation, mbeanInterface, false, emitter);
}
/**
......@@ -148,7 +147,12 @@ public class StandardEmitterMBean extends StandardMBean
if (emitter == null)
throw new IllegalArgumentException("Null emitter");
this.emitter = emitter;
this.notificationInfo = emitter.getNotificationInfo();
MBeanNotificationInfo[] infos = emitter.getNotificationInfo();
if (infos == null || infos.length == 0) {
this.notificationInfo = NO_NOTIFICATION_INFO;
} else {
this.notificationInfo = infos.clone();
}
}
/**
......@@ -184,11 +188,7 @@ public class StandardEmitterMBean extends StandardMBean
*/
protected StandardEmitterMBean(Class<?> mbeanInterface,
NotificationEmitter emitter) {
super(mbeanInterface, false);
if (emitter == null)
throw new IllegalArgumentException("Null emitter");
this.emitter = emitter;
this.notificationInfo = emitter.getNotificationInfo();
this(mbeanInterface, false, emitter);
}
/**
......@@ -231,7 +231,12 @@ public class StandardEmitterMBean extends StandardMBean
if (emitter == null)
throw new IllegalArgumentException("Null emitter");
this.emitter = emitter;
this.notificationInfo = emitter.getNotificationInfo();
MBeanNotificationInfo[] infos = emitter.getNotificationInfo();
if (infos == null || infos.length == 0) {
this.notificationInfo = NO_NOTIFICATION_INFO;
} else {
this.notificationInfo = infos.clone();
}
}
public void removeNotificationListener(NotificationListener listener)
......@@ -253,7 +258,11 @@ public class StandardEmitterMBean extends StandardMBean
}
public MBeanNotificationInfo[] getNotificationInfo() {
return notificationInfo;
if (notificationInfo.length == 0) {
return notificationInfo;
} else {
return notificationInfo.clone();
}
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册