Browse Source

Merge pull request #2052 from igor-suhoruko

* pr/2052:
  Polish "Join identical catch branches"
  Join identical catch branches
pull/2061/head
Stephane Nicoll 7 years ago
parent
commit
ca9c34710f
  1. 10
      spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverer.java
  2. 22
      spring-expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java
  3. 22
      spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java
  4. 8
      spring-tx/src/main/java/org/springframework/transaction/jta/SpringJtaSynchronizationAdapter.java
  5. 11
      spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java

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

@ -272,15 +272,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov @@ -272,15 +272,7 @@ public class AspectJAdviceParameterNameDiscoverer implements ParameterNameDiscov
}
}
}
catch (AmbiguousBindingException ambigEx) {
if (this.raiseExceptions) {
throw ambigEx;
}
else {
return null;
}
}
catch (IllegalArgumentException ex) {
catch (AmbiguousBindingException | IllegalArgumentException ex) {
if (this.raiseExceptions) {
throw ex;
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -80,13 +80,9 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests { @@ -80,13 +80,9 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
assertEquals("hello world", value);
assertEquals(String.class, value.getClass());
}
catch (EvaluationException ee) {
ee.printStackTrace();
fail("Unexpected Exception: " + ee.getMessage());
}
catch (ParseException pe) {
pe.printStackTrace();
fail("Unexpected Exception: " + pe.getMessage());
catch (EvaluationException | ParseException ex) {
ex.printStackTrace();
fail("Unexpected Exception: " + ex.getMessage());
}
}
@ -189,13 +185,9 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests { @@ -189,13 +185,9 @@ public class ExpressionLanguageScenarioTests extends AbstractExpressionTests {
assertEquals("hellohello", value);
}
catch (EvaluationException ee) {
ee.printStackTrace();
fail("Unexpected Exception: " + ee.getMessage());
}
catch (ParseException pe) {
pe.printStackTrace();
fail("Unexpected Exception: " + pe.getMessage());
catch (EvaluationException | ParseException ex) {
ex.printStackTrace();
fail("Unexpected Exception: " + ex.getMessage());
}
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -276,13 +276,9 @@ public class SetValueTests extends AbstractExpressionTests { @@ -276,13 +276,9 @@ public class SetValueTests extends AbstractExpressionTests {
e.setValue(lContext, value);
assertEquals("Retrieved value was not equal to set value", value, e.getValue(lContext,value.getClass()));
}
catch (EvaluationException ee) {
ee.printStackTrace();
fail("Unexpected Exception: " + ee.getMessage());
}
catch (ParseException pe) {
pe.printStackTrace();
fail("Unexpected Exception: " + pe.getMessage());
catch (EvaluationException | ParseException ex) {
ex.printStackTrace();
fail("Unexpected Exception: " + ex.getMessage());
}
}
@ -309,13 +305,9 @@ public class SetValueTests extends AbstractExpressionTests { @@ -309,13 +305,9 @@ public class SetValueTests extends AbstractExpressionTests {
// assertEquals("Retrieved value was not equal to set value", expectedValue, e.getValue(lContext));
}
}
catch (EvaluationException ee) {
ee.printStackTrace();
fail("Unexpected Exception: " + ee.getMessage());
}
catch (ParseException pe) {
pe.printStackTrace();
fail("Unexpected Exception: " + pe.getMessage());
catch (EvaluationException | ParseException ex) {
ex.printStackTrace();
fail("Unexpected Exception: " + ex.getMessage());
}
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -121,14 +121,10 @@ public class SpringJtaSynchronizationAdapter implements Synchronization { @@ -121,14 +121,10 @@ public class SpringJtaSynchronizationAdapter implements Synchronization {
boolean readOnly = TransactionSynchronizationManager.isCurrentTransactionReadOnly();
this.springSynchronization.beforeCommit(readOnly);
}
catch (RuntimeException ex) {
catch (RuntimeException | Error ex) {
setRollbackOnlyIfPossible();
throw ex;
}
catch (Error err) {
setRollbackOnlyIfPossible();
throw err;
}
finally {
// Process Spring's beforeCompletion early, in order to avoid issues
// with strict JTA implementations that issue warnings when doing JDBC

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -56,15 +56,10 @@ public class MockUOWManager implements UOWManager { @@ -56,15 +56,10 @@ public class MockUOWManager implements UOWManager {
action.run();
this.status = (this.rollbackOnly ? UOW_STATUS_ROLLEDBACK : UOW_STATUS_COMMITTED);
}
catch (Error err) {
this.status = UOW_STATUS_ROLLEDBACK;
throw err;
}
catch (RuntimeException ex) {
catch (Error | RuntimeException ex) {
this.status = UOW_STATUS_ROLLEDBACK;
throw ex;
}
catch (Exception ex) {
} catch (Exception ex) {
this.status = UOW_STATUS_ROLLEDBACK;
throw new UOWActionException(ex);
}

Loading…
Cancel
Save