Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Bug 875156 - NPE in code completion
Browse files Browse the repository at this point in the history
Method getContextMatches from JavascriptCompletor now verifies if the baseObject is not null.
  • Loading branch information
Josejulio Martínez Magaña committed Oct 24, 2015
1 parent 86bbcd5 commit ee0578f
Showing 1 changed file with 18 additions and 16 deletions.
Expand Up @@ -461,25 +461,27 @@ private Map<String, Object> getContextMatches(String start, Class<?> typeFilter)
private Map<String, List<Object>> getContextMatches(PrintWriter output, Object baseObject, String start) {
Map<String, List<Object>> found = new HashMap<String, List<Object>>();

Class<?> baseObjectClass = null;
if (baseObject instanceof Class) {
baseObjectClass = (Class<?>) baseObject;
} else {
baseObjectClass = baseObject.getClass();
}

try {
if (baseObjectClass.equals(Void.TYPE)) {
return found;
} else if (ScriptableObject.class.isAssignableFrom(baseObjectClass)) {
return findJavascriptContextMatches((ScriptableObject) baseObject, start);
if (baseObject != null) {
Class<?> baseObjectClass = null;
if (baseObject instanceof Class) {
baseObjectClass = (Class<?>) baseObject;
} else {
return findJavaBeanContextMatches(baseObject, baseObjectClass, start);
baseObjectClass = baseObject.getClass();
}

} catch (Exception e) {
LOG.info("Failure during code completion", e);
e.printStackTrace(output);
try {
if (baseObjectClass.equals(Void.TYPE)) {
return found;
} else if (ScriptableObject.class.isAssignableFrom(baseObjectClass)) {
return findJavascriptContextMatches((ScriptableObject) baseObject, start);
} else {
return findJavaBeanContextMatches(baseObject, baseObjectClass, start);
}

} catch (Exception e) {
LOG.info("Failure during code completion", e);
e.printStackTrace(output);
}
}

return found;
Expand Down

0 comments on commit ee0578f

Please sign in to comment.