From cb809b11161001e4f6063124bcec4aaa7cbcbde0 Mon Sep 17 00:00:00 2001 From: Nandakumar Vadivelu Date: Tue, 17 Sep 2024 18:04:30 +0530 Subject: [PATCH] HDDS-11181. Cleanup of unnecessary try-catch block. --- ...eManagerProtocolClientSideTranslatorPB.java | 8 ++------ .../hadoop/ozone/om/OzoneManagerUtils.java | 8 ++------ .../hadoop/ozone/s3/OzoneClientCache.java | 2 -- .../hadoop/ozone/freon/RandomKeyGenerator.java | 18 +++--------------- .../shell/volume/DeleteVolumeHandler.java | 6 +----- 5 files changed, 8 insertions(+), 34 deletions(-) diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java index bdd1428b16d..432b55051da 100644 --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OzoneManagerProtocolClientSideTranslatorPB.java @@ -2117,12 +2117,8 @@ public OzoneFileStatus getFileStatus(OmKeyArgs args) throws IOException { .setGetFileStatusRequest(req) .build(); - final GetFileStatusResponse resp; - try { - resp = handleError(submitRequest(omRequest)).getGetFileStatusResponse(); - } catch (IOException e) { - throw e; - } + final GetFileStatusResponse resp = handleError(submitRequest(omRequest)) + .getGetFileStatusResponse(); return OzoneFileStatus.getFromProtobuf(resp.getStatus()); } diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerUtils.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerUtils.java index 5a4ff643157..2301bbbdbf2 100644 --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerUtils.java +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerUtils.java @@ -164,12 +164,8 @@ private static OmBucketInfo resolveBucketInfoLink( * buck-src has the actual BucketLayout that will be used by the * links. */ - try { - return resolveBucketInfoLink(metadataManager, - buckInfo.getSourceVolume(), buckInfo.getSourceBucket(), visited); - } catch (IOException e) { - throw e; - } + return resolveBucketInfoLink(metadataManager, buckInfo.getSourceVolume(), + buckInfo.getSourceBucket(), visited); } return buckInfo; } diff --git a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/OzoneClientCache.java b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/OzoneClientCache.java index 4f08527668c..7614c4933a8 100644 --- a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/OzoneClientCache.java +++ b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/OzoneClientCache.java @@ -154,8 +154,6 @@ private void setCertificate(String omServiceID, } } catch (CertificateException ce) { throw new IOException(ce); - } catch (IOException e) { - throw e; } finally { if (certClient != null) { certClient.close(); diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/RandomKeyGenerator.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/RandomKeyGenerator.java index c964676f266..58b62d22b98 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/RandomKeyGenerator.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/RandomKeyGenerator.java @@ -355,11 +355,7 @@ public Void call() throws Exception { // wait until all keys are added or exception occurred. while ((numberOfKeysAdded.get() != totalKeyCount) && exception == null) { - try { - Thread.sleep(CHECK_INTERVAL_MILLIS); - } catch (InterruptedException e) { - throw e; - } + Thread.sleep(CHECK_INTERVAL_MILLIS); } executor.shutdown(); executor.awaitTermination(Integer.MAX_VALUE, TimeUnit.MILLISECONDS); @@ -373,11 +369,7 @@ public Void call() throws Exception { if (validateExecutor != null) { while (!validationQueue.isEmpty()) { - try { - Thread.sleep(CHECK_INTERVAL_MILLIS); - } catch (InterruptedException e) { - throw e; - } + Thread.sleep(CHECK_INTERVAL_MILLIS); } validateExecutor.shutdown(); validateExecutor.awaitTermination(Integer.MAX_VALUE, @@ -421,11 +413,7 @@ private void doCleanObjects() throws InterruptedException { // wait until all Buckets are cleaned or exception occurred. while ((numberOfBucketsCleaned.get() != totalBucketCount) && exception == null) { - try { - Thread.sleep(CHECK_INTERVAL_MILLIS); - } catch (InterruptedException e) { - throw e; - } + Thread.sleep(CHECK_INTERVAL_MILLIS); } } catch (InterruptedException e) { LOG.error("Failed to wait until all Buckets are cleaned", e); diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/DeleteVolumeHandler.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/DeleteVolumeHandler.java index 8cc80502386..00270310737 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/DeleteVolumeHandler.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/DeleteVolumeHandler.java @@ -227,11 +227,7 @@ private void doCleanBuckets() throws InterruptedException { // wait until all Buckets are cleaned or exception occurred. while (numberOfBucketsCleaned.get() != totalBucketCount && exception == null) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - throw e; - } + Thread.sleep(100); } } catch (InterruptedException e) { LOG.error("Failed to wait until all Buckets are cleaned", e);