Bug 875156

Summary: NPE in code completion
Product: [Other] RHQ Project Reporter: Libor Zoubek <lzoubek>
Component: CLIAssignee: Josejulio Martínez <jmartine>
Status: POST --- QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.5CC: finwemartinez, hrupp, jmartine, theute
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Libor Zoubek 2012-11-09 11:36:03 EST
Description of problem: I get NPE when trying to use code completion in CLI for particular type


Version-Release number of selected component (if applicable):
Version: 4.6.0-SNAPSHOT
Build Number: ce0f7f2

How reproducible:always


Steps to Reproduce:
1. run following in CLI
var resource = ProxyFactory.getResource(12345);
resource.resourceType.metricDefinitions.<TAB>
  
Actual results:

java.lang.NullPointerException
	at org.rhq.scripting.javascript.JavascriptCompletor.getContextMatches(JavascriptCompletor.java:456)
	at org.rhq.scripting.javascript.JavascriptCompletor.contextComplete(JavascriptCompletor.java:208)
	at org.rhq.scripting.javascript.JavascriptCompletor.contextComplete(JavascriptCompletor.java:201)
	at org.rhq.scripting.javascript.JavascriptCompletor.contextComplete(JavascriptCompletor.java:201)
	at org.rhq.scripting.javascript.JavascriptCompletor.complete(JavascriptCompletor.java:131)
	at org.rhq.enterprise.client.utility.CodeCompletionCompletorWrapper.complete(CodeCompletionCompletorWrapper.java:34)
	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:278)
	at org.rhq.enterprise.client.ClientMain$1.run(ClientMain.java:319)
	at java.lang.Thread.run(Unknown Source)

Expected results: metric definitions for given resource type name are printed

Additional info:
Comment 1 Josejulio 2015-10-24 02:23:54 EDT
Submitted a PR that fixes this issue:
https://github.com/rhq-project/rhq/pull/187
Comment 3 Josejulio Martínez 2016-06-14 11:32:34 EDT
commit b5ab4f5f0493c8d38ffd8ed33b6159c824a8b39c
Merge: 972c091 ee0578f
Author: Michael Burman <yak@iki.fi>
Date:   Tue Jun 14 14:47:09 2016 +0300

    Merge pull request #187 from josejulio/Bug-875156
    
    Bug 875156 - NPE in code completion

commit ee0578fa3f3cde335b24ec5c9fa7ef6e3c31de9a
Author: Josejulio Martínez Magaña <josejulio.martinez@aluxoft.com>
Date:   Sat Oct 24 01:21:39 2015 -0500

    Bug 875156 - NPE in code completion
    
    Method getContextMatches from JavascriptCompletor now verifies if the baseObject is not null.