296570 EOFException for HttpExchange when HttpClient.stop called

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2067 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-07-05 04:42:35 +00:00
parent 75dd71b1ff
commit 3e515dd060
4 changed files with 25 additions and 4 deletions

View File

@ -596,10 +596,21 @@ public class HttpConnection implements Connection
{
//if there is a live, unfinished exchange, set its status to be
//excepted and wake up anyone waiting on waitForDone()
if (_exchange != null && !_exchange.isDone())
if (_exchange != null && !_exchange.isDone())
{
_exchange.setStatus(HttpExchange.STATUS_EXCEPTED);
_exchange.getEventListener().onException(new EOFException("local close"));
switch (_exchange.getStatus())
{
case HttpExchange.STATUS_CANCELLED:
case HttpExchange.STATUS_CANCELLING:
case HttpExchange.STATUS_COMPLETED:
case HttpExchange.STATUS_EXCEPTED:
case HttpExchange.STATUS_EXPIRED:
break;
default:
_exchange.setStatus(HttpExchange.STATUS_EXCEPTED);
_exchange.getEventListener().onException(new EOFException("local close"));
}
}
_endp.close();

View File

@ -173,6 +173,7 @@ public class HttpExchange
case STATUS_WAITING_FOR_CONNECTION:
case STATUS_WAITING_FOR_COMMIT:
case STATUS_CANCELLING:
case STATUS_EXCEPTED:
set=_status.compareAndSet(oldStatus,newStatus);
break;
}
@ -283,6 +284,7 @@ public class HttpExchange
case STATUS_CANCELLING:
switch (newStatus)
{
case STATUS_EXCEPTED:
case STATUS_CANCELLED:
if (set=_status.compareAndSet(oldStatus,newStatus))
done();
@ -301,6 +303,9 @@ public class HttpExchange
case STATUS_START:
set=_status.compareAndSet(oldStatus,newStatus);
break;
default:
set=true;
break;
}
break;
default:

View File

@ -282,10 +282,10 @@ public abstract class AbstractHttpExchangeCancelTest extends TestCase
getHttpClient().send(exchange);
int status = exchange.waitForDone();
assertEquals(HttpExchange.STATUS_COMPLETED, status);
assertTrue(exchange.isResponseCompleted());
assertFalse(exchange.isFailed());
assertFalse(exchange.isAssociated());
assertEquals(HttpExchange.STATUS_COMPLETED, status);
}
public void testHttpExchangeOnServerException() throws Exception

View File

@ -532,6 +532,11 @@ public class HttpExchangeTest extends TestCase
response.getOutputStream().write(bout.toByteArray());
}
}
catch(InterruptedException e)
{
System.err.println(e);
Log.debug(e);
}
catch(IOException e)
{
e.printStackTrace();