From 1757c7cb4e52f6cd2183617dbef45e0dc9f1be09 Mon Sep 17 00:00:00 2001 From: Camilo Bernal Date: Tue, 16 Oct 2012 11:33:32 -0400 Subject: Add null check to PrintStream in PerfLaunchConfigurationDelegate. In the case where perf does not run, such as in o.e.l.perf.tests, there is no available console to output to. Adding this check avoids a null pointer exception when said case occurs. Change-Id: Ic5e0444e889da087d45a7ad2e35ea39a50a511fa Reviewed-on: https://git.eclipse.org/r/8234 Tested-by: Hudson CI Reviewed-by: Roland Grunberg IP-Clean: Roland Grunberg Tested-by: Roland Grunberg --- .../perf/launch/PerfLaunchConfigDelegate.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java index 5f7b7c7587..e27eee22d3 100644 --- a/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java +++ b/perf/org.eclipse.linuxtools.perf/src/org/eclipse/linuxtools/internal/perf/launch/PerfLaunchConfigDelegate.java @@ -121,15 +121,20 @@ public class PerfLaunchConfigDelegate extends ProfileLaunchConfigurationDelegate outputTo = binaryOutCons.newOutputStream(); //Get the printstream for that console print = new PrintStream(outputTo); - } - for (int i = 0; i < commandArray.length; i++) { - print.print(commandArray[i] + " "); + } + + if (print != null) { + for (int i = 0; i < commandArray.length; i++) { + print.print(commandArray[i] + " "); + } + + // Print Message + print.println(); + print.println("Analysing recorded perf.data, please wait..."); + // Possibly should pass this (the console reference) on to + // PerfCore.Report if theres anything we ever want to spit + // out to user. } - - //Print Message - print.println(); - print.println("Analysing recorded perf.data, please wait..."); - //Possibly should pass this (the console reference) on to PerfCore.Report if theres anything we ever want to spit out to user. } //(Only for testing this line..) PerfCore.Report(config, null, null, null, "/home/thavidu/dev/eclipse-oprof2-workspace/org.eclipse.linuxtools.internal.perf.tests/resources/perf.data"); -- cgit v1.2.3