Skip to content
Permalink
Browse files
Identical catch sections in a single try statement. Collapse into a m…
…ulti-catch section.
  • Loading branch information
arturobernalg committed Jun 20, 2021
1 parent bc1091e commit 5165bddec796a1e2278c01412e06f44de52c911a
Showing 6 changed files with 15 additions and 87 deletions.
@@ -92,15 +92,7 @@ else if ( clazz.isEnum() )
result = Modifier.isFinal( field.getModifiers() );
}
}
catch ( ClassNotFoundException e )
{
cause = e;
}
catch ( NoSuchFieldException e )
{
cause = e;
}
catch ( SecurityException e )
catch ( ClassNotFoundException | SecurityException | NoSuchFieldException e )
{
cause = e;
}
@@ -138,15 +130,7 @@ Class getFieldClass( OgnlContext context )

return field.getType();
}
catch ( ClassNotFoundException e )
{
cause = e;
}
catch ( NoSuchFieldException e )
{
cause = e;
}
catch ( SecurityException e )
catch ( ClassNotFoundException | SecurityException | NoSuchFieldException e )
{
cause = e;
}
@@ -52,16 +52,10 @@ public Object getPossibleProperty( Map<String, Object> context, Object target, S
{
result = OgnlRuntime.getFieldValue( ognlContext, target, name, true );
}
}
catch ( IntrospectionException ex )
{
throw new OgnlException( name, ex );
}
catch ( OgnlException ex )
} catch ( OgnlException ex )
{
throw ex;
}
catch ( Exception ex )
} catch ( Exception ex )
{
throw new OgnlException( name, ex );
}
@@ -93,16 +87,10 @@ public Object setPossibleProperty( Map<String, Object> context, Object target, S
result = m.invoke( target, value );
}
}
}
catch ( IntrospectionException ex )
{
throw new OgnlException( name, ex );
}
catch ( OgnlException ex )
} catch ( OgnlException ex )
{
throw ex;
}
catch ( Exception ex )
} catch ( Exception ex )
{
throw new OgnlException( name, ex );
}
@@ -111,11 +111,7 @@ public static Object parseExpression( String expression )
OgnlParser parser = new OgnlParser( new StringReader( expression ) );
return parser.topLevelExpression();
}
catch ( ParseException e )
{
throw new ExpressionSyntaxException( expression, e );
}
catch ( TokenMgrError e )
catch ( ParseException | TokenMgrError e )
{
throw new ExpressionSyntaxException( expression, e );
}
@@ -927,15 +927,10 @@ public static Object callAppropriateMethod( OgnlContext context, Object source,
return invokeMethod( target, method, convertedArgs );

}
catch ( NoSuchMethodException e )
catch ( NoSuchMethodException | IllegalAccessException e )
{
cause = e;
}
catch ( IllegalAccessException e )
{
cause = e;
}
catch ( InvocationTargetException e )
} catch ( InvocationTargetException e )
{
cause = e.getTargetException();
}
@@ -1019,26 +1014,13 @@ public static Object callConstructor( OgnlContext context, String className, Obj
}
return ctor.newInstance( actualArgs );
}
catch ( ClassNotFoundException e )
catch ( ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException e )
{
cause = e;
}
catch ( NoSuchMethodException e )
{
cause = e;
}
catch ( IllegalAccessException e )
{
cause = e;
}
catch ( InvocationTargetException e )
} catch ( InvocationTargetException e )
{
cause = e.getTargetException();
}
catch ( InstantiationException e )
{
cause = e;
}

throw new MethodFailedException( className, "new", cause );
}
@@ -1296,19 +1278,7 @@ public static Object getStaticField( OgnlContext context, String className, Stri

return field.get( null );
}
catch ( ClassNotFoundException e )
{
cause = e;
}
catch ( NoSuchFieldException e )
{
cause = e;
}
catch ( SecurityException e )
{
cause = e;
}
catch ( IllegalAccessException e )
catch ( ClassNotFoundException | IllegalAccessException | SecurityException | NoSuchFieldException e )
{
cause = e;
}
@@ -243,17 +243,11 @@ public final Object getValue( OgnlContext context, Object source )
{
result = evaluateGetValueBody( context, source );
}
catch ( OgnlException ex )
{
evalException = ex;
throw ex;
}
catch ( RuntimeException ex )
catch ( OgnlException | RuntimeException ex )
{
evalException = ex;
throw ex;
}
finally
} finally
{
Evaluation eval = context.popEvaluation();

@@ -67,11 +67,7 @@ public Map<String, PropertyDescriptor> create( Class<?> targetClass )

findObjectIndexedPropertyDescriptors( targetClass, result );
}
catch ( IntrospectionException e )
{
throw new CacheException( e );
}
catch ( OgnlException e )
catch ( IntrospectionException | OgnlException e )
{
throw new CacheException( e );
}

0 comments on commit 5165bdd

Please sign in to comment.