Bug 726673 - CLI: NPE on availabilityType tab completion
Summary: CLI: NPE on availabilityType tab completion
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: CLI
Version: 3.0.1
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: ---
Assignee: Lukas Krejci
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: jon30-bugs
TreeView+ depends on / blocked
 
Reported: 2011-07-29 11:59 UTC by Ondřej Žižka
Modified: 2013-09-04 07:48 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-09-04 07:48:24 UTC
Embargoed:


Attachments (Terms of Use)

Description Ondřej Žižka 2011-07-29 11:59:35 UTC
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 20:35:42 UTC
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 20:50:16 UTC
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 09:51:01 UTC
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 21:27:51 UTC
Assigning to Lukas for further evaluation. Lukas, do what you think makes sense for this one.

Comment 5 Lukas Krejci 2013-02-27 13:48:02 UTC
master http://git.fedorahosted.org/cgit/rhq/rhq.git/commit/?id=5f74ac330228be62050d1b387ea2cf9a47639c36
Author: Lukas Krejci <lkrejci>
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 07:48:24 UTC
Bulk closing of some old issues


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