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

MBeanOperationInfo accepts any int value as "impact"

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 10
    • core-svc
    • None
    • behavioral
    • low
    • Hide
      There should be no change in behavior for all current valid values of impact.
      For invalid impact values IllegalArgumentException will be thrown.
      Show
      There should be no change in behavior for all current valid values of impact. For invalid impact values IllegalArgumentException will be thrown.
    • SE

      Summary

      Change the constructor of javax.management.MBeanOperationInfo.MBeanOperationInfo throw an llegalArgumentException if the impact argument is not among the defined values INFO, ACTION, ACTION_INFO, or UNKNOWN.

      Problem

      javax.management.MBeanOperationInfo.MBeanOperationInfo constructor accepts any integer value as impact.

      Solution

      Added validation for impact parameter of javax.management.MBeanOperationInfo.MBeanOperationInfo constructor. MBeanOperationInfo throws new IllegalArgumentException if impact provided is not among INFO, ACTION, ACTION_INFO, UNKNOWN

      Specification

      --- old/src/java.management/share/classes/javax/management/MBeanOperationInfo.java  2017-11-08 23:19:02.156362000 +0530
      +++ new/src/java.management/share/classes/javax/management/MBeanOperationInfo.java  2017-11-08 23:19:01.160362000 +0530
      @@ -1,5 +1,5 @@
       /*
      - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
      + * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
        * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
        *
        * This code is free software; you can redistribute it and/or modify it
      @@ -146,6 +146,9 @@
            * @param descriptor The descriptor for the operation.  This may be null
            * which is equivalent to an empty descriptor.
            *
      +     * @throws IllegalArgumentException if {@code impact} is not one of
      +     * {@linkplain #ACTION}, {@linkplain #ACTION_INFO}, {@linkplain #INFO} or {@linkplain #UNKNOWN}.
      +     *
            * @since 1.6
            */
           public MBeanOperationInfo(String name,
      @@ -157,6 +160,12 @@
      
               super(name, description, descriptor);
      
      +        if (impact < INFO || impact > UNKNOWN) {
      +            throw new IllegalArgumentException("Argument impact can only be "
      +                    + "one of ACTION, ACTION_INFO, "
      +                    + "INFO, or UNKNOWN" + " given value is :" + impact);
      +        }
      +
               if (signature == null || signature.length == 0)
                   signature = MBeanParameterInfo.NO_PARAMS;
               else
      @@ -259,8 +268,7 @@
               case ACTION: impactString = "action"; break;
               case ACTION_INFO: impactString = "action/info"; break;
               case INFO: impactString = "info"; break;
      -        case UNKNOWN: impactString = "unknown"; break;
      -        default: impactString = "(" + getImpact() + ")";
      +        default: impactString = "unknown";
               }
               return getClass().getName() + "[" +
                   "description=" + getDescription() + ", " +

            uvangapally Ujwal Vangapally (Inactive)
            sjiang Shanliang Jiang (Inactive)
            Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: