--- old/test/jdk/java/net/httpclient/http2/server/Http2TestServer.java 2017-11-30 04:05:22.260332047 -0800 +++ new/test/jdk/java/net/httpclient/http2/server/Http2TestServer.java 2017-11-30 04:05:22.069315351 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; import javax.net.ServerSocketFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLParameters; @@ -131,6 +132,18 @@ handlers.put(path, handler); } + volatile Http2TestExchangeSupplier exchangeSupplier = Http2TestExchangeSupplier.ofDefault(); + + /** + * Sets an explicit exchange handler to be used for all future connections. + * Useful for testing scenarios where non-standard or specific server + * behaviour is required, either direct control over the frames sent, "bad" + * behaviour, or something else. + */ + public void setExchangeSupplier(Http2TestExchangeSupplier exchangeSupplier) { + this.exchangeSupplier = exchangeSupplier; + } + Http2Handler getHandlerFor(String path) { if (path == null || path.equals("")) path = "/"; @@ -199,7 +212,8 @@ while (!stopping) { Socket socket = server.accept(); InetSocketAddress addr = (InetSocketAddress) socket.getRemoteSocketAddress(); - Http2TestServerConnection c = new Http2TestServerConnection(this, socket); + Http2TestServerConnection c = + new Http2TestServerConnection(this, socket, exchangeSupplier); connections.put(addr, c); try { c.run();