|
14 | 14 | import io.opentelemetry.opamp.client.internal.request.delay.PeriodicTaskExecutor; |
15 | 15 | import io.opentelemetry.opamp.client.internal.response.Response; |
16 | 16 | import java.io.IOException; |
17 | | -import java.io.OutputStream; |
18 | 17 | import java.time.Duration; |
19 | 18 | import java.util.Objects; |
20 | 19 | import java.util.Optional; |
@@ -135,7 +134,7 @@ private void doSendRequest() { |
135 | 134 |
|
136 | 135 | byte[] data = agentToServer.encodeByteString().toByteArray(); |
137 | 136 | CompletableFuture<HttpSender.Response> future = |
138 | | - requestSender.send(new ByteArrayWriter(data), data.length); |
| 137 | + requestSender.send(outputStream -> outputStream.write(data), data.length); |
139 | 138 | try (HttpSender.Response response = future.get(30, TimeUnit.SECONDS)) { |
140 | 139 | if (isSuccessful(response)) { |
141 | 140 | handleSuccessResponse( |
@@ -201,17 +200,4 @@ private void handleErrorResponse(ServerErrorResponse errorResponse) { |
201 | 200 | private Callback getCallback() { |
202 | 201 | return Objects.requireNonNull(callback); |
203 | 202 | } |
204 | | - |
205 | | - private static class ByteArrayWriter implements HttpSender.BodyWriter { |
206 | | - private final byte[] data; |
207 | | - |
208 | | - private ByteArrayWriter(byte[] data) { |
209 | | - this.data = data; |
210 | | - } |
211 | | - |
212 | | - @Override |
213 | | - public void writeTo(OutputStream outputStream) throws IOException { |
214 | | - outputStream.write(data); |
215 | | - } |
216 | | - } |
217 | 203 | } |
0 commit comments