ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adorosz...@apache.org
Subject ambari git commit: AMBARI-19149. Code cleanup: identical catch blocks
Date Thu, 25 May 2017 07:44:04 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk c2409e740 -> 1adb70d53


AMBARI-19149. Code cleanup: identical catch blocks


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1adb70d5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1adb70d5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1adb70d5

Branch: refs/heads/trunk
Commit: 1adb70d53041e64ac7e844592453cd3085704105
Parents: c2409e7
Author: Attila Doroszlai <adoroszlai@hortonworks.com>
Authored: Tue May 23 17:31:57 2017 +0200
Committer: Attila Doroszlai <adoroszlai@hortonworks.com>
Committed: Thu May 25 09:46:04 2017 +0200

----------------------------------------------------------------------
 .../ServiceComponentHostEventWrapper.java       |  4 +---
 .../server/api/handlers/UpdateHandler.java      |  4 +---
 .../query/render/ClusterBlueprintRenderer.java  |  5 +---
 .../checks/DatabaseConsistencyCheckHelper.java  |  4 +---
 .../AmbariManagementControllerImpl.java         | 22 +-----------------
 .../internal/ClientConfigResourceProvider.java  |  2 --
 .../ClusterStackVersionResourceProvider.java    |  4 +---
 .../StackDependencyResourceProvider.java        |  6 +----
 .../ambari/server/orm/helpers/ScriptRunner.java | 10 ++------
 .../scheduler/ExecutionScheduleManager.java     |  4 +---
 .../security/encryption/AESEncryptor.java       | 24 +++-----------------
 .../encryption/MasterKeyServiceImpl.java        |  6 -----
 .../kerberos/ADKerberosOperationHandler.java    |  5 +---
 .../kerberos/IPAKerberosOperationHandler.java   |  6 +----
 .../kerberos/KerberosOperationHandler.java      |  6 -----
 .../topology/ClusterConfigurationRequest.java   |  4 +---
 .../ambari/server/topology/TopologyManager.java |  5 +---
 .../apache/ambari/server/utils/HTTPUtils.java   |  3 ---
 .../ambari/server/utils/ShellCommandUtil.java   | 23 ++++---------------
 .../server/agent/LocalAgentSimulator.java       |  5 +---
 20 files changed, 23 insertions(+), 129 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ServiceComponentHostEventWrapper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ServiceComponentHostEventWrapper.java
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ServiceComponentHostEventWrapper.java
index b9df962..7bce6b8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ServiceComponentHostEventWrapper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ServiceComponentHostEventWrapper.java
@@ -58,9 +58,7 @@ public class ServiceComponentHostEventWrapper {
       try {
         eventJson = StageUtils.jaxbToString(event);
         return eventJson;
-      } catch (JAXBException e) {
-        throw new RuntimeException("Couldn't get json", e);
-      } catch (IOException e) {
+      } catch (JAXBException | IOException e) {
         throw new RuntimeException("Couldn't get json", e);
       }
     } else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/UpdateHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/UpdateHandler.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/UpdateHandler.java
index d0c11f2..2f1af51 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/UpdateHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/handlers/UpdateHandler.java
@@ -53,9 +53,7 @@ public class UpdateHandler extends BaseManagementHandler {
 
     } catch (AuthorizationException e) {
       result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.FORBIDDEN, e.getMessage()));
-    } catch (UnsupportedPropertyException e) {
-      result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST, e));
-    } catch (IllegalArgumentException e) {
+    } catch (UnsupportedPropertyException | IllegalArgumentException e) {
       result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.BAD_REQUEST, e));
     } catch (NoSuchParentResourceException e) {
       result = new ResultImpl(new ResultStatus(ResultStatus.STATUS.NOT_FOUND, e));

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
index 3b4ae16..b00391a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
@@ -188,12 +188,9 @@ public class ClusterBlueprintRenderer extends BaseRenderer implements
Renderer {
     ClusterTopology topology;
     try {
       topology = createClusterTopology(clusterNode);
-    } catch (InvalidTopologyTemplateException e) {
+    } catch (InvalidTopologyTemplateException | InvalidTopologyException e) {
       //todo
       throw new RuntimeException("Unable to process blueprint export request: " + e, e);
-    } catch (InvalidTopologyException e) {
-      //todo:
-      throw new RuntimeException("Unable to process blueprint export request: " + e, e);
     }
 
     BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology);

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
index 7c40c83..26ebd99 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
@@ -1073,9 +1073,7 @@ public class DatabaseConsistencyCheckHelper {
           error("You have non selected configs: {} for service {} from cluster {}!", StringUtils.join(serviceConfig.get(serviceName),
","), serviceName, clusterName);
         }
       }
-    } catch (SQLException e) {
-      LOG.error("Exception occurred during complex service check procedure: ", e);
-    } catch (AmbariException e) {
+    } catch (SQLException | AmbariException e) {
       LOG.error("Exception occurred during complex service check procedure: ", e);
     } finally {
       if (rs != null) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 9660488..68af5f7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -3637,7 +3637,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     for (ServiceComponentHostRequest request : requests) {
       try {
         response.addAll(getHostComponents(request));
-      } catch (ServiceComponentHostNotFoundException e) {
+      } catch (ServiceComponentHostNotFoundException | ServiceComponentNotFoundException
| ServiceNotFoundException e) {
         if (requests.size() == 1) {
           // only throw exception if 1 request.
           // there will be > 1 request in case of OR predicate
@@ -3645,26 +3645,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
         } else {
           LOG.debug("Ignoring not found exception due to other requests", e);
         }
-      } catch (ServiceNotFoundException e) {
-        if (requests.size() == 1) {
-          // only throw exception if 1 request.
-          // there will be > 1 request in case of OR predicate
-          // In 'OR' case, a host_component may be included in predicate
-          // that has no corresponding service
-          throw e;
-        } else {
-          LOG.debug("Ignoring not found exception due to other requests", e);
-        }
-      } catch (ServiceComponentNotFoundException e) {
-        if (requests.size() == 1) {
-          // only throw exception if 1 request.
-          // there will be > 1 request in case of OR predicate
-          // In 'OR' case, a host_component may be included in predicate
-          // that has no corresponding component
-          throw e;
-        } else {
-          LOG.debug("Ignoring not found exception due to other requests", e);
-        }
       } catch (ParentObjectNotFoundException e) {
         // If there is only one request, always throw exception.
         // There will be > 1 request in case of OR predicate.

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
index de262b5..4dfcc3d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
@@ -478,8 +478,6 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
         commandFiles.add(jsonFile);
         pythonCompressFilesCmds.add(cmd);
 
-      } catch (AmbariException e) {
-        throw new SystemException("Controller error ", e);
       } catch (IOException e) {
         throw new SystemException("Controller error ", e);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
index c2de5f1..ca90f09 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
@@ -886,9 +886,7 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
 
         return getRequestStatus(null);
       }
-    } catch (AmbariException e) {
-      throw new SystemException("Cannot perform request", e);
-    } catch (InterruptedException e) {
+    } catch (AmbariException | InterruptedException e) {
       throw new SystemException("Cannot perform request", e);
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDependencyResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDependencyResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDependencyResourceProvider.java
index 82f9118..8b69c6a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDependencyResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDependencyResourceProvider.java
@@ -123,11 +123,7 @@ public class StackDependencyResourceProvider extends AbstractResourceProvider
{
       try {
         resources.addAll(getDependencyResources(properties,
             getRequestPropertyIds(request, predicate)));
-      } catch (NoSuchResourceException e) {
-        if (requestProps.size() == 1) {
-          throw e;
-        }
-      } catch (NoSuchParentResourceException e) {
+      } catch (NoSuchResourceException | NoSuchParentResourceException e) {
         if (requestProps.size() == 1) {
           throw e;
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/ScriptRunner.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/ScriptRunner.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/ScriptRunner.java
index 1afd638..7bfaa06 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/ScriptRunner.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/helpers/ScriptRunner.java
@@ -107,9 +107,7 @@ public class ScriptRunner {
       } finally {
         connection.setAutoCommit(originalAutoCommit);
       }
-    } catch (IOException e) {
-      throw e;
-    } catch (SQLException e) {
+    } catch (IOException | SQLException e) {
       throw e;
     } catch (Exception e) {
       throw new RuntimeException("Error running script.  Cause: " + e, e);
@@ -204,11 +202,7 @@ public class ScriptRunner {
       if (!autoCommit) {
         conn.commit();
       }
-    } catch (SQLException e) {
-      printlnError("Error executing: " + command);
-      printlnError(e);
-      throw e;
-    } catch (IOException e) {
+    } catch (SQLException | IOException e) {
       printlnError("Error executing: " + command);
       printlnError(e);
       throw e;

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java
b/ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java
index 853733c..91f642e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/scheduler/ExecutionScheduleManager.java
@@ -131,9 +131,7 @@ public class ExecutionScheduleManager {
 
     try {
       buildApiClient();
-    } catch (NoSuchAlgorithmException e) {
-      throw new RuntimeException(e);
-    } catch (KeyManagementException e) {
+    } catch (NoSuchAlgorithmException | KeyManagementException e) {
       throw new RuntimeException(e);
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/AESEncryptor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/AESEncryptor.java
b/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/AESEncryptor.java
index b63264b..ab3953d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/AESEncryptor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/AESEncryptor.java
@@ -58,15 +58,7 @@ public class AESEncryptor {
       dcipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
       byte[] iv = ecipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV();
       dcipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(iv));
-    } catch (NoSuchAlgorithmException e) {
-      e.printStackTrace();
-    } catch (NoSuchPaddingException e) {
-      e.printStackTrace();
-    } catch (InvalidKeyException e) {
-      e.printStackTrace();
-    } catch (InvalidParameterSpecException e) {
-      e.printStackTrace();
-    } catch (InvalidAlgorithmParameterException e) {
+    } catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException | InvalidParameterSpecException
| InvalidKeyException | NoSuchPaddingException e) {
       e.printStackTrace();
     }
   }
@@ -81,15 +73,7 @@ public class AESEncryptor {
       dcipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
       byte[] iv = ecipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV();
       dcipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(iv));
-    } catch (NoSuchAlgorithmException e) {
-      e.printStackTrace();
-    } catch (NoSuchPaddingException e) {
-      e.printStackTrace();
-    } catch (InvalidKeyException e) {
-      e.printStackTrace();
-    } catch (InvalidParameterSpecException e) {
-      e.printStackTrace();
-    } catch (InvalidAlgorithmParameterException e) {
+    } catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException | InvalidParameterSpecException
| InvalidKeyException | NoSuchPaddingException e) {
       e.printStackTrace();
     }
   }
@@ -105,9 +89,7 @@ public class AESEncryptor {
       factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
       KeySpec spec = new PBEKeySpec(passPhrase.toCharArray(), salt, ITERATION_COUNT, KEY_LENGTH);
       key = factory.generateSecret(spec);
-    } catch (NoSuchAlgorithmException e) {
-      e.printStackTrace();
-    } catch (InvalidKeySpecException e) {
+    } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
       e.printStackTrace();
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
index f0f1761..4763cc2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
@@ -286,9 +286,6 @@ public class MasterKeyServiceImpl implements MasterKeyService {
                 key = new String(master);
               }
               FileUtils.deleteQuietly(keyFile);
-            } catch (IOException e) {
-              LOG.error("Cannot read master key from file: " + keyPath);
-              e.printStackTrace();
             } catch (Exception e) {
               LOG.error("Cannot read master key from file: " + keyPath);
               e.printStackTrace();
@@ -310,9 +307,6 @@ public class MasterKeyServiceImpl implements MasterKeyService {
       master = new String(aes.decrypt(Base64.decodeBase64(parts[0]),
           Base64.decodeBase64(parts[1]), Base64.decodeBase64(parts[2])),
           "UTF8").toCharArray();
-    } catch (IOException e) {
-      e.printStackTrace();
-      throw e;
     } catch (Exception e) {
       e.printStackTrace();
       throw e;

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandler.java
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandler.java
index cd19174..b2dbd5e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandler.java
@@ -554,10 +554,7 @@ public class ADKerberosOperationHandler extends KerberosOperationHandler
{
     } catch (ParseErrorException e) {
       LOG.warn("Failed to parse Active Directory create principal template", e);
       throw new KerberosOperationException("Failed to parse Active Directory create principal
template", e);
-    } catch (MethodInvocationException e) {
-      LOG.warn("Failed to process Active Directory create principal template", e);
-      throw new KerberosOperationException("Failed to process Active Directory create principal
template", e);
-    } catch (ResourceNotFoundException e) {
+    } catch (MethodInvocationException | ResourceNotFoundException e) {
       LOG.warn("Failed to process Active Directory create principal template", e);
       throw new KerberosOperationException("Failed to process Active Directory create principal
template", e);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/IPAKerberosOperationHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/IPAKerberosOperationHandler.java
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/IPAKerberosOperationHandler.java
index 5bff85d..54b4cd3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/IPAKerberosOperationHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/IPAKerberosOperationHandler.java
@@ -1085,11 +1085,7 @@ public class IPAKerberosOperationHandler extends KerberosOperationHandler
{
         process.waitFor();
 
         LOG.debug("done subprocess");
-      } catch (IOException e) {
-        String message = String.format("Failed to execute the command: %s", e.getLocalizedMessage());
-        LOG.error(message, e);
-        throw new KerberosOperationException(message, e);
-      } catch (InterruptedException e) {
+      } catch (IOException | InterruptedException e) {
         String message = String.format("Failed to execute the command: %s", e.getLocalizedMessage());
         LOG.error(message, e);
         throw new KerberosOperationException(message, e);

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandler.java
b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandler.java
index eea5071..1d979d0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosOperationHandler.java
@@ -19,7 +19,6 @@
 package org.apache.ambari.server.serveraction.kerberos;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -681,11 +680,6 @@ public abstract class KerberosOperationHandler {
         fos = new FileOutputStream(tempFile);
         fos.write(Base64.decodeBase64(keytabData));
         success = true;
-      } catch (FileNotFoundException e) {
-        String message = String.format("Failed to write to temporary keytab file %s: %s",
-            tempFile.getAbsolutePath(), e.getLocalizedMessage());
-        LOG.error(message, e);
-        throw new KerberosOperationException(message, e);
       } catch (IOException e) {
         String message = String.format("Failed to write to temporary keytab file %s: %s",
             tempFile.getAbsolutePath(), e.getLocalizedMessage());

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
index cc647e5..28752c4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
@@ -332,9 +332,7 @@ public class ClusterConfigurationRequest {
         }
       }
 
-    } catch (KerberosInvalidConfigurationException e) {
-      LOG.error("An exception occurred while doing Kerberos related configuration update:
" + e, e);
-    } catch (AmbariException e) {
+    } catch (KerberosInvalidConfigurationException | AmbariException e) {
       LOG.error("An exception occurred while doing Kerberos related configuration update:
" + e, e);
     }
     return requiredHostGroups;

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
index 14bc446..c153381 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
@@ -936,12 +936,9 @@ public class TopologyManager {
       // update the host with the rack info if applicable
       updateHostWithRackInfo(topology, response, host);
 
-    } catch (InvalidTopologyException e) {
+    } catch (InvalidTopologyException | NoSuchHostGroupException e) {
       // host already registered
       throw new RuntimeException("An internal error occurred while performing request host
registration: " + e, e);
-    } catch (NoSuchHostGroupException e) {
-      // invalid host group
-      throw new RuntimeException("An internal error occurred while performing request host
registration: " + e, e);
     }
 
     // persist the host request -> hostName association

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/utils/HTTPUtils.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/utils/HTTPUtils.java b/ambari-server/src/main/java/org/apache/ambari/server/utils/HTTPUtils.java
index e2b5c1a..1632c38 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/utils/HTTPUtils.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/HTTPUtils.java
@@ -18,7 +18,6 @@
 package org.apache.ambari.server.utils;
 
 import java.io.BufferedReader;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.HttpURLConnection;
@@ -72,8 +71,6 @@ public class HTTPUtils {
         }
         rd.close();
       }
-    } catch (IOException e) {
-      e.printStackTrace();
     } catch (Exception e) {
       e.printStackTrace();
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java
b/ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java
index d42b5c6..4fcad3d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/ShellCommandUtil.java
@@ -163,11 +163,9 @@ public class ShellCommandUtil {
     if (LINUX) {
       try {
         result = runCommand(new String[]{"stat", "-c", "%a", path}).getStdout();
-      } catch (IOException e) {
+      } catch (IOException | InterruptedException e) {
         // Improbable
         LOG.warn(String.format("Can not perform stat on %s", path), e);
-      } catch (InterruptedException e) {
-        LOG.warn(String.format("Can not perform stat on %s", path), e);
       }
     } else {
       LOG.debug(String.format("Not performing stat -s \"%%a\" command on file %s " +
@@ -187,11 +185,9 @@ public class ShellCommandUtil {
     if (LINUX) {
       try {
         runCommand(new String[]{"chmod", mode, path});
-      } catch (IOException e) {
+      } catch (IOException | InterruptedException e) {
         // Improbable
         LOG.warn(String.format("Can not perform chmod %s %s", mode, path), e);
-      } catch (InterruptedException e) {
-        LOG.warn(String.format("Can not perform chmod %s %s", mode, path), e);
       }
     } else {
       LOG.debug(String.format("Not performing chmod %s command for file %s " +
@@ -212,13 +208,10 @@ public class ShellCommandUtil {
       if (!StringUtils.isEmpty(ownerName)) {
         try {
           return runCommand(new String[]{"chown", ownerName, path}, null, null, true);
-        } catch (IOException e) {
+        } catch (IOException | InterruptedException e) {
           // Improbable
           LOG.warn(String.format("Can not perform chown %s %s", ownerName, path), e);
           return new Result(-1, "", "Cannot perform operation: " + e.getLocalizedMessage());
-        } catch (InterruptedException e) {
-          LOG.warn(String.format("Can not perform chown %s %s", ownerName, path), e);
-          return new Result(-1, "", "Cannot perform operation: " + e.getLocalizedMessage());
         }
       } else {
         return new Result(0, "", "");
@@ -243,13 +236,10 @@ public class ShellCommandUtil {
       if (!StringUtils.isEmpty(groupName)) {
         try {
           return runCommand(new String[]{"chgrp", groupName, path}, null, null, true);
-        } catch (IOException e) {
+        } catch (IOException | InterruptedException e) {
           // Improbable
           LOG.warn(String.format("Can not perform chgrp %s %s", groupName, path), e);
           return new Result(-1, "", "Cannot perform operation: " + e.getLocalizedMessage());
-        } catch (InterruptedException e) {
-          LOG.warn(String.format("Can not perform chgrp %s %s", groupName, path), e);
-          return new Result(-1, "", "Cannot perform operation: " + e.getLocalizedMessage());
         }
       } else {
         return new Result(0, "", "");
@@ -294,13 +284,10 @@ public class ShellCommandUtil {
 
       try {
         return runCommand(new String[]{"chmod", mode, path}, null, null, true);
-      } catch (IOException e) {
+      } catch (IOException | InterruptedException e) {
         // Improbable
         LOG.warn(String.format("Can not perform chmod %s %s", mode, path), e);
         return new Result(-1, "", "Cannot perform operation: " + e.getLocalizedMessage());
-      } catch (InterruptedException e) {
-        LOG.warn(String.format("Can not perform chmod %s %s", mode, path), e);
-        return new Result(-1, "", "Cannot perform operation: " + e.getLocalizedMessage());
       }
     } else {
       LOG.debug(String.format("Not performing chmod command for file %s " +

http://git-wip-us.apache.org/repos/asf/ambari/blob/1adb70d5/ambari-server/src/test/java/org/apache/ambari/server/agent/LocalAgentSimulator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/LocalAgentSimulator.java
b/ambari-server/src/test/java/org/apache/ambari/server/agent/LocalAgentSimulator.java
index b63779c..9de1509 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/LocalAgentSimulator.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/LocalAgentSimulator.java
@@ -103,10 +103,7 @@ public class LocalAgentSimulator implements Runnable {
     RegistrationResponse response;
     try {
       response = handler.handleRegistration(reg);
-    } catch (AmbariException e) {
-      LOG.info("Registration failed", e);
-      return;
-    } catch (InvalidStateTransitionException e) {
+    } catch (AmbariException | InvalidStateTransitionException e) {
       LOG.info("Registration failed", e);
       return;
     }


Mime
View raw message