Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8332371

Better JMX interoperability with older JDKs, after removing Subject Delegation

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 23
    • core-svc
    • None
    • behavioral
    • minimal
    • Hide
      This fix slightly alters the fix that was pushed for JDK-8326666, in order to restore support for non-null arrays containing null subjects, which had been removed by JDK-8326666. Specifically, it makes JDKs more compatible, more interoperable.
      Show
      This fix slightly alters the fix that was pushed for JDK-8326666 , in order to restore support for non-null arrays containing null subjects, which had been removed by JDK-8326666 . Specifically, it makes JDKs more compatible, more interoperable.
    • Java API
    • SE

      Summary

      Make the javax.management.remote.rmi.RMIConnection method addNotificationListeners less strict about noticing attempted use of the removed Subject Delegation feature, to better interoperate with older JDKs. Specifically, only throw UnsupportedOperationException if a non-null Subject is specified, and tolerate the containing array parameter being non-null.

      Problem

      It is desirable and expected that JDKs of different versions can interoperate as much as possible, and use of JMX should be possible between different JDK versions.

      After Subject Delegation removal, JMX interoperability with older JDKs is limited when applications use the addNotificationListeners method. The older JDKs pass a delegation Subject, usually null, in an array. Later JDKs throw UnsupportedOperationException if the array itself is non-null. That was too strict: if the array contains no non-null Subjects, then it is not an attempt to use Subject Delegation, and should not be an error. The later JDK is unnecessarily incompatible with older JDKs.

      This change is to correct an oversight that meant an application running on an older JDK, could not connect to a more modern JDK where the Subject Delegation feature had been removed.

      Solution

      Make javax.management.remote.rmi.RMIConnection::addNotificationListeners less strict: accept a non-null delegatedSubjects array parameter. Only throw UnsupportedOperationException if the array contains any non-null Subject.

      Specification

      In javax.management.remote.rmi.RMIConnection, changes to the addNotificationListeners method are:

      Change @param delegationSubjects to only say that this array should be null, but a non-null array is accepted for compatibilty reasons, which must not contain any non-null entries.

      Change the @throws IllegalArgumentException to state the the two arrays, names and filters, must be the same size (not that the 3 arrays must be).

      Change @throws UnsupportedOperationException to happen if the delegationSubjects array is non-null and contains any non-null values (rather than only if the given array itself is non-null).

      PR: https://github.com/openjdk/jdk/pull/19253/files

      Diff of the public API doc for src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnection.java:

      --- a/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnection.java
      +++ b/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnection.java
      @@ -956,7 +956,9 @@
            * @param filters an array of marshalled representations of the
            * <code>NotificationFilters</code>.  Elements of this array can
            * be null.
      -     * @param delegationSubjects must be {@code null}.
      +     * @param delegationSubjects should be {@code null}, but a non-null
      +     * array is also accepted for compatibility reasons, which must not
      +     * contain any non-null entries.
            *
            * @return an array of <code>listenerIDs</code> identifying the
            * local listeners.  This array has the same number of elements as
      @@ -964,8 +966,7 @@
            *
            * @throws IllegalArgumentException if <code>names</code> or
            * <code>filters</code> is null, or if <code>names</code> contains
      -     * a null element, or if the three arrays do not all have the same
      -     * size.
      +     * a null element, or if these two arrays do not have the same size.
            * @throws ClassCastException if one of the elements of
            * <code>filters</code> unmarshalls as a non-null object that is
            * not a <code>NotificationFilter</code>.
      @@ -974,7 +975,8 @@
            * @throws SecurityException if, for one of the MBeans, the
            * client does not have permission to add a listener.
            * @throws IOException if a general communication exception occurred.
      -     * @throws UnsupportedOperationException if {@code delegationSubject} is non-null.
      +     * @throws UnsupportedOperationException if {@code delegationSubjects}
      +     * is non-null and contains any non-null values.
            */
           public Integer[] addNotificationListeners(ObjectName[] names,
                           MarshalledObject[] filters,

            kevinw Kevin Walls
            kevinw Kevin Walls
            Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: