x22x22 commented on a change in pull request #5616:
URL: https://github.com/apache/skywalking/pull/5616#discussion_r499201275
##########
File path:
oap-server/server-receiver-plugin/zipkin-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/zipkin/handler/SpanProcessor.java
##########
@@ -39,37 +39,36 @@ public SpanProcessor(SourceReceiver receiver) {
}
void convert(ZipkinReceiverConfig config, SpanBytesDecoder decoder,
HttpServletRequest request) throws IOException {
- InputStream inputStream = getInputStream(request);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] buffer = new byte[2048];
- int readCntOnce;
+ try(InputStream inputStream = getInputStream(request)) {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ byte[] buffer = new byte[2048];
+ int readCntOnce;
- while ((readCntOnce = inputStream.read(buffer)) >= 0) {
- out.write(buffer, 0, readCntOnce);
- }
+ while ((readCntOnce = inputStream.read(buffer)) >= 0) {
+ out.write(buffer, 0, readCntOnce);
+ }
- List<Span> spanList = decoder.decodeList(out.toByteArray());
+ List<Span> spanList = decoder.decodeList(out.toByteArray());
- if (config.isNeedAnalysis()) {
- ZipkinSkyWalkingTransfer transfer = new ZipkinSkyWalkingTransfer();
- transfer.doTransfer(config, spanList);
- } else {
- SpanForward forward = new SpanForward(config, receiver);
- forward.send(spanList);
+ if (config.isNeedAnalysis()) {
+ ZipkinSkyWalkingTransfer transfer = new
ZipkinSkyWalkingTransfer();
+ transfer.doTransfer(config, spanList);
+ } else {
+ SpanForward forward = new SpanForward(config, receiver);
+ forward.send(spanList);
+ }
}
}
private InputStream getInputStream(HttpServletRequest request) throws
IOException {
- InputStream requestInStream;
-
String headEncoding = request.getHeader("accept-encoding");
if (headEncoding != null && (headEncoding.indexOf("gzip") != -1)) {
- requestInStream = new GZIPInputStream(request.getInputStream());
+ try(InputStream requestInStream = new
GZIPInputStream(request.getInputStream());){
+ return requestInStream;
Review comment:
Restored code.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]