summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorCamilo Bernal2013-03-20 12:24:24 (EDT)
committer Sami Wagiaalla2013-03-20 14:48:38 (EDT)
commit6ca693128a159f516a8e3676e20c4df4cc0c6e6c (patch)
tree148ff7857d0afc4658e7da67ab9cfa1f2e4dee1e
parent9f6d72ae4055ae91fe6f396a39b57e675ea025ec (diff)
downloadorg.eclipse.linuxtools-6ca693128a159f516a8e3676e20c4df4cc0c6e6c.zip
org.eclipse.linuxtools-6ca693128a159f516a8e3676e20c4df4cc0c6e6c.tar.gz
org.eclipse.linuxtools-6ca693128a159f516a8e3676e20c4df4cc0c6e6c.tar.bz2
Fix NPE in metadata singletonrefs/changes/43/11343/3
* Add null check after attempting to access uninitialized probes. * Inline small function that is used once. * Minor clean up. Change-Id: If4701da424ad9818cb53b2281e9ea515caf9cd7d Reviewed-on: https://git.eclipse.org/r/11343 Reviewed-by: Sami Wagiaalla <swagiaal@redhat.com> IP-Clean: Sami Wagiaalla <swagiaal@redhat.com> Tested-by: Sami Wagiaalla <swagiaal@redhat.com>
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java31
1 files changed, 12 insertions, 19 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java
index 5d10816..eeaf0af 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPMetadataSingleton.java
@@ -57,16 +57,20 @@ public class STPMetadataSingleton {
// Check to see if the proposal hint included a <tapset>.<partialprobe>
// or just a <probe>. (ie syscall. or syscall.re).
- boolean tapsetAndProbeIncluded = isTapsetAndProbe(match);
+ boolean tapsetAndProbeIncluded = match.indexOf('.') >= 0;
TreeNode node = TapsetLibrary.getProbes();
+ if (node == null) {
+ return NO_MATCHES;
+ }
// If the result is a tapset and partial probe, get the tapset, then
// narrow down the list with partial probe matches.
if (tapsetAndProbeIncluded) {
node = node.getChildByName(getTapset(match));
- if (node == null )
+ if (node == null) {
return NO_MATCHES;
+ }
// Now get the completions.
return getMatchingChildren(node, match);
@@ -94,17 +98,20 @@ public class STPMetadataSingleton {
*/
public String[] getProbeVariableCompletions(String probe, String prefix){
TreeNode node = TapsetLibrary.getProbes();
- if (node == null )
+ if (node == null) {
return NO_MATCHES;
+ }
// Get the matching leaf node.
node = node.getChildByName(getTapset(probe));
- if (node == null )
+ if (node == null) {
return NO_MATCHES;
+ }
node = node.getChildByName(probe);
- if (node == null )
+ if (node == null) {
return NO_MATCHES;
+ }
// Get the completions.
return getMatchingChildren(node, prefix);
@@ -124,20 +131,6 @@ public class STPMetadataSingleton {
}
/**
- * Given data, decide whether it is comprised of a <tapset>.<probe>
- * hint, or just a <tapset>.
- *
- * @param data - hint data
- * @return
- */
- private boolean isTapsetAndProbe(String data) {
- if (data.indexOf('.') >= 0)
- return true;
-
- return false;
- }
-
- /**
* Given data, extract <tapset>
*
* @param data - hint data