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

shell:new issue with class wildcards

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.0.6
    • 4.1.0, 4.0.7
    • karaf
    • None
    • Patch

    Description

      Karaf shell fails if you run this command:

      a=shell:new java.util.ArrayList 2
      
      2016-09-02 11:15:51,525 | ERROR | nsole user karaf | ShellUtil                        | 43 - org.apache.karaf.shell.core - 4.0.6 | Exception caught while executing command
      java.lang.IllegalStateException
      	at org.apache.karaf.shell.support.converter.GenericType.parametersOf(GenericType.java:161)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.karaf.shell.support.converter.GenericType.[init](GenericType.java:53)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.karaf.shell.support.converter.GenericType.parametersOf(GenericType.java:154)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.karaf.shell.support.converter.GenericType.[init](GenericType.java:53)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.karaf.shell.commands.impl.NewAction.findMatchingConstructors(NewAction.java:167)[41:org.apache.karaf.shell.commands:4.0.6]
      	at org.apache.karaf.shell.commands.impl.NewAction.execute(NewAction.java:89)[41:org.apache.karaf.shell.commands:4.0.6]
      	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:83)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:67)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:87)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:480)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:406)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:182)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:119)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:94)[43:org.apache.karaf.shell.core:4.0.6]
      	at org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:274)[43:org.apache.karaf.shell.core:4.0.6]
      	at java.lang.Thread.run(Thread.java:745)[:1.8.0_102]
      
      

      The reason for that is not really that it can't handle generics but it the logic that probe for the best matching constructor, that at some point, in this class:

      https://github.com/apache/karaf/blob/68bef0ced72a3fe192cfe496b3fff654b49b2377/shell/core/src/main/java/org/apache/karaf/shell/support/converter/GenericType.java#L161-L161

      sees type set to "? extends E" that is not able to handle, thus throwing the blocking exception.

      It's enough to replace that exception with an empty return, to bypass the failing iteration and have the command to succeed.

      Attachments

        Issue Links

          Activity

            People

              ffang Freeman Yue Fang
              paolo.antinori Paolo Antinori
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: