1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 09:15:38 +02:00

Merge "Bug 471143 - Prevent potential NPE in disconnect" into R2_0_maintenance

This commit is contained in:
Greg Watson 2015-06-26 11:43:50 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit 41a0e60a48

View file

@ -46,15 +46,19 @@ public class TerminalConsoleConnector {
public OutThread() { public OutThread() {
super("Terminal Output"); //$NON-NLS-1$ super("Terminal Output"); //$NON-NLS-1$
} }
@Override
public void run() { public void run() {
try { try {
byte[] buff = new byte[1024]; byte[] buff = new byte[1024];
InputStream in = remoteProcess.getInputStream(); if (remoteProcess != null) {
for (int n = in.read(buff); n >= 0; n = in.read(buff)) { InputStream in = remoteProcess.getInputStream();
for (PageConnector connector : pageConnectors) { for (int n = in.read(buff); n >= 0; n = in.read(buff)) {
ITerminalControl control = connector.control; for (PageConnector connector : pageConnectors) {
if (control != null) { ITerminalControl control = connector.control;
control.getRemoteToTerminalOutputStream().write(buff, 0, n); if (control != null) {
control.getRemoteToTerminalOutputStream().write(buff, 0, n);
}
} }
} }
} }
@ -67,6 +71,7 @@ public class TerminalConsoleConnector {
} }
} }
} }
private OutThread outThread; private OutThread outThread;
public TerminalConsoleConnector(IRemoteConnection connection) { public TerminalConsoleConnector(IRemoteConnection connection) {
@ -153,7 +158,7 @@ public class TerminalConsoleConnector {
} }
public void disconnect() { public void disconnect() {
if (!remoteProcess.isCompleted()) { if (remoteProcess != null && !remoteProcess.isCompleted()) {
new Job(ConsoleMessages.DISCONNECTING) { new Job(ConsoleMessages.DISCONNECTING) {
@Override @Override
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
@ -200,7 +205,7 @@ public class TerminalConsoleConnector {
@Override @Override
public OutputStream getTerminalToRemoteStream() { public OutputStream getTerminalToRemoteStream() {
return remoteProcess.getOutputStream(); return remoteProcess != null ? remoteProcess.getOutputStream() : null;
} }
@Override @Override