Bug 726673 - CLI: NPE on availabilityType tab completion
CLI: NPE on availabilityType tab completion
Status: CLOSED CURRENTRELEASE
Product: RHQ Project
Classification: Other
Component: CLI (Show other bugs)
3.0.1
Unspecified Unspecified
unspecified Severity medium (vote)
: ---
: ---
Assigned To: Lukas Krejci
Mike Foley
:
Depends On:
Blocks: jon30-bugs
  Show dependency treegraph
 
Reported: 2011-07-29 07:59 EDT by Ondřej Žižka
Modified: 2013-09-04 03:48 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-09-04 03:48:24 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ondřej Žižka 2011-07-29 07:59:35 EDT
var x = AvailabilityManager.getCurrentAvailabilityForResource( ... );

x.availabilityType.<tab>

Leads to:

ava.lang.NullPointerException
        at org.rhq.enterprise.client.InteractiveJavascriptCompletor.getContextMatches(InteractiveJavascriptCompletor.java:445)
        at org.rhq.enterprise.client.InteractiveJavascriptCompletor.contextComplete(InteractiveJavascriptCompletor.java:200)
        at org.rhq.enterprise.client.InteractiveJavascriptCompletor.contextComplete(InteractiveJavascriptCompletor.java:193)
        at org.rhq.enterprise.client.InteractiveJavascriptCompletor.complete(InteractiveJavascriptCompletor.java:134)
        at jline.MultiCompletor.complete(MultiCompletor.java:53)
        at jline.ConsoleReader.complete(ConsoleReader.java:832)
        at jline.ConsoleReader.readLine(ConsoleReader.java:518)
        at jline.ConsoleReader.readLine(ConsoleReader.java:448)
        at org.rhq.enterprise.client.ClientMain.getUserInput(ClientMain.java:189)
        at org.rhq.enterprise.client.ClientMain$1.run(ClientMain.java:237)
        at java.lang.Thread.run(Thread.java:662)
Comment 1 Ian Springer 2011-11-08 15:35:42 EST
I'm unable to reproduce this using HEAD of the master branch:

rhqadmin@localhost:7080$ var x = AvailabilityManager.getCurrentAvailabilityForResource(10001)

rhqadmin@localhost:7080$ x
Availability:
	availabilityType: DOWN
	         endTime: 
	              id: 12247
	        resource: Resource[id=10001, type=<null>, key=null, name=null, parent=<null>]
	       startTime: Tue Nov 08 15:16:11 EST 2011

rhqadmin@localhost:7080$ x.availabilityType
AvailabilityType:
	name: DOWN

rhqadmin@localhost:7080$ x.availabilityType.<Tab>

compareTo        declaringClass   name             ordinal          toString         valueOf          values


Even when I set x.availablityType to null and then try the autocompletion again, I still don't get an NPE. I just get an ASCII beep telling me there are no autocompletion matches.

Ondra, can you still reproduce this? If so, can you try to give me more detailed reproduction steps that I can use to reproduce?

Thanks.
Comment 2 Heiko W. Rupp 2011-11-08 15:50:16 EST
May be related to https://bugzilla.redhat.com/show_bug.cgi?id=717392
and https://bugzilla.redhat.com/show_bug.cgi?id=743379 
and thus fixed by one of those.
Comment 3 Heiko W. Rupp 2011-11-09 04:51:01 EST
Ian I see something similar:

rhqadmin@localhost:7080$ AlertDefinitionManager.alertDefinition.<TAB>

java.lang.NullPointerException
        at org.rhq.enterprise.client.InteractiveJavascriptCompletor.invoke(InteractiveJavascriptCompletor.java:593)
        at org.rhq.enterprise.client.InteractiveJavascriptCompletor.contextComplete(InteractiveJavascriptCompletor.java:185)
        at org.rhq.enterprise.client.InteractiveJavascriptCompletor.complete(InteractiveJavascriptCompletor.java:134)
        at jline.MultiCompletor.complete(MultiCompletor.java:53)
        at jline.ConsoleReader.complete(ConsoleReader.java:832)
        at jline.ConsoleReader.readLine(ConsoleReader.java:518)
        at jline.ConsoleReader.readLine(ConsoleReader.java:448)
        at org.rhq.enterprise.client.ClientMain.getUserInput(ClientMain.java:202)
        at org.rhq.enterprise.client.ClientMain$1.run(ClientMain.java:250)
        at java.lang.Thread.run(Thread.java:680)

This comes from the fact, that we invoke on method being null here. A possible patch:

--- modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/InteractiveJavascriptCompletor.java (revision 38bdef17e38c1322d7034f26360420036aedc19c)
+++ modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/InteractiveJavascriptCompletor.java (revision )
@@ -182,7 +182,10 @@
                 Object rootObject = matches.get(next).get(0);
                 if (rootObject instanceof PropertyDescriptor && !(baseObject instanceof Class)) {
                     try {
-                        rootObject = invoke(baseObject, ((PropertyDescriptor) rootObject).getReadMethod());
+                        Method readMethod = ((PropertyDescriptor) rootObject).getReadMethod();
+                        if (readMethod==null)
+                            return -1;
+                        rootObject = invoke(baseObject, readMethod);
                     } catch (Exception e) {
                         e.printStackTrace();
Comment 4 Jay Shaughnessy 2013-02-26 16:27:51 EST
Assigning to Lukas for further evaluation. Lukas, do what you think makes sense for this one.
Comment 5 Lukas Krejci 2013-02-27 08:48:02 EST
master http://git.fedorahosted.org/cgit/rhq/rhq.git/commit/?id=5f74ac330228be62050d1b387ea2cf9a47639c36
Author: Lukas Krejci <lkrejci@redhat.com>
Date:   Wed Feb 27 14:40:52 2013 +0100

    [BZ 726673] - be more robust against different types of bean properties.
    Rhino doesn't handle indexed properties automagically as it does normal
    basic javabean properties, so we should offer no code completion on such
    advanced property types.
Comment 6 Heiko W. Rupp 2013-09-04 03:48:24 EDT
Bulk closing of some old issues

Note You need to log in before you can comment on or make changes to this bug.