From accdee23e24ff2a6bd57914a6e53fd5aa592d625 Mon Sep 17 00:00:00 2001 From: Uwe Stieber Date: Wed, 22 Oct 2014 08:29:03 +0200 Subject: Target Explorer: Fix C/C++ Remote Application launch is not terminated if the gdbserver launch failed --- .../launch/cdt/launching/TEGdbLaunchDelegate.java | 171 +++++++++++---------- .../tcf/te/tcf/launch/cdt/utils/TEHelper.java | 153 ++++++------------ 2 files changed, 139 insertions(+), 185 deletions(-) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbLaunchDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbLaunchDelegate.java index 8db57f46e..bad872159 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbLaunchDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbLaunchDelegate.java @@ -16,6 +16,7 @@ package org.eclipse.tcf.te.tcf.launch.cdt.launching; import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.dsf.concurrent.DsfRunnable; @@ -23,6 +24,7 @@ import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor; import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunchDelegate; +import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; @@ -39,12 +41,12 @@ import org.eclipse.tcf.te.tcf.launch.cdt.activator.Activator; import org.eclipse.tcf.te.tcf.launch.cdt.interfaces.IRemoteTEConfigurationConstants; import org.eclipse.tcf.te.tcf.launch.cdt.nls.Messages; import org.eclipse.tcf.te.tcf.launch.cdt.utils.TEHelper; +import org.eclipse.tcf.te.tcf.processes.core.launcher.ProcessLauncher; public class TEGdbLaunchDelegate extends GdbLaunchDelegate { @Override - public void launch(ILaunchConfiguration config, String mode, - ILaunch launch, IProgressMonitor monitor) throws CoreException { + public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { IPath exePath = checkBinaryDetails(config); if (exePath != null && launch instanceof GdbLaunch) { // -1. Initialize TE @@ -52,41 +54,26 @@ public class TEGdbLaunchDelegate extends GdbLaunchDelegate { // 0. Get the peer from the launch configuration IPeer peer = TEHelper.getCurrentConnection(config).getPeer(); // 1.Download binary if needed - String remoteExePath = config.getAttribute( - IRemoteTEConfigurationConstants.ATTR_REMOTE_PATH, ""); //$NON-NLS-1$ + String remoteExePath = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_REMOTE_PATH, ""); //$NON-NLS-1$ monitor.setTaskName(Messages.RemoteRunLaunchDelegate_2); - boolean skipDownload = config - .getAttribute( - IRemoteTEConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET, - false); + boolean skipDownload = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_SKIP_DOWNLOAD_TO_TARGET, false); if (!skipDownload) { - TEHelper.remoteFileTransfer(peer, exePath.toString(), - remoteExePath, new SubProgressMonitor(monitor, 80)); + TEHelper.remoteFileTransfer(peer, exePath.toString(), remoteExePath, new SubProgressMonitor(monitor, 80)); } + // 2.Launch gdbserver on target - String gdbserverPortNumber = config - .getAttribute( - IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT, - IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT); - String gdbserverPortNumberMappedTo = config - .getAttribute( - IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT_MAPPED_TO, - (String)null); - String gdbserverCommand = config - .getAttribute( - IRemoteTEConfigurationConstants.ATTR_GDBSERVER_COMMAND, - IRemoteTEConfigurationConstants.ATTR_GDBSERVER_COMMAND_DEFAULT); - String commandArguments = ":" + gdbserverPortNumber + " " //$NON-NLS-1$ //$NON-NLS-2$ - + TEHelper.spaceEscapify(remoteExePath); + String gdbserverPortNumber = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT, IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT_DEFAULT); + String gdbserverPortNumberMappedTo = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_PORT_MAPPED_TO, (String) null); + String gdbserverCommand = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_GDBSERVER_COMMAND, IRemoteTEConfigurationConstants.ATTR_GDBSERVER_COMMAND_DEFAULT); + String commandArguments = ":" + gdbserverPortNumber + " " + TEHelper.spaceEscapify(remoteExePath); //$NON-NLS-1$ //$NON-NLS-2$ String arguments = getProgramArguments(config); - String prelaunchCmd = config.getAttribute( - IRemoteTEConfigurationConstants.ATTR_PRERUN_COMMANDS, ""); //$NON-NLS-1$ + String prelaunchCmd = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_PRERUN_COMMANDS, ""); //$NON-NLS-1$ + + TEHelper.launchCmd(peer, prelaunchCmd, null, new SubProgressMonitor(monitor, 2), new Callback()); - TEHelper.launchCmd(peer, prelaunchCmd, null, - new SubProgressMonitor(monitor, 2), new Callback()); if (arguments != null && !arguments.equals("")) //$NON-NLS-1$ - commandArguments += " " + arguments; //$NON-NLS-1$ + commandArguments += " " + arguments; //$NON-NLS-1$ monitor.setTaskName(Messages.RemoteRunLaunchDelegate_9); final GdbLaunch l = (GdbLaunch) launch; @@ -97,14 +84,14 @@ public class TEGdbLaunchDelegate extends GdbLaunchDelegate { // Need to shutdown the DSF launch session because it is // partially started already. try { - l.getSession().getExecutor() - .execute(new DsfRunnable() { - @Override - public void run() { - l.shutdownSession(new ImmediateRequestMonitor()); - } - }); - } catch (RejectedExecutionException e) { + l.getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + l.shutdownSession(new ImmediateRequestMonitor()); + } + }); + } + catch (RejectedExecutionException e) { // Session disposed. } @@ -117,18 +104,24 @@ public class TEGdbLaunchDelegate extends GdbLaunchDelegate { // could access them at the same time. We need a different // variable for each launch, but we also need it be final. // Use a final array to do that. - final boolean gdbServerReady[] = new boolean[1]; - gdbServerReady[0] = false; + final AtomicBoolean gdbServerReady = new AtomicBoolean(false); + final AtomicBoolean gdbServerExited = new AtomicBoolean(false); final Object lock = new Object(); StreamsDataReceiver.Listener listener = new StreamsDataReceiver.Listener() { @Override - public void dataReceived(String data) { + public void dataReceived(String data) { if (data.contains("Listening on port")) { //$NON-NLS-1$ + gdbServerReady.set(true); + synchronized (lock) { + lock.notifyAll(); + } + } + else if (data.contains("GDBserver exiting")) { //$NON-NLS-1$ + gdbServerExited.set(true); synchronized (lock) { - gdbServerReady[0] = true; lock.notifyAll(); } } @@ -136,70 +129,84 @@ public class TEGdbLaunchDelegate extends GdbLaunchDelegate { } }; - TEHelper.launchCmd(peer, gdbserverCommand, commandArguments, - listener, new SubProgressMonitor(monitor, 3), callback); + ProcessLauncher launcher = TEHelper.launchCmd(peer, gdbserverCommand, commandArguments, listener, new SubProgressMonitor(monitor, 3), callback); // Now wait until gdbserver is up and running on the remote host - synchronized (lock) { - while (gdbServerReady[0] == false) { - if (monitor.isCanceled()) { - // gdbserver launch failed - // Need to shutdown the DSF launch session because it is - // partially started already. - try { - l.getSession().getExecutor() - .execute(new DsfRunnable() { - @Override - public void run() { - l.shutdownSession(new ImmediateRequestMonitor()); - } - }); - } catch (RejectedExecutionException e) { - // Session disposed. - } - - abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage, - null, - ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED); - } + while (!gdbServerReady.get() && !gdbServerExited.get()) { + if (monitor.isCanceled()) { + // gdbserver launch failed + // Need to shutdown the DSF launch session because it is + // partially started already. + shutdownSession(l); + } + synchronized (lock) { try { lock.wait(300); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { } } } + // If the gdbserver exited, also shutdown the DSF launch session + if (gdbServerExited.get()) { + shutdownSession(l); + } + // 3. Let debugger know how gdbserver was started on the remote ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); - wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, - true); + wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP, true); wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_HOST, - TEHelper.getCurrentConnection(config).getPeer() - .getAttributes().get(IPeer.ATTR_IP_HOST)); - wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, - gdbserverPortNumberMappedTo == null || "".equals(gdbserverPortNumberMappedTo) ? gdbserverPortNumber : gdbserverPortNumberMappedTo); //$NON-NLS-1$ + TEHelper.getCurrentConnection(config).getPeer().getAttributes().get(IPeer.ATTR_IP_HOST)); + wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_PORT, gdbserverPortNumberMappedTo == null || "".equals(gdbserverPortNumberMappedTo) ? gdbserverPortNumber : gdbserverPortNumberMappedTo); //$NON-NLS-1$ wc.doSave(); try { super.launch(config, mode, launch, monitor); - } catch (CoreException ex) { - // TODO launch failed, need to kill gdbserver - + } + catch (CoreException ex) { + // Launch failed, need to kill gdbserver + launcher.terminate(); // report failure further throw ex; - } finally { + } + finally { monitor.done(); } } } - protected String getProgramArguments(ILaunchConfiguration config) - throws CoreException { - String args = config.getAttribute( - ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, - (String) null); + /** + * Shutdown the GDB debug session. + * + * @param launch The GDB launch. Must not be null. + * @throws CoreException If the GDB debug session shutdown failed. + */ + protected void shutdownSession(final GdbLaunch launch) throws CoreException { + Assert.isNotNull(launch); + try { + launch.getSession().getExecutor().execute(new DsfRunnable() { + @Override + public void run() { + // Avoid an NPE while running the shutdown + if (launch.getDsfExecutor() != null) { + launch.shutdownSession(new ImmediateRequestMonitor()); + } + } + }); + } + catch (RejectedExecutionException e) { + // Session disposed. + } + + abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage, null, ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED); + } + + protected String getProgramArguments(ILaunchConfiguration config) throws CoreException { + String args = config + .getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null); if (args != null) { args = VariablesPlugin.getDefault().getStringVariableManager() - .performStringSubstitution(args); + .performStringSubstitution(args); } return args; } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java index a70464fc8..e6316bf9b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java @@ -56,14 +56,10 @@ import org.eclipse.tcf.te.tcf.processes.core.launcher.ProcessLauncher; public class TEHelper { - public static void remoteFileTransfer(IPeer peer, String localFilePath, - String remoteFilePath, SubProgressMonitor monitor) { - monitor.beginTask(Messages.RemoteRunLaunchDelegate_2 + " " //$NON-NLS-1$ - + localFilePath + " to " + remoteFilePath, 100); //$NON-NLS-1$ - FileTransferItem item = new FileTransferItem(new Path(localFilePath), - new Path(remoteFilePath)); - item.setProperty(IFileTransferItem.PROPERTY_DIRECTION, - ""+IFileTransferItem.HOST_TO_TARGET); //$NON-NLS-1$ + public static void remoteFileTransfer(IPeer peer, String localFilePath, String remoteFilePath, SubProgressMonitor monitor) { + monitor.beginTask(Messages.RemoteRunLaunchDelegate_2 + " " + localFilePath + " to " + remoteFilePath, 100); //$NON-NLS-1$ //$NON-NLS-2$ + FileTransferItem item = new FileTransferItem(new Path(localFilePath), new Path(remoteFilePath)); + item.setProperty(IFileTransferItem.PROPERTY_DIRECTION, "" + IFileTransferItem.HOST_TO_TARGET); //$NON-NLS-1$ final Callback callback = new Callback(); FileTransferService.transfer(peer, null, item, monitor, callback); // Wait till the step finished, an execution occurred or the @@ -76,10 +72,10 @@ public class TEHelper { final AtomicReference parent = new AtomicReference(); final Runnable runnable = new Runnable() { @Override - public void run() { + public void run() { parent.set(ModelManager.getPeerModel() - .getService(IPeerModelLookupService.class) - .lkupPeerModelById(peerId)); + .getService(IPeerModelLookupService.class) + .lkupPeerModelById(peerId)); } }; Protocol.invokeAndWait(runnable); @@ -88,21 +84,16 @@ public class TEHelper { return null; } - public static IPeerNode getCurrentConnection(ILaunchConfiguration config) - throws CoreException { - String peerId = config.getAttribute( - IRemoteTEConfigurationConstants.ATTR_REMOTE_CONNECTION, ""); //$NON-NLS-1$ + public static IPeerNode getCurrentConnection(ILaunchConfiguration config) throws CoreException { + String peerId = config.getAttribute(IRemoteTEConfigurationConstants.ATTR_REMOTE_CONNECTION, ""); //$NON-NLS-1$ IPeerNode connection = getPeerNode(peerId); if (connection == null) { - abort(Messages.RemoteRunLaunchDelegate_13, null, - ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); + abort(Messages.RemoteRunLaunchDelegate_13, null, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); } return connection; } - public static ProcessLauncher launchCmd(final IPeer peer, String command, - Listener listener, SubProgressMonitor monitor, ICallback callback) - throws CoreException { + public static ProcessLauncher launchCmd(final IPeer peer, String command, Listener listener, SubProgressMonitor monitor, ICallback callback) throws CoreException { if (command != null && !command.trim().equals("")) { //$NON-NLS-1$ String[] args = StringUtil.tokenize(command, 0, true); if (args.length > 0) { @@ -111,47 +102,34 @@ public class TEHelper { if (args.length > 1) { arguments = Arrays.copyOfRange(args, 1, args.length); } - return launchCmd(peer, cmd, arguments, listener, monitor, - callback); + return launchCmd(peer, cmd, arguments, listener, monitor, callback); } } return null; } - public static ProcessLauncher launchCmd(final IPeer peer, - String remoteCommandPath, String arguments, Listener listener, - SubProgressMonitor monitor, ICallback callback) - throws CoreException { + public static ProcessLauncher launchCmd(final IPeer peer, String remoteCommandPath, String arguments, Listener listener, SubProgressMonitor monitor, ICallback callback) throws CoreException { String[] args = arguments != null && !"".equals(arguments.trim()) ? StringUtil.tokenize(arguments, 0, true) : null; //$NON-NLS-1$ - return launchCmd(peer, remoteCommandPath, args, listener, monitor, - callback); + return launchCmd(peer, remoteCommandPath, args, listener, monitor, callback); } - public static ProcessLauncher launchCmd(final IPeer peer, - String remoteCommandPath, String[] args, Listener listener, - SubProgressMonitor monitor, ICallback callback) - throws CoreException { + public static ProcessLauncher launchCmd(final IPeer peer, String remoteCommandPath, String[] args, Listener listener, SubProgressMonitor monitor, ICallback callback) throws CoreException { if (remoteCommandPath != null && !remoteCommandPath.trim().equals("")) { //$NON-NLS-1$ - monitor.beginTask(NLS.bind(Messages.RemoteRunLaunchDelegate_8, - remoteCommandPath, args), 10); + monitor.beginTask(NLS.bind(Messages.RemoteRunLaunchDelegate_8, remoteCommandPath, args), 10); // Construct the launcher object ProcessLauncher launcher = new ProcessLauncher(); Map launchAttributes = new HashMap(); - launchAttributes.put(IProcessLauncher.PROP_PROCESS_PATH, - spaceEscapify(remoteCommandPath)); + launchAttributes.put(IProcessLauncher.PROP_PROCESS_PATH, spaceEscapify(remoteCommandPath)); launchAttributes.put(IProcessLauncher.PROP_PROCESS_ARGS, args); - launchAttributes.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, - Boolean.FALSE); + launchAttributes.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, Boolean.FALSE); boolean outputConsole = true; if (outputConsole) { - launchAttributes.put( - IProcessLauncher.PROP_PROCESS_ASSOCIATE_CONSOLE, - Boolean.TRUE); + launchAttributes.put(IProcessLauncher.PROP_PROCESS_ASSOCIATE_CONSOLE, Boolean.TRUE); } // Fill in the launch attributes @@ -159,49 +137,32 @@ public class TEHelper { container.setProperties(launchAttributes); // If the line separator setting is not set explicitly, try to - // determine - // it automatically (local host only). - if (container - .getProperty(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR) == null) { + // determine it automatically (local host only). + if (container.getProperty(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR) == null) { // Determine if the launch is on local host. If yes, we can - // preset - // the - // line ending character. + // preset the line ending character. final AtomicBoolean isLocalhost = new AtomicBoolean(); Runnable runnable = new Runnable() { @Override - public void run() { - if (ITransportTypes.TRANSPORT_TYPE_TCP.equals(peer - .getTransportName()) - || ITransportTypes.TRANSPORT_TYPE_SSL - .equals(peer.getTransportName())) { - isLocalhost.set(IPAddressUtil.getInstance() - .isLocalHost( - peer.getAttributes().get( - IPeer.ATTR_IP_HOST))); + public void run() { + if (ITransportTypes.TRANSPORT_TYPE_TCP.equals(peer.getTransportName()) || ITransportTypes.TRANSPORT_TYPE_SSL.equals(peer.getTransportName())) { + isLocalhost.set(IPAddressUtil.getInstance().isLocalHost(peer.getAttributes().get(IPeer.ATTR_IP_HOST))); } } }; - if (Protocol.isDispatchThread()) - runnable.run(); - else - Protocol.invokeAndWait(runnable); + if (Protocol.isDispatchThread()) runnable.run(); + else Protocol.invokeAndWait(runnable); if (isLocalhost.get()) { - container - .setProperty( - ITerminalsConnectorConstants.PROP_LINE_SEPARATOR, - Host.isWindowsHost() ? ILineSeparatorConstants.LINE_SEPARATOR_CRLF - : ILineSeparatorConstants.LINE_SEPARATOR_LF); + container.setProperty(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR, + Host.isWindowsHost() ? ILineSeparatorConstants.LINE_SEPARATOR_CRLF : ILineSeparatorConstants.LINE_SEPARATOR_LF); } } if (listener != null) { - container.setProperty( - IProcessLauncher.PROP_PROCESS_OUTPUT_LISTENER, - new StreamsDataReceiver.Listener[] { listener }); + container.setProperty(IProcessLauncher.PROP_PROCESS_OUTPUT_LISTENER, new StreamsDataReceiver.Listener[] { listener }); } // Launch the process launcher.launch(peer, container, new Callback(callback) { @@ -219,14 +180,10 @@ public class TEHelper { return null; } - public static String launchCmdReadOutput(final IPeer peer, - String remoteCommandPath, String[] args, - final SubProgressMonitor monitor, ICallback callback) - throws CoreException { + public static String launchCmdReadOutput(final IPeer peer, String remoteCommandPath, String[] args, final SubProgressMonitor monitor, ICallback callback) throws CoreException { String output = null; if (remoteCommandPath != null && !remoteCommandPath.trim().equals("")) { //$NON-NLS-1$ - monitor.beginTask(NLS.bind(Messages.RemoteRunLaunchDelegate_8, - remoteCommandPath, args), 10); + monitor.beginTask(NLS.bind(Messages.RemoteRunLaunchDelegate_8, remoteCommandPath, args), 10); // Construct the launcher object final ProcessStreamsProxy proxy = new ProcessStreamsProxy(); @@ -234,15 +191,11 @@ public class TEHelper { Map launchAttributes = new HashMap(); - launchAttributes.put(IProcessLauncher.PROP_PROCESS_PATH, - spaceEscapify(remoteCommandPath)); + launchAttributes.put(IProcessLauncher.PROP_PROCESS_PATH, spaceEscapify(remoteCommandPath)); launchAttributes.put(IProcessLauncher.PROP_PROCESS_ARGS, args); - launchAttributes.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, - Boolean.FALSE); - launchAttributes.put( - IProcessLauncher.PROP_PROCESS_ASSOCIATE_CONSOLE, - Boolean.TRUE); + launchAttributes.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, Boolean.FALSE); + launchAttributes.put(IProcessLauncher.PROP_PROCESS_ASSOCIATE_CONSOLE, Boolean.TRUE); // Fill in the launch attributes IPropertiesContainer container = new PropertiesContainer(); @@ -269,7 +222,8 @@ public class TEHelper { } try { lock.wait(300); - } catch (InterruptedException e) { + } + catch (InterruptedException e) { } } ProcessOutputReaderThread reader = proxy.getOutputReader(); @@ -283,36 +237,29 @@ public class TEHelper { } /** - * Throws a core exception with an error status object built from the given - * message, lower level exception, and error code. + * Throws a core exception with an error status object built from the given message, lower level + * exception, and error code. * - * @param message - * the status message - * @param exception - * lower level exception associated with the error, or - * null if none - * @param code - * error code + * @param message the status message + * @param exception lower level exception associated with the error, or null if none + * @param code error code */ - public static void abort(String message, Throwable exception, int code) - throws CoreException { + public static void abort(String message, Throwable exception, int code) throws CoreException { IStatus status; if (exception != null) { - MultiStatus multiStatus = new MultiStatus(Activator.PLUGIN_ID, - code, message, exception); - multiStatus.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, - code, exception.getLocalizedMessage(), exception)); + MultiStatus multiStatus = new MultiStatus(Activator.PLUGIN_ID, code, message, exception); + multiStatus.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, code, exception + .getLocalizedMessage(), exception)); status = multiStatus; - } else { - status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, code, - message, null); + } + else { + status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, code, message, null); } throw new CoreException(status); } public static String spaceEscapify(String inputString) { - if (inputString == null) - return null; + if (inputString == null) return null; return inputString.replaceAll(" ", "\\\\ "); //$NON-NLS-1$ //$NON-NLS-2$ } -- cgit v1.2.3