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>
(cherry picked from commit 573daed419)
This commit is contained in:
Narges Shadab 2021-03-09 09:07:02 -08:00 committed by Bharath Vissapragada
parent 321b5c7979
commit 884cb0bd2c
No known key found for this signature in database
GPG Key ID: 18AE42A0B5A93FA7
1 changed files with 2 additions and 3 deletions

View File

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