author | chegar |
Tue, 18 Jun 2019 18:38:53 +0100 | |
changeset 55405 | 17f24c0e2f01 |
parent 49765 | ee6f7a61f3a5 |
child 56451 | 9585061fdb04 |
permissions | -rw-r--r-- |
48379
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
1 |
/* |
49765 | 2 |
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. |
48379
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
4 |
* |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
8 |
* |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
13 |
* accompanied this code). |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
14 |
* |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
18 |
* |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
21 |
* questions. |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
22 |
*/ |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
23 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
24 |
import java.io.FileNotFoundException; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
25 |
import java.nio.ByteBuffer; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
26 |
import java.nio.file.Files; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
27 |
import java.nio.file.Path; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
28 |
import java.nio.file.Paths; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
29 |
import java.nio.file.OpenOption; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
30 |
import java.util.List; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
31 |
import java.util.concurrent.CompletableFuture; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
32 |
import java.util.concurrent.Flow; |
49765 | 33 |
import java.net.http.HttpHeaders; |
34 |
import java.net.http.HttpRequest.BodyPublishers; |
|
35 |
import java.net.http.HttpResponse.BodyHandler; |
|
36 |
import java.net.http.HttpResponse.ResponseInfo; |
|
37 |
import java.net.http.HttpResponse.BodyHandlers; |
|
38 |
import java.net.http.HttpResponse.BodySubscriber; |
|
39 |
import java.net.http.HttpResponse.BodySubscribers; |
|
40 |
import java.util.function.Function; |
|
48379
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
41 |
import org.testng.annotations.DataProvider; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
42 |
import org.testng.annotations.Test; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
43 |
import static java.nio.charset.StandardCharsets.UTF_8; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
44 |
import static java.nio.file.StandardOpenOption.CREATE; |
49765 | 45 |
import static java.nio.file.StandardOpenOption.DELETE_ON_CLOSE; |
48379
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
46 |
import static java.nio.file.StandardOpenOption.WRITE; |
49765 | 47 |
import static java.nio.file.StandardOpenOption.READ; |
48379
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
48 |
import static org.testng.Assert.assertThrows; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
49 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
50 |
/* |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
51 |
* @test |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
52 |
* @summary Basic tests for API specified exceptions from Publisher, Handler, |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
53 |
* and Subscriber convenience static factory methods. |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
54 |
* @run testng SubscriberPublisherAPIExceptions |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
55 |
*/ |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
56 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
57 |
public class SubscriberPublisherAPIExceptions { |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
58 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
59 |
static final Class<NullPointerException> NPE = NullPointerException.class; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
60 |
static final Class<IllegalArgumentException> IAE = IllegalArgumentException.class; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
61 |
static final Class<IndexOutOfBoundsException> IOB = IndexOutOfBoundsException.class; |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
62 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
63 |
@Test |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
64 |
public void publisherAPIExceptions() { |
49765 | 65 |
assertThrows(NPE, () -> BodyPublishers.ofByteArray(null)); |
66 |
assertThrows(NPE, () -> BodyPublishers.ofByteArray(null, 0, 1)); |
|
67 |
assertThrows(IOB, () -> BodyPublishers.ofByteArray(new byte[100], 0, 101)); |
|
68 |
assertThrows(IOB, () -> BodyPublishers.ofByteArray(new byte[100], 1, 100)); |
|
69 |
assertThrows(IOB, () -> BodyPublishers.ofByteArray(new byte[100], -1, 10)); |
|
70 |
assertThrows(IOB, () -> BodyPublishers.ofByteArray(new byte[100], 99, 2)); |
|
71 |
assertThrows(IOB, () -> BodyPublishers.ofByteArray(new byte[1], -100, 1)); |
|
72 |
assertThrows(NPE, () -> BodyPublishers.ofByteArray(null)); |
|
73 |
assertThrows(NPE, () -> BodyPublishers.ofFile(null)); |
|
74 |
assertThrows(NPE, () -> BodyPublishers.ofInputStream(null)); |
|
75 |
assertThrows(NPE, () -> BodyPublishers.ofString(null)); |
|
76 |
assertThrows(NPE, () -> BodyPublishers.ofString("A", null)); |
|
77 |
assertThrows(NPE, () -> BodyPublishers.ofString(null, UTF_8)); |
|
78 |
assertThrows(NPE, () -> BodyPublishers.ofString(null, null)); |
|
48379
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
79 |
} |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
80 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
81 |
@DataProvider(name = "nonExistentFiles") |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
82 |
public Object[][] nonExistentFiles() { |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
83 |
List<Path> paths = List.of(Paths.get("doesNotExist"), |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
84 |
Paths.get("tsixEtoNseod"), |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
85 |
Paths.get("doesNotExist2")); |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
86 |
paths.forEach(p -> { |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
87 |
if (Files.exists(p)) |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
88 |
throw new AssertionError("Unexpected " + p); |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
89 |
}); |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
90 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
91 |
return paths.stream().map(p -> new Object[] { p }).toArray(Object[][]::new); |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
92 |
} |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
93 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
94 |
@Test(dataProvider = "nonExistentFiles", expectedExceptions = FileNotFoundException.class) |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
95 |
public void fromFileCheck(Path path) throws Exception { |
49765 | 96 |
BodyPublishers.ofFile(path); |
48379
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
97 |
} |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
98 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
99 |
@Test |
49765 | 100 |
public void handlerAPIExceptions() throws Exception { |
48379
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
101 |
Path path = Paths.get(".").resolve("tt"); |
49765 | 102 |
Path file = Files.createFile(Paths.get(".").resolve("aFile")); |
103 |
Path doesNotExist = Paths.get(".").resolve("doneNotExist"); |
|
104 |
if (Files.exists(doesNotExist)) |
|
105 |
throw new AssertionError("Unexpected " + doesNotExist); |
|
106 |
||
107 |
assertThrows(NPE, () -> BodyHandlers.ofByteArrayConsumer(null)); |
|
108 |
assertThrows(NPE, () -> BodyHandlers.ofFile(null)); |
|
109 |
assertThrows(NPE, () -> BodyHandlers.ofFile(null, CREATE, WRITE)); |
|
110 |
assertThrows(NPE, () -> BodyHandlers.ofFile(path, (OpenOption[])null)); |
|
111 |
assertThrows(NPE, () -> BodyHandlers.ofFile(path, new OpenOption[] {null})); |
|
112 |
assertThrows(NPE, () -> BodyHandlers.ofFile(path, new OpenOption[] {CREATE, null})); |
|
113 |
assertThrows(NPE, () -> BodyHandlers.ofFile(path, new OpenOption[] {null, CREATE})); |
|
114 |
assertThrows(NPE, () -> BodyHandlers.ofFile(null, (OpenOption[])null)); |
|
115 |
assertThrows(NPE, () -> BodyHandlers.ofFileDownload(null, CREATE, WRITE)); |
|
116 |
assertThrows(NPE, () -> BodyHandlers.ofFileDownload(path, (OpenOption[])null)); |
|
117 |
assertThrows(NPE, () -> BodyHandlers.ofFileDownload(path, new OpenOption[] {null})); |
|
118 |
assertThrows(NPE, () -> BodyHandlers.ofFileDownload(path, new OpenOption[] {CREATE, null})); |
|
119 |
assertThrows(NPE, () -> BodyHandlers.ofFileDownload(path, new OpenOption[] {null, CREATE})); |
|
120 |
assertThrows(NPE, () -> BodyHandlers.ofFileDownload(null, (OpenOption[])null)); |
|
121 |
assertThrows(IAE, () -> BodyHandlers.ofFileDownload(file, CREATE, WRITE)); |
|
122 |
assertThrows(IAE, () -> BodyHandlers.ofFileDownload(doesNotExist, CREATE, WRITE)); |
|
123 |
assertThrows(NPE, () -> BodyHandlers.ofString(null)); |
|
124 |
assertThrows(NPE, () -> BodyHandlers.buffering(null, 1)); |
|
125 |
assertThrows(IAE, () -> BodyHandlers.buffering(new NoOpHandler(), 0)); |
|
126 |
assertThrows(IAE, () -> BodyHandlers.buffering(new NoOpHandler(), -1)); |
|
127 |
assertThrows(IAE, () -> BodyHandlers.buffering(new NoOpHandler(), Integer.MIN_VALUE)); |
|
128 |
||
129 |
// implementation specific exceptions |
|
130 |
assertThrows(IAE, () -> BodyHandlers.ofFile(path, READ)); |
|
131 |
assertThrows(IAE, () -> BodyHandlers.ofFile(path, DELETE_ON_CLOSE)); |
|
132 |
assertThrows(IAE, () -> BodyHandlers.ofFile(path, READ, DELETE_ON_CLOSE)); |
|
133 |
assertThrows(IAE, () -> BodyHandlers.ofFileDownload(path, DELETE_ON_CLOSE)); |
|
48379
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
134 |
} |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
135 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
136 |
@Test |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
137 |
public void subscriberAPIExceptions() { |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
138 |
Path path = Paths.get(".").resolve("tt"); |
49765 | 139 |
assertThrows(NPE, () -> BodySubscribers.ofByteArrayConsumer(null)); |
140 |
assertThrows(NPE, () -> BodySubscribers.ofFile(null)); |
|
141 |
assertThrows(NPE, () -> BodySubscribers.ofFile(null, CREATE, WRITE)); |
|
142 |
assertThrows(NPE, () -> BodySubscribers.ofFile(path, (OpenOption[])null)); |
|
143 |
assertThrows(NPE, () -> BodySubscribers.ofFile(path, new OpenOption[] {null})); |
|
144 |
assertThrows(NPE, () -> BodySubscribers.ofFile(path, new OpenOption[] {CREATE, null})); |
|
145 |
assertThrows(NPE, () -> BodySubscribers.ofFile(path, new OpenOption[] {null, CREATE})); |
|
146 |
assertThrows(NPE, () -> BodySubscribers.ofFile(null, (OpenOption[])null)); |
|
147 |
assertThrows(NPE, () -> BodySubscribers.ofString(null)); |
|
148 |
assertThrows(NPE, () -> BodySubscribers.buffering(null, 1)); |
|
149 |
assertThrows(IAE, () -> BodySubscribers.buffering(new NoOpSubscriber(), 0)); |
|
150 |
assertThrows(IAE, () -> BodySubscribers.buffering(new NoOpSubscriber(), -1)); |
|
151 |
assertThrows(IAE, () -> BodySubscribers.buffering(new NoOpSubscriber(), Integer.MIN_VALUE)); |
|
152 |
assertThrows(NPE, () -> BodySubscribers.mapping(null, Function.identity())); |
|
153 |
assertThrows(NPE, () -> BodySubscribers.mapping(BodySubscribers.ofByteArray(), null)); |
|
154 |
assertThrows(NPE, () -> BodySubscribers.mapping(null, null)); |
|
155 |
||
156 |
// implementation specific exceptions |
|
157 |
assertThrows(IAE, () -> BodySubscribers.ofFile(path, READ)); |
|
158 |
assertThrows(IAE, () -> BodySubscribers.ofFile(path, DELETE_ON_CLOSE)); |
|
159 |
assertThrows(IAE, () -> BodySubscribers.ofFile(path, READ, DELETE_ON_CLOSE)); |
|
48379
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
160 |
} |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
161 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
162 |
static class NoOpHandler implements BodyHandler<Void> { |
49765 | 163 |
@Override public BodySubscriber<Void> apply(ResponseInfo rinfo) { return null; } |
48379
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
164 |
} |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
165 |
|
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
166 |
static class NoOpSubscriber implements BodySubscriber<Void> { |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
167 |
@Override public void onSubscribe(Flow.Subscription subscription) { } |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
168 |
@Override public void onNext(List<ByteBuffer> item) { } |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
169 |
@Override public void onError(Throwable throwable) { } |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
170 |
@Override public void onComplete() { } |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
171 |
@Override public CompletableFuture<Void> getBody() { return null; } |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
172 |
} |
5382baab8371
8193698: Null handling in BodyPublisher, BodyHandler, and BodySubscriber convenience static factory methods
chegar
parents:
diff
changeset
|
173 |
} |