Merged branch 'jetty-9.3.x' into 'jetty-9.4.x'.

This commit is contained in:
Simone Bordet 2016-09-26 15:52:18 +02:00
commit a292ef0652
2 changed files with 12 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.HttpVersion;
@ -311,6 +312,7 @@ public class StreamCloseTest extends AbstractTest
@Test @Test
public void testFailedSessionClosesIdleStream() throws Exception public void testFailedSessionClosesIdleStream() throws Exception
{ {
AtomicReference<Session> sessionRef = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
final List<Stream> streams = new ArrayList<>(); final List<Stream> streams = new ArrayList<>();
start(new ServerSessionListener.Adapter() start(new ServerSessionListener.Adapter()
@ -332,9 +334,7 @@ public class StreamCloseTest extends AbstractTest
@Override @Override
public void onFailure(Session session, Throwable failure) public void onFailure(Session session, Throwable failure)
{ {
Assert.assertEquals(0, session.getStreams().size()); sessionRef.set(session);
for (Stream stream : streams)
Assert.assertTrue(stream.isClosed());
latch.countDown(); latch.countDown();
} }
}); });
@ -350,5 +350,13 @@ public class StreamCloseTest extends AbstractTest
session.newStream(request2, new Promise.Adapter<>(), new Stream.Listener.Adapter()); session.newStream(request2, new Promise.Adapter<>(), new Stream.Listener.Adapter());
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Session serverSession = sessionRef.get();
// Wait for the server to finish the close activities.
Thread.sleep(1000);
Assert.assertEquals(0, serverSession.getStreams().size());
for (Stream stream : streams)
Assert.assertTrue(stream.isClosed());
} }
} }

View File

@ -468,8 +468,8 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
@Override @Override
public void onConnectionFailure(int error, String reason) public void onConnectionFailure(int error, String reason)
{ {
close(error, reason, Callback.NOOP);
notifyFailure(this, new IOException(String.format("%d/%s", error, reason))); notifyFailure(this, new IOException(String.format("%d/%s", error, reason)));
close(error, reason, Callback.NOOP);
} }
@Override @Override