Paolo Antinori created KARAF-4693:
-------------------------------------

             Summary: shell:new issue with class wildcards
                 Key: KARAF-4693
                 URL: https://issues.apache.org/jira/browse/KARAF-4693
             Project: Karaf
          Issue Type: Bug
          Components: karaf-shell
    Affects Versions: 4.0.6
            Reporter: Paolo Antinori


Karaf shell fails if you run this command:

{code: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]

{code}

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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to