Hello.

During investigation of IDEA inspections I found suspicious code in a method
com.sun.jmx.remote.internal.ServerNotifForwarder#removeNotificationListener
https://github.com/openjdk/jdk/blob/master/src/java.management/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java#L167

Exception re = null;
for (int i = 0 ; i < listenerIDs.length ; i++) {
    try {
        removeNotificationListener(name, listenerIDs[i]);
    } catch (Exception e) {
        // Give back the first exception
        //
        if (re != null) {
            re = e;
        }
    }
}
if (re != null) {
    throw re;
}

Variable 're' set initially to 'null', but then in a catch block it
checked to be '!= null'.
As you can see this condition can never be true. And exceptions from
inner calls are not propagated as expected.
It seems that it should check if (re == null) inside the catch block.


Andrey Turbanov

Reply via email to