github-code-scanning[bot] commented on code in PR #14040:
URL: https://github.com/apache/druid/pull/14040#discussion_r1160179500
##########
extensions-core/s3-extensions/src/test/java/org/apache/druid/storage/s3/S3TaskLogsTest.java:
##########
@@ -434,6 +460,32 @@
Assert.assertEquals(REPORT_CONTENTS, report);
}
+ @Test
+ public void test_status_fetch() throws IOException
+ {
+ EasyMock.reset(s3Client);
+ String logPath = TEST_PREFIX + "/" + KEY_1 + "/status.json";
+ ObjectMetadata objectMetadata = new ObjectMetadata();
+ objectMetadata.setContentLength(STATUS_CONTENTS.length());
+ EasyMock.expect(s3Client.getObjectMetadata(TEST_BUCKET,
logPath)).andReturn(objectMetadata);
+ S3Object s3Object = new S3Object();
+ s3Object.setObjectContent(new
ByteArrayInputStream(STATUS_CONTENTS.getBytes(StandardCharsets.UTF_8)));
+ GetObjectRequest getObjectRequest = new GetObjectRequest(TEST_BUCKET,
logPath);
+ getObjectRequest.setRange(0, STATUS_CONTENTS.length() - 1);
+ getObjectRequest.withMatchingETagConstraint(objectMetadata.getETag());
+ EasyMock.expect(s3Client.getObject(getObjectRequest)).andReturn(s3Object);
+ EasyMock.replay(s3Client);
+
+ S3TaskLogs s3TaskLogs = getS3TaskLogs();
+
+ Optional<InputStream> inputStreamOptional =
s3TaskLogs.streamTaskStatus(KEY_1);
+ String report = new BufferedReader(
+ new InputStreamReader(inputStreamOptional.get(),
StandardCharsets.UTF_8))
Review Comment:
## Potential input resource leak
This InputStreamReader is not always closed on method exit.
[Show more
details](https://github.com/apache/druid/security/code-scanning/4732)
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]