fix RESOURCE_LEAK (#5616)

This commit is contained in:
Kdump 2020-10-07 18:47:25 +08:00 committed by GitHub
parent a785be4f2b
commit 5fa2ae4903
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 16 deletions

View File

@ -209,4 +209,4 @@ public class AgentClassLoader extends ClassLoader {
private final JarFile jarFile;
private final File sourceFile;
}
}
}

View File

@ -98,4 +98,4 @@ public class IgnoreConfigInitializer {
}
throw new ConfigNotFoundException("Fail to load ignore config file.");
}
}
}

View File

@ -39,23 +39,24 @@ public class SpanProcessor {
}
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);
}
}
}