Skip to content

Commit 3f2682b

Browse files
authored
HADOOP-17622. Avoid usage of deprecated IOUtils#cleanup API. (apache#2862)
Signed-off-by: Takanobu Asanuma <tasanuma@apache.org>
1 parent 26b8f67 commit 3f2682b

File tree

64 files changed

+102
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+102
-99
lines changed

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public void testHasFileDescriptor() throws IOException {
312312
.new LocalFSFileInputStream(path), 1024);
313313
assertNotNull(bis.getFileDescriptor());
314314
} finally {
315-
IOUtils.cleanup(null, bis);
315+
IOUtils.cleanupWithLogger(null, bis);
316316
}
317317
}
318318

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/metrics2/sink/TestFileSink.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void testFileSink() throws IOException {
115115
IOUtils.copyBytes(is, baos, 1024, true);
116116
outFileContent = new String(baos.toByteArray(), "UTF-8");
117117
} finally {
118-
IOUtils.cleanup(null, baos, is);
118+
IOUtils.cleanupWithLogger(null, baos, is);
119119
}
120120

121121
// Check the out file content. Should be something like the following:

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/unix/TestDomainSocket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,6 @@ public void run() {
759759
readerThread.join();
760760
Assert.assertFalse(failed.get());
761761
Assert.assertEquals(3, bytesRead.get());
762-
IOUtils.cleanup(null, socks);
762+
IOUtils.cleanupWithLogger(null, socks);
763763
}
764764
}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,8 @@ void join() {
618618
private synchronized void cleanUp() {
619619

620620
shouldServiceRun = false;
621-
IOUtils.cleanup(null, bpNamenode);
622-
IOUtils.cleanup(null, lifelineSender);
621+
IOUtils.cleanupWithLogger(null, bpNamenode);
622+
IOUtils.cleanupWithLogger(null, lifelineSender);
623623
bpos.shutdownActor(this);
624624
}
625625

@@ -992,7 +992,7 @@ public void close() {
992992
} catch (InterruptedException e) {
993993
Thread.currentThread().interrupt();
994994
}
995-
IOUtils.cleanup(null, lifelineNamenode);
995+
IOUtils.cleanupWithLogger(null, lifelineNamenode);
996996
}
997997

998998
@Override

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockReceiver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public void close() throws IOException {
369369
streams.close();
370370
}
371371
if (replicaHandler != null) {
372-
IOUtils.cleanup(null, replicaHandler);
372+
IOUtils.cleanupWithLogger(null, replicaHandler);
373373
replicaHandler = null;
374374
}
375375
if (measuredFlushTime) {

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockScanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public synchronized void addVolumeScanner(FsVolumeReference ref) {
252252
if (!success) {
253253
// If we didn't create a new VolumeScanner object, we don't
254254
// need this reference to the volume.
255-
IOUtils.cleanup(null, ref);
255+
IOUtils.cleanupWithLogger(null, ref);
256256
}
257257
}
258258
}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataXceiver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public void requestShortCircuitFds(final ExtendedBlock blk,
432432
blk.getBlockId(), dnR.getDatanodeUuid(), success));
433433
}
434434
if (fis != null) {
435-
IOUtils.cleanup(null, fis);
435+
IOUtils.cleanupWithLogger(null, fis);
436436
}
437437
}
438438
}
@@ -555,7 +555,7 @@ public void requestShortCircuitShm(String clientName) throws IOException {
555555
LOG.warn("Failed to shut down socket in error handler", e);
556556
}
557557
}
558-
IOUtils.cleanup(null, shmInfo);
558+
IOUtils.cleanupWithLogger(null, shmInfo);
559559
}
560560
}
561561

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/VolumeScanner.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ private long scanBlock(ExtendedBlock cblock, long bytesPerSec) {
451451
} catch (IOException e) {
452452
resultHandler.handle(block, e);
453453
} finally {
454-
IOUtils.cleanup(null, blockSender);
454+
IOUtils.cleanupWithLogger(null, blockSender);
455455
}
456456
metrics.incrBlockVerificationFailures();
457457
return -1;
@@ -674,13 +674,13 @@ public void run() {
674674
// Save the current position of all block iterators and close them.
675675
for (BlockIterator iter : blockIters) {
676676
saveBlockIterator(iter);
677-
IOUtils.cleanup(null, iter);
677+
IOUtils.cleanupWithLogger(null, iter);
678678
}
679679
} finally {
680680
VolumeScannerCBInjector.get().terminationCallBack(this);
681681
// When the VolumeScanner exits, release the reference we were holding
682682
// on the volume. This will allow the volume to be removed later.
683-
IOUtils.cleanup(null, ref);
683+
IOUtils.cleanupWithLogger(null, ref);
684684
}
685685
}
686686

@@ -767,7 +767,7 @@ public synchronized void disableBlockPoolId(String bpid) {
767767
if (iter.getBlockPoolId().equals(bpid)) {
768768
LOG.trace("{}: disabling scanning on block pool {}", this, bpid);
769769
i.remove();
770-
IOUtils.cleanup(null, iter);
770+
IOUtils.cleanupWithLogger(null, iter);
771771
if (curBlockIter == iter) {
772772
curBlockIter = null;
773773
}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/checker/DatasetVolumeChecker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public void call(Set<FsVolumeSpi> ignored1,
234234
}
235235
}), MoreExecutors.directExecutor());
236236
} else {
237-
IOUtils.cleanup(null, reference);
237+
IOUtils.cleanupWithLogger(null, reference);
238238
if (numVolumes.decrementAndGet() == 0) {
239239
latch.countDown();
240240
}
@@ -311,7 +311,7 @@ public boolean checkVolume(
311311
);
312312
return true;
313313
} else {
314-
IOUtils.cleanup(null, volumeReference);
314+
IOUtils.cleanupWithLogger(null, volumeReference);
315315
}
316316
return false;
317317
}
@@ -404,7 +404,7 @@ private void markFailed() {
404404
}
405405

406406
private void cleanup() {
407-
IOUtils.cleanup(null, reference);
407+
IOUtils.cleanupWithLogger(null, reference);
408408
invokeCallback();
409409
}
410410

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedBlockReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private Peer newConnectedPeer(ExtendedBlock b, InetSocketAddress addr,
158158
return peer;
159159
} finally {
160160
if (!success) {
161-
IOUtils.cleanup(null, peer);
161+
IOUtils.cleanupWithLogger(null, peer);
162162
IOUtils.closeSocket(sock);
163163
}
164164
}

0 commit comments

Comments
 (0)