Skip to content

Commit 9ca9268

Browse files
committed
HDFS-17373. Fix connection leak in FolderRenamePending
1 parent 5ad7737 commit 9ca9268

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azure/NativeAzureFileSystem.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,12 @@ public FolderRenamePending(Path redoFile, NativeAzureFileSystem fs)
160160

161161
// open redo file
162162
Path f = redoFile;
163-
FSDataInputStream input = fs.open(f);
164-
byte[] bytes = new byte[MAX_RENAME_PENDING_FILE_SIZE];
165-
int l = input.read(bytes);
163+
int l;
164+
byte[] bytes;
165+
try (FSDataInputStream input = fs.open(f)) {
166+
bytes = new byte[MAX_RENAME_PENDING_FILE_SIZE];
167+
l = input.read(bytes);
168+
}
166169
if (l <= 0) {
167170
// Jira HADOOP-12678 -Handle empty rename pending metadata file during
168171
// atomic rename in redo path. If during renamepending file is created

0 commit comments

Comments
 (0)