diff --git a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpChannelOverHTTP2.java b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpChannelOverHTTP2.java index eb41f55a96d..df999131b73 100644 --- a/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpChannelOverHTTP2.java +++ b/jetty-http2/http2-http-client-transport/src/main/java/org/eclipse/jetty/http2/client/http/HttpChannelOverHTTP2.java @@ -25,7 +25,6 @@ import org.eclipse.jetty.client.HttpReceiver; import org.eclipse.jetty.client.HttpSender; import org.eclipse.jetty.client.api.Result; import org.eclipse.jetty.http2.ErrorCode; -import org.eclipse.jetty.http2.HTTP2Stream; import org.eclipse.jetty.http2.api.Session; import org.eclipse.jetty.http2.api.Stream; import org.eclipse.jetty.http2.frames.ResetFrame; @@ -78,7 +77,6 @@ public class HttpChannelOverHTTP2 extends HttpChannel public void setStream(Stream stream) { this.stream = stream; - getHttpExchange().getRequest().attribute(HTTP2Stream.class.getName(), stream); } @Override diff --git a/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2Test.java b/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2Test.java index 6090f76affb..51aa09c3364 100644 --- a/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2Test.java +++ b/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/HttpClientTransportOverHTTP2Test.java @@ -34,6 +34,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -50,7 +51,6 @@ import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.MetaData; import org.eclipse.jetty.http2.ErrorCode; import org.eclipse.jetty.http2.HTTP2Session; -import org.eclipse.jetty.http2.HTTP2Stream; import org.eclipse.jetty.http2.api.Session; import org.eclipse.jetty.http2.api.Stream; import org.eclipse.jetty.http2.api.server.ServerSessionListener; @@ -237,8 +237,32 @@ public class HttpClientTransportOverHTTP2Test extends AbstractTest CountDownLatch latch = new CountDownLatch(2); AtomicInteger lastStream = new AtomicInteger(); + AtomicReference streamRef = new AtomicReference<>(); + CountDownLatch streamLatch = new CountDownLatch(1); client = new HttpClient(new HttpClientTransportOverHTTP2(new HTTP2Client()) { + @Override + protected HttpConnectionOverHTTP2 newHttpConnection(HttpDestination destination, Session session) + { + return new HttpConnectionOverHTTP2(destination, session) + { + @Override + protected HttpChannelOverHTTP2 newHttpChannel() + { + return new HttpChannelOverHTTP2(getHttpDestination(), this, getSession()) + { + @Override + public void setStream(Stream stream) + { + super.setStream(stream); + streamRef.set(stream); + streamLatch.countDown(); + } + }; + } + }; + } + @Override protected void onClose(HttpConnectionOverHTTP2 connection, GoAwayFrame frame) { @@ -268,9 +292,10 @@ public class HttpClientTransportOverHTTP2Test extends AbstractTest latch.countDown(); }); + Assert.assertTrue(streamLatch.await(5, TimeUnit.SECONDS)); Assert.assertTrue(latch.await(5, TimeUnit.SECONDS)); - Stream stream = (Stream)request.getAttributes().get(HTTP2Stream.class.getName()); + Stream stream = streamRef.get(); Assert.assertNotNull(stream); Assert.assertEquals(lastStream.get(), stream.getId()); }