cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject cassandra git commit: simplify duplicate catch blocks
Date Thu, 30 Apr 2015 03:25:43 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 16a7fcfb7 -> 01880a470


simplify duplicate catch blocks


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/01880a47
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/01880a47
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/01880a47

Branch: refs/heads/trunk
Commit: 01880a470c31c6c27bb82d73727623fe253eef9f
Parents: 16a7fcf
Author: Dave Brosius <dbrosius@mebigfatguy.com>
Authored: Wed Apr 29 23:25:24 2015 -0400
Committer: Dave Brosius <dbrosius@mebigfatguy.com>
Committed: Wed Apr 29 23:25:24 2015 -0400

----------------------------------------------------------------------
 .../apache/cassandra/db/marshal/TypeParser.java | 21 +++-----------------
 .../hadoop/AbstractColumnFamilyInputFormat.java |  5 +----
 .../apache/cassandra/hadoop/HadoopCompat.java   | 10 ++--------
 .../hadoop/pig/AbstractCassandraStorage.java    |  6 +-----
 .../cassandra/io/compress/SnappyCompressor.java | 10 +---------
 .../metrics/CassandraMetricsRegistry.java       |  5 +----
 .../scheduler/RoundRobinScheduler.java          |  7 +------
 .../org/apache/cassandra/tools/NodeProbe.java   |  6 +-----
 .../cassandra/transport/FrameCompressor.java    | 10 +---------
 .../org/apache/cassandra/utils/FBUtilities.java |  6 +-----
 .../apache/cassandra/utils/IntervalTree.java    | 10 +---------
 .../cassandra/db/marshal/CompositeTypeTest.java |  6 ++----
 .../cassandra/db/marshal/TypeParserTest.java    |  6 ++----
 .../io/sstable/IndexSummaryManagerTest.java     |  6 +-----
 14 files changed, 19 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/src/java/org/apache/cassandra/db/marshal/TypeParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/TypeParser.java b/src/java/org/apache/cassandra/db/marshal/TypeParser.java
index 176ea4d..ad7ffed 100644
--- a/src/java/org/apache/cassandra/db/marshal/TypeParser.java
+++ b/src/java/org/apache/cassandra/db/marshal/TypeParser.java
@@ -347,12 +347,7 @@ public class TypeParser
             Field field = typeClass.getDeclaredField("instance");
             return (AbstractType<?>) field.get(null);
         }
-        catch (NoSuchFieldException e)
-        {
-            // Trying with empty parser
-            return getRawAbstractType(typeClass, EMPTY_PARSER);
-        }
-        catch (IllegalAccessException e)
+        catch (NoSuchFieldException | IllegalAccessException e)
         {
             // Trying with empty parser
             return getRawAbstractType(typeClass, EMPTY_PARSER);
@@ -368,13 +363,7 @@ public class TypeParser
             Method method = typeClass.getDeclaredMethod("getInstance", TypeParser.class);
             return (AbstractType<?>) method.invoke(null, parser);
         }
-        catch (NoSuchMethodException e)
-        {
-            // Trying to see if we have an instance field and apply the default parameter
to it
-            AbstractType<?> type = getRawAbstractType(typeClass);
-            return AbstractType.parseDefaultParameters(type, parser);
-        }
-        catch (IllegalAccessException e)
+        catch (NoSuchMethodException | IllegalAccessException e)
         {
             // Trying to see if we have an instance field and apply the default parameter
to it
             AbstractType<?> type = getRawAbstractType(typeClass);
@@ -412,11 +401,7 @@ public class TypeParser
             Method method = typeClass.getDeclaredMethod("getInstance", TypeParser.class);
             return (AbstractType<?>) method.invoke(null, parser);
         }
-        catch (NoSuchMethodException e)
-        {
-            throw new ConfigurationException("Invalid comparator class " + typeClass.getName()
+ ": must define a public static instance field or a public static method getInstance(TypeParser).");
-        }
-        catch (IllegalAccessException e)
+        catch (NoSuchMethodException | IllegalAccessException e)
         {
             throw new ConfigurationException("Invalid comparator class " + typeClass.getName()
+ ": must define a public static instance field or a public static method getInstance(TypeParser).");
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/src/java/org/apache/cassandra/hadoop/AbstractColumnFamilyInputFormat.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/AbstractColumnFamilyInputFormat.java b/src/java/org/apache/cassandra/hadoop/AbstractColumnFamilyInputFormat.java
index 6fe2239..691bd76 100644
--- a/src/java/org/apache/cassandra/hadoop/AbstractColumnFamilyInputFormat.java
+++ b/src/java/org/apache/cassandra/hadoop/AbstractColumnFamilyInputFormat.java
@@ -317,14 +317,11 @@ public abstract class AbstractColumnFamilyInputFormat<K, Y> extends
InputFormat<
         {
             map = client.describe_local_ring(ConfigHelper.getInputKeyspace(conf));
         }
-        catch (InvalidRequestException e)
-        {
-            throw new RuntimeException(e);
-        }
         catch (TException e)
         {
             throw new RuntimeException(e);
         }
+        
         return map;
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/src/java/org/apache/cassandra/hadoop/HadoopCompat.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/HadoopCompat.java b/src/java/org/apache/cassandra/hadoop/HadoopCompat.java
index f2f7033..bcfb952 100644
--- a/src/java/org/apache/cassandra/hadoop/HadoopCompat.java
+++ b/src/java/org/apache/cassandra/hadoop/HadoopCompat.java
@@ -234,11 +234,7 @@ public class HadoopCompat {
         try {
             return (Counter)
                     GENERIC_COUNTER_CONSTRUCTOR.newInstance(name, displayName, value);
-        } catch (InstantiationException e) {
-            throw new IllegalArgumentException("Can't instantiate Counter", e);
-        } catch (IllegalAccessException e) {
-            throw new IllegalArgumentException("Can't instantiate Counter", e);
-        } catch (InvocationTargetException e) {
+        } catch (InstantiationException | IllegalAccessException | InvocationTargetException
e) {
             throw new IllegalArgumentException("Can't instantiate Counter", e);
         }
     }
@@ -249,9 +245,7 @@ public class HadoopCompat {
     private static Object invoke(Method method, Object obj, Object... args) {
         try {
             return method.invoke(obj, args);
-        } catch (IllegalAccessException e) {
-            throw new IllegalArgumentException("Can't invoke method " + method.getName(),
e);
-        } catch (InvocationTargetException e) {
+        } catch (IllegalAccessException | InvocationTargetException e) {
             throw new IllegalArgumentException("Can't invoke method " + method.getName(),
e);
         }
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/src/java/org/apache/cassandra/hadoop/pig/AbstractCassandraStorage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/pig/AbstractCassandraStorage.java b/src/java/org/apache/cassandra/hadoop/pig/AbstractCassandraStorage.java
index 1389488..263e6c0 100644
--- a/src/java/org/apache/cassandra/hadoop/pig/AbstractCassandraStorage.java
+++ b/src/java/org/apache/cassandra/hadoop/pig/AbstractCassandraStorage.java
@@ -217,11 +217,7 @@ public abstract class AbstractCassandraStorage extends LoadFunc implements
Store
                         validator = LongType.instance; 
                     validators.put(cd.name, validator);
                 }
-                catch (ConfigurationException e)
-                {
-                    throw new IOException(e);
-                }
-                catch (SyntaxException e)
+                catch (ConfigurationException | SyntaxException e)
                 {
                     throw new IOException(e);
                 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/src/java/org/apache/cassandra/io/compress/SnappyCompressor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/compress/SnappyCompressor.java b/src/java/org/apache/cassandra/io/compress/SnappyCompressor.java
index 7a91df1..d1f1f34 100644
--- a/src/java/org/apache/cassandra/io/compress/SnappyCompressor.java
+++ b/src/java/org/apache/cassandra/io/compress/SnappyCompressor.java
@@ -63,15 +63,7 @@ public class SnappyCompressor implements ICompressor
             JVMStabilityInspector.inspectThrowable(e);
             return false;
         }
-        catch (NoClassDefFoundError e)
-        {
-            return false;
-        }
-        catch (SnappyError e)
-        {
-            return false;
-        }
-        catch (UnsatisfiedLinkError e)
+        catch (NoClassDefFoundError | SnappyError | UnsatisfiedLinkError e)
         {
             return false;
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/src/java/org/apache/cassandra/metrics/CassandraMetricsRegistry.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/CassandraMetricsRegistry.java b/src/java/org/apache/cassandra/metrics/CassandraMetricsRegistry.java
index 2f76adb..7038e99 100644
--- a/src/java/org/apache/cassandra/metrics/CassandraMetricsRegistry.java
+++ b/src/java/org/apache/cassandra/metrics/CassandraMetricsRegistry.java
@@ -138,12 +138,9 @@ public class CassandraMetricsRegistry extends MetricRegistry
         } catch (InstanceAlreadyExistsException e)
         {
             logger.debug("Metric bean already exists", e);
-        } catch (MBeanRegistrationException e)
+        } catch (MBeanRegistrationException | NotCompliantMBeanException e)
         {
             logger.debug("Unable to register metric bean", e);
-        } catch (NotCompliantMBeanException e)
-        {
-            logger.warn("Unable to register metric bean", e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/src/java/org/apache/cassandra/scheduler/RoundRobinScheduler.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/scheduler/RoundRobinScheduler.java b/src/java/org/apache/cassandra/scheduler/RoundRobinScheduler.java
index 1a18e61..c98c0fe 100644
--- a/src/java/org/apache/cassandra/scheduler/RoundRobinScheduler.java
+++ b/src/java/org/apache/cassandra/scheduler/RoundRobinScheduler.java
@@ -86,12 +86,7 @@ public class RoundRobinScheduler implements IRequestScheduler
                 weightedQueue.put(t, timeoutMS);
                 // the scheduler will release us when a slot is available
             }
-            catch (TimeoutException e)
-            {
-                queueSize.acquireUninterruptibly();
-                throw e;
-            }
-            catch (InterruptedException e)
+            catch (TimeoutException | InterruptedException e)
             {
                 queueSize.acquireUninterruptibly();
                 throw e;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/src/java/org/apache/cassandra/tools/NodeProbe.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java b/src/java/org/apache/cassandra/tools/NodeProbe.java
index 6496319..0edfded 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -851,11 +851,7 @@ public class NodeProbe implements AutoCloseable
         {
             hhProxy.truncateAllHints();
         }
-        catch (ExecutionException e)
-        {
-            throw new RuntimeException("Error while executing truncate hints", e);
-        }
-        catch (InterruptedException e)
+        catch (ExecutionException | InterruptedException e)
         {
             throw new RuntimeException("Error while executing truncate hints", e);
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/src/java/org/apache/cassandra/transport/FrameCompressor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/FrameCompressor.java b/src/java/org/apache/cassandra/transport/FrameCompressor.java
index db4350c..01c0c31 100644
--- a/src/java/org/apache/cassandra/transport/FrameCompressor.java
+++ b/src/java/org/apache/cassandra/transport/FrameCompressor.java
@@ -51,15 +51,7 @@ public interface FrameCompressor
                 JVMStabilityInspector.inspectThrowable(e);
                 i = null;
             }
-            catch (NoClassDefFoundError e)
-            {
-                i = null;
-            }
-            catch (SnappyError e)
-            {
-                i = null;
-            }
-            catch (UnsatisfiedLinkError e)
+            catch (NoClassDefFoundError | SnappyError | UnsatisfiedLinkError e)
             {
                 i = null;
             }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/src/java/org/apache/cassandra/utils/FBUtilities.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/FBUtilities.java b/src/java/org/apache/cassandra/utils/FBUtilities.java
index dd54ae1..b61f956 100644
--- a/src/java/org/apache/cassandra/utils/FBUtilities.java
+++ b/src/java/org/apache/cassandra/utils/FBUtilities.java
@@ -446,11 +446,7 @@ public class FBUtilities
         {
             return (Class<T>)Class.forName(classname);
         }
-        catch (ClassNotFoundException e)
-        {
-            throw new ConfigurationException(String.format("Unable to find %s class '%s'",
readable, classname), e);
-        }
-        catch (NoClassDefFoundError e)
+        catch (ClassNotFoundException | NoClassDefFoundError e)
         {
             throw new ConfigurationException(String.format("Unable to find %s class '%s'",
readable, classname), e);
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/src/java/org/apache/cassandra/utils/IntervalTree.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/IntervalTree.java b/src/java/org/apache/cassandra/utils/IntervalTree.java
index 376d1bc..e857ee7 100644
--- a/src/java/org/apache/cassandra/utils/IntervalTree.java
+++ b/src/java/org/apache/cassandra/utils/IntervalTree.java
@@ -349,15 +349,7 @@ public class IntervalTree<C extends Comparable<? super C>, D,
I extends Interval
                 }
                 return new IntervalTree<C, D, I>(intervals);
             }
-            catch (InstantiationException e)
-            {
-                throw new RuntimeException(e);
-            }
-            catch (InvocationTargetException e)
-            {
-                throw new RuntimeException(e);
-            }
-            catch (IllegalAccessException e)
+            catch (InstantiationException | InvocationTargetException | IllegalAccessException
e)
             {
                 throw new RuntimeException(e);
             }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java b/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
index 2e746fa..25c1c7d 100644
--- a/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
+++ b/test/unit/org/apache/cassandra/db/marshal/CompositeTypeTest.java
@@ -214,16 +214,14 @@ public class CompositeTypeTest
             TypeParser.parse("CompositeType");
             fail("Shouldn't work");
         }
-        catch (ConfigurationException e) {}
-        catch (SyntaxException e) {}
+        catch (ConfigurationException | SyntaxException e) {}
 
         try
         {
             TypeParser.parse("CompositeType()");
             fail("Shouldn't work");
         }
-        catch (ConfigurationException e) {}
-        catch (SyntaxException e) {}
+        catch (ConfigurationException | SyntaxException e) {}
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/test/unit/org/apache/cassandra/db/marshal/TypeParserTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/marshal/TypeParserTest.java b/test/unit/org/apache/cassandra/db/marshal/TypeParserTest.java
index ee3052c..5a697be 100644
--- a/test/unit/org/apache/cassandra/db/marshal/TypeParserTest.java
+++ b/test/unit/org/apache/cassandra/db/marshal/TypeParserTest.java
@@ -69,15 +69,13 @@ public class TypeParserTest
             TypeParser.parse("y");
             fail("Should not pass");
         }
-        catch (ConfigurationException e) {}
-        catch (SyntaxException e) {}
+        catch (ConfigurationException | SyntaxException e) {}
 
         try
         {
             TypeParser.parse("LongType(reversed@)");
             fail("Should not pass");
         }
-        catch (ConfigurationException e) {}
-        catch (SyntaxException e) {}
+        catch (ConfigurationException | SyntaxException e) {}
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/01880a47/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java b/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java
index 7a00983..eac6094 100644
--- a/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/IndexSummaryManagerTest.java
@@ -180,11 +180,7 @@ public class IndexSummaryManagerTest
             try
             {
                 future.get();
-            } catch (InterruptedException e)
-            {
-                throw new RuntimeException(e);
-            }
-            catch (ExecutionException e)
+            } catch (InterruptedException | ExecutionException e)
             {
                 throw new RuntimeException(e);
             }


Mime
View raw message