diff --git a/libjava/classpath/ChangeLog.gcj b/libjava/classpath/ChangeLog.gcj index 4aac14f38ab..a4faec8c89b 100644 --- a/libjava/classpath/ChangeLog.gcj +++ b/libjava/classpath/ChangeLog.gcj @@ -1,3 +1,10 @@ +2007-02-15 Gary Benson + + * gnu/javax/management/Server.java + (registerMBean): Always register objects that implement the + MBeanRegistration interface, and check the name returned by + preRegister before using it. + 2007-02-15 Gary Benson * javax/management/ObjectName.java: diff --git a/libjava/classpath/gnu/javax/management/Server.java b/libjava/classpath/gnu/javax/management/Server.java index 5501b4af7c0..aa39c75ad46 100644 --- a/libjava/classpath/gnu/javax/management/Server.java +++ b/libjava/classpath/gnu/javax/management/Server.java @@ -1657,19 +1657,27 @@ public class Server MBeanRegistration register = null; if (obj instanceof MBeanRegistration) register = (MBeanRegistration) obj; - if (name == null) + if (name == null && register == null) + { + RuntimeException e = + new IllegalArgumentException("The name was null and " + + "the bean does not implement " + + "MBeanRegistration."); + throw new RuntimeOperationsException(e); + } + if (register != null) { - if (register == null) - { - RuntimeException e = - new IllegalArgumentException("The name was null and " + - "the bean does not implement " + - "MBeanRegistration."); - throw new RuntimeOperationsException(e); - } try { - name = register.preRegister(this, null); + name = register.preRegister(this, name); + if (name == null) + { + RuntimeException e = + new NullPointerException("The name returned by " + + "MBeanRegistration.preRegister() " + + "was null"); + throw e; + } if (sm != null) sm.checkPermission(new MBeanPermission(className, null, name, "registerMBean")); diff --git a/libjava/classpath/lib/gnu/javax/management/Server$ServerInfo.class b/libjava/classpath/lib/gnu/javax/management/Server$ServerInfo.class index 644d5a40574..08402446059 100644 Binary files a/libjava/classpath/lib/gnu/javax/management/Server$ServerInfo.class and b/libjava/classpath/lib/gnu/javax/management/Server$ServerInfo.class differ diff --git a/libjava/classpath/lib/gnu/javax/management/Server$ServerInputStream.class b/libjava/classpath/lib/gnu/javax/management/Server$ServerInputStream.class index 536ac420c81..134351e7b96 100644 Binary files a/libjava/classpath/lib/gnu/javax/management/Server$ServerInputStream.class and b/libjava/classpath/lib/gnu/javax/management/Server$ServerInputStream.class differ diff --git a/libjava/classpath/lib/gnu/javax/management/Server$ServerNotificationListener.class b/libjava/classpath/lib/gnu/javax/management/Server$ServerNotificationListener.class index 769500cada3..dd98c5beb34 100644 Binary files a/libjava/classpath/lib/gnu/javax/management/Server$ServerNotificationListener.class and b/libjava/classpath/lib/gnu/javax/management/Server$ServerNotificationListener.class differ diff --git a/libjava/classpath/lib/gnu/javax/management/Server.class b/libjava/classpath/lib/gnu/javax/management/Server.class index 54552f00585..41154ad8bf3 100644 Binary files a/libjava/classpath/lib/gnu/javax/management/Server.class and b/libjava/classpath/lib/gnu/javax/management/Server.class differ