karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Dolan (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (KARAF-913) Omitted @Command on Gogo plugin is hard to debug because of NPE
Date Tue, 04 Oct 2011 18:17:34 GMT
Omitted @Command on Gogo plugin is hard to debug because of NPE

                 Key: KARAF-913
                 URL: https://issues.apache.org/jira/browse/KARAF-913
             Project: Karaf
          Issue Type: Bug
          Components: karaf-shell
    Affects Versions: 2.2.2
            Reporter: Chris Dolan
            Priority: Minor

If you forget to put a @Command annotation on your OsgiCommandSupport subclass, and you try
to execute that command with a syntax error (perhaps you forget an argument) then you'll get
the following under-informative error in the shell:

    Error executing command: java.lang.NullPointerException

The root cause (discovered by stepping in the debugger) is in DefaultActionPreparer.prepare()
line 291 where this line of code:

                    Command command = action.getClass().getAnnotation(Command.class);

is not followed by a null check. In fact, there are several places in that method where the
result of getAnnotation() is not checked. I propose one of the following two solutions:
 1) add null checks
 2) throw an informative exception in CommandProcessorImpl.addCommand() if the @Command is

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message