author | jjg |
Wed, 04 Jan 2017 18:33:20 -0800 (2017-01-05) | |
changeset 43029 | 1cd1c816581e |
parent 42460 | 7133f144981a |
permissions | -rw-r--r-- |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
1 |
/* |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
4 |
* |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
8 |
* |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
13 |
* accompanied this code). |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
14 |
* |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
18 |
* |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
21 |
* questions. |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
22 |
*/ |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
23 |
|
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
24 |
import java.io.*; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
25 |
import jdk.incubator.http.HttpClient; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
26 |
import jdk.incubator.http.HttpResponse; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
27 |
import jdk.incubator.http.HttpRequest; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
28 |
import java.net.ServerSocket; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
29 |
import java.net.Socket; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
30 |
import java.net.URI; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
31 |
import java.nio.file.Files; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
32 |
import java.nio.file.Path; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
33 |
import java.nio.file.Paths; |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
34 |
import java.nio.ByteBuffer; |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
35 |
import java.util.concurrent.CompletableFuture; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
36 |
import java.util.concurrent.Executor; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
37 |
import java.util.concurrent.ExecutorService; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
38 |
import java.util.concurrent.ExecutionException; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
39 |
import java.util.concurrent.Flow; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
40 |
import java.util.concurrent.TimeoutException; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
41 |
import java.util.concurrent.TimeUnit; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
42 |
import static java.lang.System.out; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
43 |
import static java.nio.charset.StandardCharsets.US_ASCII; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
44 |
import static jdk.incubator.http.HttpResponse.BodyHandler.discard; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
45 |
import static java.nio.charset.StandardCharsets.UTF_8; |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
46 |
|
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
47 |
/** |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
48 |
* @test |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
49 |
* @bug 8151441 |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
50 |
* @summary Request body of incorrect (larger or smaller) sizes than that |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
51 |
* reported by the body processor |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
52 |
* @run main/othervm ShortRequestBody |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
53 |
*/ |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
54 |
|
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
55 |
public class ShortRequestBody { |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
56 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
57 |
static final Path testSrc = Paths.get(System.getProperty("test.src", ".")); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
58 |
static volatile HttpClient staticDefaultClient; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
59 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
60 |
static HttpClient defaultClient() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
61 |
if (staticDefaultClient == null) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
62 |
synchronized (ShortRequestBody.class) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
63 |
staticDefaultClient = HttpClient.newHttpClient(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
64 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
65 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
66 |
return staticDefaultClient; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
67 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
68 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
69 |
// Some body types ( sources ) for testing. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
70 |
static final String STRING_BODY = "Hello world"; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
71 |
static final byte[] BYTE_ARRAY_BODY = new byte[] { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
72 |
(byte)0xCA, (byte)0xFE, (byte)0xBA, (byte)0xBE }; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
73 |
static final Path FILE_BODY = testSrc.resolve("docs").resolve("files").resolve("foo.txt"); |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
74 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
75 |
// Body lengths and offsets ( amount to be wrong by ), to make coordination |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
76 |
// between client and server easier. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
77 |
static final int[] BODY_LENGTHS = new int[] { STRING_BODY.length(), |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
78 |
BYTE_ARRAY_BODY.length, |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
79 |
fileSize(FILE_BODY) }; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
80 |
static final int[] BODY_OFFSETS = new int[] { 0, +1, -1, +2, -2, +3, -3 }; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
81 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
82 |
// A delegating body processor. Subtypes will have a concrete body type. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
83 |
static abstract class AbstractDelegateRequestBody |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
84 |
implements HttpRequest.BodyProcessor { |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
85 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
86 |
final HttpRequest.BodyProcessor delegate; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
87 |
final long contentLength; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
88 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
89 |
AbstractDelegateRequestBody(HttpRequest.BodyProcessor delegate, |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
90 |
long contentLength) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
91 |
this.delegate = delegate; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
92 |
this.contentLength = contentLength; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
93 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
94 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
95 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
96 |
public void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
97 |
delegate.subscribe(subscriber); |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
98 |
} |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
99 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
100 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
101 |
public long contentLength() { return contentLength; /* may be wrong! */ } |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
102 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
103 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
104 |
// Request body processors that may generate a different number of actual |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
105 |
// bytes to that of what is reported through their {@code contentLength}. |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
106 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
107 |
static class StringRequestBody extends AbstractDelegateRequestBody { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
108 |
StringRequestBody(String body, int additionalLength) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
109 |
super(HttpRequest.BodyProcessor.fromString(body), |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
110 |
body.getBytes(UTF_8).length + additionalLength); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
111 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
112 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
113 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
114 |
static class ByteArrayRequestBody extends AbstractDelegateRequestBody { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
115 |
ByteArrayRequestBody(byte[] body, int additionalLength) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
116 |
super(HttpRequest.BodyProcessor.fromByteArray(body), |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
117 |
body.length + additionalLength); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
118 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
119 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
120 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
121 |
static class FileRequestBody extends AbstractDelegateRequestBody { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
122 |
FileRequestBody(Path path, int additionalLength) throws IOException { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
123 |
super(HttpRequest.BodyProcessor.fromFile(path), |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
124 |
Files.size(path) + additionalLength); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
125 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
126 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
127 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
128 |
// --- |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
129 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
130 |
public static void main(String[] args) throws Exception { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
131 |
try (Server server = new Server()) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
132 |
URI uri = new URI("http://127.0.0.1:" + server.getPort() + "/"); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
133 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
134 |
// sanity |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
135 |
success(uri, new StringRequestBody(STRING_BODY, 0)); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
136 |
success(uri, new ByteArrayRequestBody(BYTE_ARRAY_BODY, 0)); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
137 |
success(uri, new FileRequestBody(FILE_BODY, 0)); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
138 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
139 |
for (int i=1; i< BODY_OFFSETS.length; i++) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
140 |
failureBlocking(uri, new StringRequestBody(STRING_BODY, BODY_OFFSETS[i])); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
141 |
failureBlocking(uri, new ByteArrayRequestBody(BYTE_ARRAY_BODY, BODY_OFFSETS[i])); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
142 |
failureBlocking(uri, new FileRequestBody(FILE_BODY, BODY_OFFSETS[i])); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
143 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
144 |
failureNonBlocking(uri, new StringRequestBody(STRING_BODY, BODY_OFFSETS[i])); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
145 |
failureNonBlocking(uri, new ByteArrayRequestBody(BYTE_ARRAY_BODY, BODY_OFFSETS[i])); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
146 |
failureNonBlocking(uri, new FileRequestBody(FILE_BODY, BODY_OFFSETS[i])); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
147 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
148 |
} finally { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
149 |
Executor def = defaultClient().executor(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
150 |
if (def instanceof ExecutorService) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
151 |
((ExecutorService)def).shutdownNow(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
152 |
} |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
153 |
} |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
154 |
} |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
155 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
156 |
static void success(URI uri, HttpRequest.BodyProcessor processor) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
157 |
throws Exception |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
158 |
{ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
159 |
CompletableFuture<HttpResponse<Void>> cf; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
160 |
HttpRequest request = HttpRequest.newBuilder(uri) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
161 |
.POST(processor) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
162 |
.build(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
163 |
cf = defaultClient().sendAsync(request, discard(null)); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
164 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
165 |
HttpResponse<Void> resp = cf.get(30, TimeUnit.SECONDS); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
166 |
out.println("Response code: " + resp.statusCode()); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
167 |
check(resp.statusCode() == 200, "Expected 200, got ", resp.statusCode()); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
168 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
169 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
170 |
static void failureNonBlocking(URI uri, HttpRequest.BodyProcessor processor) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
171 |
throws Exception |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
172 |
{ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
173 |
CompletableFuture<HttpResponse<Void>> cf; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
174 |
HttpRequest request = HttpRequest.newBuilder(uri) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
175 |
.POST(processor) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
176 |
.build(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
177 |
cf = defaultClient().sendAsync(request, discard(null)); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
178 |
|
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
179 |
try { |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
180 |
HttpResponse<Void> r = cf.get(30, TimeUnit.SECONDS); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
181 |
throw new RuntimeException("Unexpected response: " + r.statusCode()); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
182 |
} catch (TimeoutException x) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
183 |
throw new RuntimeException("Unexpected timeout", x); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
184 |
} catch (ExecutionException expected) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
185 |
out.println("Caught expected: " + expected); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
186 |
check(expected.getCause() instanceof IOException, |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
187 |
"Expected cause IOException, but got: ", expected.getCause()); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
188 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
189 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
190 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
191 |
static void failureBlocking(URI uri, HttpRequest.BodyProcessor processor) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
192 |
throws Exception |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
193 |
{ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
194 |
HttpRequest request = HttpRequest.newBuilder(uri) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
195 |
.POST(processor) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
196 |
.build(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
197 |
try { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
198 |
HttpResponse<Void> r = defaultClient().send(request, discard(null)); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
199 |
throw new RuntimeException("Unexpected response: " + r.statusCode()); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
200 |
} catch (IOException expected) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
201 |
out.println("Caught expected: " + expected); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
202 |
} |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
203 |
} |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
204 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
205 |
static class Server extends Thread implements AutoCloseable { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
206 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
207 |
static String RESPONSE = "HTTP/1.1 200 OK\r\n" + |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
208 |
"Connection: close\r\n"+ |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
209 |
"Content-length: 0\r\n\r\n"; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
210 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
211 |
private final ServerSocket ss; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
212 |
private volatile boolean closed; |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
213 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
214 |
Server() throws IOException { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
215 |
super("Test-Server"); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
216 |
ss = new ServerSocket(0); this.start(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
217 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
218 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
219 |
int getPort() { return ss.getLocalPort(); } |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
220 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
221 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
222 |
public void run() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
223 |
int count = 0; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
224 |
int offset = 0; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
225 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
226 |
while (!closed) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
227 |
try (Socket s = ss.accept()) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
228 |
InputStream is = s.getInputStream(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
229 |
readRequestHeaders(is); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
230 |
byte[] ba = new byte[1024]; |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
231 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
232 |
int length = BODY_LENGTHS[count % 3]; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
233 |
length += BODY_OFFSETS[offset]; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
234 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
235 |
is.readNBytes(ba, 0, length); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
236 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
237 |
OutputStream os = s.getOutputStream(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
238 |
os.write(RESPONSE.getBytes(US_ASCII)); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
239 |
count++; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
240 |
if (count % 6 == 0) // 6 is the number of failure requests per offset |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
241 |
offset++; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
242 |
} catch (IOException e) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
243 |
if (!closed) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
244 |
System.out.println("Unexpected" + e); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
245 |
} |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
246 |
} |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
247 |
} |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
248 |
|
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
249 |
@Override |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
250 |
public void close() { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
251 |
if (closed) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
252 |
return; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
253 |
closed = true; |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
254 |
try { |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
255 |
ss.close(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
256 |
} catch (IOException e) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
257 |
throw new UncheckedIOException("Unexpected", e); |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
258 |
} |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
259 |
} |
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
260 |
} |
42460
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
261 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
262 |
static final byte[] requestEnd = new byte[] {'\r', '\n', '\r', '\n' }; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
263 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
264 |
// Read until the end of a HTTP request headers |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
265 |
static void readRequestHeaders(InputStream is) throws IOException { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
266 |
int requestEndCount = 0, r; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
267 |
while ((r = is.read()) != -1) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
268 |
if (r == requestEnd[requestEndCount]) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
269 |
requestEndCount++; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
270 |
if (requestEndCount == 4) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
271 |
break; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
272 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
273 |
} else { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
274 |
requestEndCount = 0; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
275 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
276 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
277 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
278 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
279 |
static int fileSize(Path p) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
280 |
try { return (int) Files.size(p); } |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
281 |
catch (IOException x) { throw new UncheckedIOException(x); } |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
282 |
} |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
283 |
|
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
284 |
static boolean check(boolean cond, Object... failedArgs) { |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
285 |
if (cond) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
286 |
return true; |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
287 |
// We are going to fail... |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
288 |
StringBuilder sb = new StringBuilder(); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
289 |
for (Object o : failedArgs) |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
290 |
sb.append(o); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
291 |
throw new RuntimeException(sb.toString()); |
7133f144981a
8170648: Move java.net.http package out of Java SE to incubator namespace
michaelm
parents:
36433
diff
changeset
|
292 |
} |
36433
dcbc230cfa4f
8151441: Completion result in httpclient Exchange.java lost
michaelm
parents:
diff
changeset
|
293 |
} |