Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improving the stream diagnosis to report the actual contents of the stream.
  • Loading branch information
kohsuke committed Aug 2, 2013
1 parent dd9f754 commit 8c90640
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main/java/hudson/remoting/ClassicCommandTransport.java
Expand Up @@ -72,6 +72,8 @@ public final Command read() throws IOException, ClassNotFoundException {
if (rawIn!=null)
rawIn.clear();
return cmd;
} catch (RuntimeException e) {// see JENKINS-19046
throw diagnoseStreamCorruption(e);
} catch (StreamCorruptedException e) {
throw diagnoseStreamCorruption(e);
}
Expand All @@ -81,9 +83,13 @@ public final Command read() throws IOException, ClassNotFoundException {
* To diagnose stream corruption, we'll try to read ahead the data.
* This operation can block, so we'll use another thread to do this.
*/
private StreamCorruptedException diagnoseStreamCorruption(StreamCorruptedException e) throws StreamCorruptedException {
if (rawIn==null)
return e; // no source of diagnostics information. can't diagnose.
private StreamCorruptedException diagnoseStreamCorruption(Exception e) throws StreamCorruptedException {
if (rawIn==null) {// no source of diagnostics information. can't diagnose.
if (e instanceof StreamCorruptedException)
return (StreamCorruptedException)e;
else
return (StreamCorruptedException)new StreamCorruptedException().initCause(e);
}

return rawIn.analyzeCrash(e,channel.toString());
}
Expand Down

0 comments on commit 8c90640

Please sign in to comment.