HBASE-25646: Possible Resource Leak in CatalogJanitor #3036

Close the stream using a try-with-resources block.

Reviewed-by: Aman Poonia <aman.poonia.29@gmail.com>
Signed-off-by: Wei-Chiu Chuang <weichiu@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
Signed-off-by: Bharath Vissapragada <bharathv@apache.org>
This commit is contained in:
Narges Shadab 2021-03-09 09:07:02 -08:00 committed by GitHub
parent 109bd24065
commit 573daed419
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -407,9 +407,8 @@ public class CatalogJanitor extends ScheduledChore {
private static void checkLog4jProperties() {
String filename = "log4j.properties";
try {
final InputStream inStream =
CatalogJanitor.class.getClassLoader().getResourceAsStream(filename);
try (final InputStream inStream =
CatalogJanitor.class.getClassLoader().getResourceAsStream(filename)) {
if (inStream != null) {
new Properties().load(inStream);
} else {