提交 2074646b 编写于 作者: K kohsuke

I encountered a situation where the channel reader appears to be stuck trying...

I encountered a situation where the channel reader appears to be stuck trying to write to output stream:

	at java.lang.Object.wait(Native Method)
	-  waiting on [B@102f72d
	at hudson.remoting.FastPipedOutputStream.write(FastPipedOutputStream.java:147)
	at hudson.remoting.FastPipedOutputStream.write(FastPipedOutputStream.java:122)
	at hudson.remoting.ProxyOutputStream$Chunk.execute(ProxyOutputStream.java:164)
	at hudson.remoting.Channel$ReaderThread.run(Channel.java:877)

Looking at the code, I see that the current write method keeps a strong reference to the sink, effectively nullifying the weak reference check. So fixing that bug.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@34825 71c3de6d-444a-0410-be80-ed276b4c234a
上级 e019884f
......@@ -130,21 +130,26 @@ public class FastPipedOutputStream extends OutputStream {
if(sink == null) {
throw new IOException("Unconnected pipe");
}
FastPipedInputStream s = sink();
if(s.closed!=null) {
throw (IOException)new IOException("Pipe is already closed").initCause(s.closed);
}
while (len>0) {
FastPipedInputStream s = sink(); // make sure the sink is still trying to read, or else fail the write.
if(s.closed!=null) {
throw (IOException)new IOException("Pipe is already closed").initCause(s.closed);
}
synchronized(s.buffer) {
if(s.writePosition == s.readPosition && s.writeLaps > s.readLaps) {
// The circular buffer is full, so wait for some reader to consume
// something.
sink(); // make sure the sink is still trying to read, or else fail the write.
// release a reference to 's' during the wait so that if the reader has abandoned the pipe
// we can tell.
byte[] buf = s.buffer;
s = null;
try {
s.buffer.wait(TIMEOUT);
buf.wait(TIMEOUT);
} catch (InterruptedException e) {
throw new IOException(e.getMessage());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册