Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2018-08-31 16:15:44 -0400
committerJeff Johnston2018-08-31 16:55:40 -0400
commit637e48106758e0b815e39bfe97a9532da2b7e453 (patch)
tree2b9dca20852bed03492fc735dbafbe46d805a80c
parentd3b17fe579879895200a3beef65abdee04a7378b (diff)
downloadorg.eclipse.linuxtools-637e48106758e0b815e39bfe97a9532da2b7e453.tar.gz
org.eclipse.linuxtools-637e48106758e0b815e39bfe97a9532da2b7e453.tar.xz
org.eclipse.linuxtools-637e48106758e0b815e39bfe97a9532da2b7e453.zip
Bug 538494 - NullPointerException in PerfCore.getHostName
- fix PerfCore getHostName() to check that project URI exists before accessing - add warning message if URI doesn't exist Change-Id: Iff242a0a70f4d75358e435593683900e8fa501c5 Reviewed-on: https://git.eclipse.org/r/128479 Tested-by: CI Bot Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/Messages.java1
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java10
-rw-r--r--perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/messages.properties1
3 files changed, 12 insertions, 0 deletions
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/Messages.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/Messages.java
index 550eaa2bb3..6f986dca96 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/Messages.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/Messages.java
@@ -18,6 +18,7 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.perf.messages"; //$NON-NLS-1$
public static String MsgProxyError;
+ public static String MsgNoProjectError;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
index bc3e529af2..465ff622f1 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/PerfCore.java
@@ -16,6 +16,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -43,6 +44,7 @@ import org.eclipse.linuxtools.internal.perf.model.TreeParent;
import org.eclipse.linuxtools.internal.perf.ui.PerfProfileView;
import org.eclipse.linuxtools.profiling.launch.ConfigUtils;
import org.eclipse.linuxtools.tools.launch.core.factory.RuntimeProcessFactory;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
@@ -117,6 +119,14 @@ public class PerfCore {
if(project == null){
return null;
}
+
+ URI projectURI = project.getLocationURI();
+ if (projectURI == null) {
+ Status status = new Status(IStatus.WARNING, PerfPlugin.PLUGIN_ID,
+ NLS.bind(Messages.MsgNoProjectError, projectName));
+ PerfPlugin.getDefault().getLog().log(status);
+ return null;
+ }
return project.getLocationURI().getHost();
}
diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/messages.properties b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/messages.properties
index 3b63b354d1..bb2c92ed0d 100644
--- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/messages.properties
+++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/messages.properties
@@ -1 +1,2 @@
MsgProxyError=Proxy could not be instantiated.
+MsgNoProjectError=Project {0} could not be located

Back to the top