/* * Copyright (c) 2020, 2021, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* * @test * @bug 8238270 * @library /test/lib http2/server * @build jdk.test.lib.net.SimpleSSLContext HttpServerAdapters * ReferenceTracker Response204V2Test * @modules java.base/sun.net.www.http * java.net.http/jdk.internal.net.http.common * java.net.http/jdk.internal.net.http.frame * java.net.http/jdk.internal.net.http.hpack * @run testng/othervm -Djdk.internal.httpclient.debug=true * -Djdk.httpclient.HttpClient.log=requests,responses,errors * Response204V2Test * @summary Tests that streams are closed after receiving a 204 response. * This test uses the OperationsTracker and will fail in * teardown if the tracker reports that some HTTP/2 streams * are still open.
*/
staticfinalint RESPONSE_CODE = 204; staticfinalint ITERATION_COUNT = 4; // a shared executor helps reduce the amount of threads created by the test staticfinal Executor executor = new TestExecutor(Executors.newCachedThreadPool()); staticfinal ConcurrentMap<String, Throwable> FAILURES = new ConcurrentHashMap<>(); staticvolatileboolean tasksFailed; staticfinal AtomicLong serverCount = new AtomicLong(); staticfinal AtomicLong clientCount = new AtomicLong(); staticfinallong start = System.nanoTime(); publicstatic String now() { long now = System.nanoTime() - start; long secs = now / 1000_000_000; long mill = (now % 1000_000_000) / 1000_000; long nan = now % 1000_000; return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan);
}
final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; privatevolatile HttpClient sharedClient;
staticclass TestExecutor implements Executor { final AtomicLong tasks = new AtomicLong();
Executor executor;
TestExecutor(Executor executor) { this.executor = executor;
}
@Override publicvoid handle(HttpTestExchange t) throws IOException { try {
URI uri = t.getRequestURI();
System.err.printf("Handler received request for %s\n", uri);
String type = uri.getScheme().toLowerCase();
InputStream is = t.getRequestBody(); while (is.read() != -1);
is.close();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.