Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXED JENKINS-7114] fixed the layer confusion in the remoting
When ProxyOutputStream sends write(byte[]) to the other end and the actual write fails, "NotifyDeadWriter" object comes back and reports back that the write has failed. Without this mechanism, the writer side will keep on going. Because the RemoteOutputStream service is a lower layer service that cannot rely on custom classloading service (doing so would create cyclic dependencies), when we send back this exception, the object graph of the exception needs to be deserializable on the receiver side. This is not the case when the exception class is defined by the user (as is the case of winstone.ClientSocketException.) This fix addresses this problem by turning an exception class into another class that emulates the output of the original exception. To make this change interopeable with earlier versions, we need to introduce a new capability flag. If we send MimicException to the other side and the other side doesn't have this class definition, then it'll cause automatic fail.
- Loading branch information
Showing
6 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package hudson.remoting; | ||
|
||
/** | ||
* Exception that prints like the specified exception. | ||
* | ||
* This is used to carry the diagnostic information to the other side of the channel | ||
* in situations where we cannot use class remoting. | ||
* | ||
* @author Kohsuke Kawaguchi | ||
* @see Capability#hasMimicException() | ||
*/ | ||
class MimicException extends Exception { | ||
private final String className; | ||
MimicException(Throwable cause) { | ||
super(cause.getMessage()); | ||
className = cause.getClass().getName(); | ||
setStackTrace(cause.getStackTrace()); | ||
|
||
if (cause.getCause()!=null) | ||
initCause(new MimicException(cause.getCause())); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
String s = className; | ||
String message = getLocalizedMessage(); | ||
return (message != null) ? (s + ": " + message) : s; | ||
} | ||
|
||
public static Throwable make(Channel ch, Throwable cause) { | ||
if (cause == null) return null; | ||
|
||
// make sure the remoting layer of the other end supports this | ||
if (ch.remoteCapability.hasMimicException()) | ||
return new MimicException(cause); | ||
else | ||
return cause; | ||
} | ||
|
||
private static final long serialVersionUID = 1L; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters