Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2010-09-08 17:44:32 -0400
committereutarass2010-09-08 17:44:32 -0400
commit07999c4dbe457d17846e0d4f4d459c1d3dc54ee6 (patch)
treec8ba669d6c72f00fef322c777b0cd56964c887f4 /plugins/org.eclipse.tm.tcf.core
parentb3e27c53d71789f0052f70aad2bfadb7c920e26f (diff)
downloadorg.eclipse.tcf-07999c4dbe457d17846e0d4f4d459c1d3dc54ee6.tar.gz
org.eclipse.tcf-07999c4dbe457d17846e0d4f4d459c1d3dc54ee6.tar.xz
org.eclipse.tcf-07999c4dbe457d17846e0d4f4d459c1d3dc54ee6.zip
Changed handling of channel End-Of-Stream messages to improve reporting of channel closed errors
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.core')
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/AbstractChannel.java28
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ChannelPIPE.java3
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ChannelTCP.java2
3 files changed, 19 insertions, 14 deletions
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/AbstractChannel.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/AbstractChannel.java
index ab93f7ec5..818f59139 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/AbstractChannel.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/AbstractChannel.java
@@ -163,7 +163,7 @@ public abstract class AbstractChannel implements IChannel {
final byte[] empty_byte_array = new byte[0];
byte[] buf = new byte[1024];
- byte[] eos;
+ byte[] eos_err_report;
private void error() throws IOException {
throw new IOException("Protocol syntax error");
@@ -217,7 +217,12 @@ public abstract class AbstractChannel implements IChannel {
int n = read();
if (n == EOM) continue;
if (n == EOS) {
- eos = readBytes(EOM);
+ try {
+ eos_err_report = readBytes(EOM);
+ if (eos_err_report.length == 0 || eos_err_report.length == 1 && eos_err_report[0] == 0) eos_err_report = null;
+ }
+ catch (Exception x) {
+ }
break;
}
final Message msg = new Message((char)n);
@@ -256,19 +261,20 @@ public abstract class AbstractChannel implements IChannel {
}
Protocol.invokeLater(new Runnable() {
public void run() {
- if (out_tokens.isEmpty()) {
+ if (out_tokens.isEmpty() && eos_err_report == null) {
close();
}
else {
- IOException x = new IOException("Connection reset by peer");
- try {
- Object[] args = JSON.parseSequence(eos);
- if (args.length > 0 && args[0] != null) {
- x = new IOException(Command.toErrorString(args[0]));
+ IOException x = new IOException("Communication channel is closed by remote peer");
+ if (eos_err_report != null) {
+ try {
+ Object[] args = JSON.parseSequence(eos_err_report);
+ if (args.length > 0 && args[0] != null) {
+ x.initCause(new Exception(Command.toErrorString(args[0])));
+ }
+ }
+ catch (IOException e) {
}
- }
- catch (IOException e) {
- x = e;
}
terminate(x);
}
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ChannelPIPE.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ChannelPIPE.java
index b758f28e7..85872e74e 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ChannelPIPE.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ChannelPIPE.java
@@ -17,7 +17,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.net.SocketException;
import org.eclipse.tm.tcf.protocol.IPeer;
import org.eclipse.tm.tcf.protocol.Protocol;
@@ -77,7 +76,7 @@ public class ChannelPIPE extends StreamChannel {
if (closed) return -1;
return inp.read();
}
- catch (SocketException x) {
+ catch (IOException x) {
if (closed) return -1;
throw x;
}
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ChannelTCP.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ChannelTCP.java
index 68dee9046..482a3eb94 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ChannelTCP.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/core/ChannelTCP.java
@@ -149,7 +149,7 @@ public class ChannelTCP extends StreamChannel {
if (closed) return -1;
return inp.read();
}
- catch (SocketException x) {
+ catch (IOException x) {
if (closed) return -1;
throw x;
}

Back to the top