Skip to content

Commit ca9c347

Browse files
committed
Merge pull request #2052 from igor-suhoruko
* pr/2052: Polish "Join identical catch branches" Join identical catch branches
2 parents 93e7a0a + 9cbd585 commit ca9c347

File tree

5 files changed

+20
-53
lines changed

5 files changed

+20
-53
lines changed

spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,7 @@ public String[] getParameterNames(Method method) {
272272
}
273273
}
274274
}
275-
catch (AmbiguousBindingException ambigEx) {
276-
if (this.raiseExceptions) {
277-
throw ambigEx;
278-
}
279-
else {
280-
return null;
281-
}
282-
}
283-
catch (IllegalArgumentException ex) {
275+
catch (AmbiguousBindingException | IllegalArgumentException ex) {
284276
if (this.raiseExceptions) {
285277
throw ex;
286278
}

spring-expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -80,13 +80,9 @@ public void testScenario_UsingStandardInfrastructure() {
8080
assertEquals("hello world", value);
8181
assertEquals(String.class, value.getClass());
8282
}
83-
catch (EvaluationException ee) {
84-
ee.printStackTrace();
85-
fail("Unexpected Exception: " + ee.getMessage());
86-
}
87-
catch (ParseException pe) {
88-
pe.printStackTrace();
89-
fail("Unexpected Exception: " + pe.getMessage());
83+
catch (EvaluationException | ParseException ex) {
84+
ex.printStackTrace();
85+
fail("Unexpected Exception: " + ex.getMessage());
9086
}
9187
}
9288

@@ -189,13 +185,9 @@ public void testScenario_RegisteringJavaMethodsAsFunctionsAndCallingThem() throw
189185
assertEquals("hellohello", value);
190186

191187
}
192-
catch (EvaluationException ee) {
193-
ee.printStackTrace();
194-
fail("Unexpected Exception: " + ee.getMessage());
195-
}
196-
catch (ParseException pe) {
197-
pe.printStackTrace();
198-
fail("Unexpected Exception: " + pe.getMessage());
188+
catch (EvaluationException | ParseException ex) {
189+
ex.printStackTrace();
190+
fail("Unexpected Exception: " + ex.getMessage());
199191
}
200192
}
201193

spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -276,13 +276,9 @@ protected void setValue(String expression, Object value) {
276276
e.setValue(lContext, value);
277277
assertEquals("Retrieved value was not equal to set value", value, e.getValue(lContext,value.getClass()));
278278
}
279-
catch (EvaluationException ee) {
280-
ee.printStackTrace();
281-
fail("Unexpected Exception: " + ee.getMessage());
282-
}
283-
catch (ParseException pe) {
284-
pe.printStackTrace();
285-
fail("Unexpected Exception: " + pe.getMessage());
279+
catch (EvaluationException | ParseException ex) {
280+
ex.printStackTrace();
281+
fail("Unexpected Exception: " + ex.getMessage());
286282
}
287283
}
288284

@@ -309,13 +305,9 @@ protected void setValue(String expression, Object value, Object expectedValue) {
309305
// assertEquals("Retrieved value was not equal to set value", expectedValue, e.getValue(lContext));
310306
}
311307
}
312-
catch (EvaluationException ee) {
313-
ee.printStackTrace();
314-
fail("Unexpected Exception: " + ee.getMessage());
315-
}
316-
catch (ParseException pe) {
317-
pe.printStackTrace();
318-
fail("Unexpected Exception: " + pe.getMessage());
308+
catch (EvaluationException | ParseException ex) {
309+
ex.printStackTrace();
310+
fail("Unexpected Exception: " + ex.getMessage());
319311
}
320312
}
321313

spring-tx/src/main/java/org/springframework/transaction/jta/SpringJtaSynchronizationAdapter.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -121,14 +121,10 @@ public void beforeCompletion() {
121121
boolean readOnly = TransactionSynchronizationManager.isCurrentTransactionReadOnly();
122122
this.springSynchronization.beforeCommit(readOnly);
123123
}
124-
catch (RuntimeException ex) {
124+
catch (RuntimeException | Error ex) {
125125
setRollbackOnlyIfPossible();
126126
throw ex;
127127
}
128-
catch (Error err) {
129-
setRollbackOnlyIfPossible();
130-
throw err;
131-
}
132128
finally {
133129
// Process Spring's beforeCompletion early, in order to avoid issues
134130
// with strict JTA implementations that issue warnings when doing JDBC

spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,15 +56,10 @@ public void runUnderUOW(int type, boolean join, UOWAction action) throws UOWActi
5656
action.run();
5757
this.status = (this.rollbackOnly ? UOW_STATUS_ROLLEDBACK : UOW_STATUS_COMMITTED);
5858
}
59-
catch (Error err) {
60-
this.status = UOW_STATUS_ROLLEDBACK;
61-
throw err;
62-
}
63-
catch (RuntimeException ex) {
59+
catch (Error | RuntimeException ex) {
6460
this.status = UOW_STATUS_ROLLEDBACK;
6561
throw ex;
66-
}
67-
catch (Exception ex) {
62+
} catch (Exception ex) {
6863
this.status = UOW_STATUS_ROLLEDBACK;
6964
throw new UOWActionException(ex);
7065
}

0 commit comments

Comments
 (0)