groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [1/5] groovy git commit: Minor refactoring: Identical 'catch' branches in 'try' statement
Date Sun, 26 Aug 2018 10:27:50 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 4e40942dc -> b89f6a3e4


Minor refactoring: Identical 'catch' branches in 'try' statement


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/8f9ec372
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8f9ec372
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8f9ec372

Branch: refs/heads/GROOVY_2_5_X
Commit: 8f9ec372abf8a192eb06f00a5234a9013b6383af
Parents: 4e40942
Author: Daniel Sun <sunlan@apache.org>
Authored: Sun Aug 26 17:44:19 2018 +0800
Committer: Daniel Sun <sunlan@apache.org>
Committed: Sun Aug 26 18:05:18 2018 +0800

----------------------------------------------------------------------
 .../src/main/java/org/codehaus/groovy/ant/Groovy.java   |  4 +---
 .../groovy/tools/groovydoc/SimpleGroovyClassDoc.java    | 12 +++---------
 .../main/java/groovy/servlet/AbstractHttpServlet.java   |  3 +--
 .../src/main/java/groovy/servlet/GroovyServlet.java     |  4 +---
 .../groovy-sql/src/main/java/groovy/sql/Sql.java        |  8 +-------
 .../org/codehaus/groovy/binding/PropertyBinding.java    |  4 +---
 .../main/groovy/groovy/text/GStringTemplateEngine.java  |  4 +---
 .../groovy/groovy/text/StreamingTemplateEngine.java     |  4 +---
 .../groovy-xml/src/main/java/groovy/util/XmlParser.java |  4 +---
 .../src/main/java/groovy/util/XmlSlurper.java           |  4 +---
 10 files changed, 12 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/8f9ec372/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java
index 7abe713..65ea13e 100644
--- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java
+++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java
@@ -528,9 +528,7 @@ public class Groovy extends Java {
                 shell.run(txt, scriptName, cmdline.getCommandline());
             }
         }
-        catch (final CompilationFailedException e) {
-            processError(e);
-        } catch (IOException e) {
+        catch (final CompilationFailedException | IOException e) {
             processError(e);
         }
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/8f9ec372/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
index d9f40a5..b308b9b 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
@@ -640,9 +640,7 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc
imp
     private Class resolveFromJavaLang(String name) {
         try {
             return Class.forName("java.lang." + name, false, getClass().getClassLoader());
-        } catch (NoClassDefFoundError e) {
-            // ignore
-        } catch (ClassNotFoundException e) {
+        } catch (NoClassDefFoundError | ClassNotFoundException e) {
             // ignore
         }
         return null;
@@ -693,9 +691,7 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc
imp
                 try {
                     // TODO cache these??
                     return Class.forName(candidate, false, getClass().getClassLoader());
-                } catch (NoClassDefFoundError e) {
-                    // ignore
-                } catch (ClassNotFoundException e) {
+                } catch (NoClassDefFoundError | ClassNotFoundException e) {
                     // ignore
                 }
             }
@@ -708,9 +704,7 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc
imp
         try {
             // TODO cache these??
             return Class.forName(candidate, false, getClass().getClassLoader());
-        } catch (NoClassDefFoundError e) {
-            // ignore
-        } catch (ClassNotFoundException e) {
+        } catch (NoClassDefFoundError | ClassNotFoundException e) {
             // ignore
         }
         return null;

http://git-wip-us.apache.org/repos/asf/groovy/blob/8f9ec372/subprojects/groovy-servlet/src/main/java/groovy/servlet/AbstractHttpServlet.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-servlet/src/main/java/groovy/servlet/AbstractHttpServlet.java
b/subprojects/groovy-servlet/src/main/java/groovy/servlet/AbstractHttpServlet.java
index 7e1dbbd..7a2d615 100644
--- a/subprojects/groovy-servlet/src/main/java/groovy/servlet/AbstractHttpServlet.java
+++ b/subprojects/groovy-servlet/src/main/java/groovy/servlet/AbstractHttpServlet.java
@@ -178,8 +178,7 @@ public abstract class AbstractHttpServlet extends HttpServlet implements
Resourc
         try {
             URL res = servletContext.getResource("/");
             if (res != null) { uri = res.toURI(); }
-        } catch (MalformedURLException ignore) {
-        } catch (URISyntaxException ignore) {
+        } catch (MalformedURLException | URISyntaxException ignore) {
         }
 
         if (uri != null) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/8f9ec372/subprojects/groovy-servlet/src/main/java/groovy/servlet/GroovyServlet.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-servlet/src/main/java/groovy/servlet/GroovyServlet.java b/subprojects/groovy-servlet/src/main/java/groovy/servlet/GroovyServlet.java
index 168f620..f64ec95 100644
--- a/subprojects/groovy-servlet/src/main/java/groovy/servlet/GroovyServlet.java
+++ b/subprojects/groovy-servlet/src/main/java/groovy/servlet/GroovyServlet.java
@@ -119,9 +119,7 @@ public class GroovyServlet extends AbstractHttpServlet {
                 public Object call() {
                     try {
                         return ((GroovyScriptEngine) getDelegate()).run(scriptUri, binding);
-                    } catch (ResourceException e) {
-                        throw new RuntimeException(e);
-                    } catch (ScriptException e) {
+                    } catch (ResourceException | ScriptException e) {
                         throw new RuntimeException(e);
                     }
                 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/8f9ec372/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
index a78c755..6c6db97 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
@@ -3577,13 +3577,7 @@ public class Sql {
             connection.setAutoCommit(false);
             callClosurePossiblyWithConnection(closure, connection);
             connection.commit();
-        } catch (SQLException e) {
-            handleError(connection, e);
-            throw e;
-        } catch (RuntimeException e) {
-            handleError(connection, e);
-            throw e;
-        } catch (Error e) {
+        } catch (SQLException | Error | RuntimeException e) {
             handleError(connection, e);
             throw e;
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/8f9ec372/subprojects/groovy-swing/src/main/java/org/codehaus/groovy/binding/PropertyBinding.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-swing/src/main/java/org/codehaus/groovy/binding/PropertyBinding.java
b/subprojects/groovy-swing/src/main/java/org/codehaus/groovy/binding/PropertyBinding.java
index f8c051b..2df1f48 100644
--- a/subprojects/groovy-swing/src/main/java/org/codehaus/groovy/binding/PropertyBinding.java
+++ b/subprojects/groovy-swing/src/main/java/org/codehaus/groovy/binding/PropertyBinding.java
@@ -157,9 +157,7 @@ public class PropertyBinding implements SourceBinding, TargetBinding,
TriggerBin
 
         try {
             return accessorClass.newInstance();
-        } catch (InstantiationException e) {
-            return DefaultPropertyAccessor.INSTANCE;
-        } catch (IllegalAccessException e) {
+        } catch (InstantiationException | IllegalAccessException e) {
             return DefaultPropertyAccessor.INSTANCE;
         }
     }

http://git-wip-us.apache.org/repos/asf/groovy/blob/8f9ec372/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
b/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
index 53ba715..1b2fa8c 100644
--- a/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
+++ b/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
@@ -209,9 +209,7 @@ public class GStringTemplateEngine extends TemplateEngine {
                 // books = 'foo' in a template would store 'books' in the binding of the
template script itself ("script")
                 // instead of storing it in the delegate, which is a Binding too
                 this.template.setResolveStrategy(Closure.DELEGATE_FIRST);
-            } catch (InstantiationException e) {
-                throw new ClassNotFoundException(e.getMessage());
-            } catch (IllegalAccessException e) {
+            } catch (InstantiationException | IllegalAccessException e) {
                 throw new ClassNotFoundException(e.getMessage());
             }
         }

http://git-wip-us.apache.org/repos/asf/groovy/blob/8f9ec372/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
b/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
index 6b8433a..8894978 100644
--- a/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
+++ b/subprojects/groovy-templates/src/main/groovy/groovy/text/StreamingTemplateEngine.java
@@ -624,9 +624,7 @@ public class StreamingTemplateEngine extends TemplateEngine {
                 Closure chicken = (Closure) object.invokeMethod("getTemplate", null);
                 //bind the two first parameters of the generated closure to this class and
the sections list
                 result = chicken.curry(this, sections);
-            } catch (InstantiationException e) {
-                throw new ClassNotFoundException(e.getMessage());
-            } catch (IllegalAccessException e) {
+            } catch (InstantiationException | IllegalAccessException e) {
                 throw new ClassNotFoundException(e.getMessage());
             }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/8f9ec372/subprojects/groovy-xml/src/main/java/groovy/util/XmlParser.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-xml/src/main/java/groovy/util/XmlParser.java b/subprojects/groovy-xml/src/main/java/groovy/util/XmlParser.java
index 33ae5a1..4320d97 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/util/XmlParser.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/util/XmlParser.java
@@ -131,9 +131,7 @@ public class XmlParser implements ContentHandler {
         try {
             factory.setFeature(feature, value);
         }
-        catch (ParserConfigurationException ignored) { }
-        catch (SAXNotRecognizedException ignored) { }
-        catch (SAXNotSupportedException ignored) { }
+        catch (ParserConfigurationException | SAXNotSupportedException | SAXNotRecognizedException
ignored) { }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/groovy/blob/8f9ec372/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java b/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java
index 2d23537..ee93474 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/util/XmlSlurper.java
@@ -143,9 +143,7 @@ public class XmlSlurper extends DefaultHandler {
         try {
             factory.setFeature(feature, value);
         }
-        catch (ParserConfigurationException ignored) { }
-        catch (SAXNotRecognizedException ignored) { }
-        catch (SAXNotSupportedException ignored) { }
+        catch (ParserConfigurationException | SAXNotSupportedException | SAXNotRecognizedException
ignored) { }
     }
 
     /**


Mime
View raw message