Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-4184

ArgumentCompleter has incorrect check for enum type

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.0.3
    • Fix Version/s: 4.0.4
    • Component/s: karaf
    • Labels:
      None

      Description

      https://github.com/apache/karaf/blob/karaf-4.0.3/shell/core/src/main/java/org/apache/karaf/shell/impl/action/command/ArgumentCompleter.java#L180

      if (type.isAssignableFrom(Enum.class)) {
      

      should really be:

      if (type.isEnum()) {
      

      because otherwise the only time that branch will be taken is when 'type' is exactly Enum.class or a superclass, as per the spec of isAssignableFrom. It won't be taken when the field is a concrete enum class with actual values.

      If you want to stick with "isAssignableFrom" then the Enum check should be:

      if (Enum.class.isAssignableFrom(type)) {
      

        Attachments

          Activity

            People

            • Assignee:
              jbonofre Jean-Baptiste Onofré
              Reporter:
              mcculls Stuart McCulloch
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: