Skip to content

Commit 8b17861

Browse files
author
Faisal Hameed
committed
Fixing squid:S2147 - Catches should be combined.
1 parent 9c54267 commit 8b17861

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

activeweb/src/main/java/org/javalite/activeweb/DynamicClassFactory.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public static <T> T createInstance(String className, Class<T> expectedType) thro
2323
Object o = getCompiledClass(className).newInstance();
2424
T instance = expectedType.cast(o);
2525
return instance ;
26-
} catch (CompilationException e) {
27-
throw e;
28-
} catch (ClassLoadException e) {
26+
} catch (CompilationException | ClassLoadException e) {
2927
throw e;
3028
} catch (ClassCastException e) {
3129
throw new ClassLoadException("Class: " + className + " is not the expected type, are you sure it extends " + expectedType.getName() + "?");

activeweb/src/main/java/org/javalite/activeweb/RenderTemplateResponse.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ void doProcess() {
8787
try {
8888
templateManager.merge(values, template, layout, format, Context.getHttpResponse().getWriter());
8989
}
90-
catch (IllegalStateException e){
91-
throw e;
92-
}
93-
catch (ViewException e) {
90+
catch (IllegalStateException | ViewException e){
9491
throw e;
9592
}
9693
catch (Exception e) {

activeweb/src/main/java/org/javalite/activeweb/RequestDispatcher.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,9 @@ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain
219219
}
220220
} catch (CompilationException e) {
221221
renderSystemError(e);
222-
} catch (ClassLoadException e) {
222+
} catch (ClassLoadException | ActionNotFoundException e) {
223223
renderSystemError("/system/404", useDefaultLayoutForErrors() ? getDefaultLayout():null, 404, e);
224-
}catch (ActionNotFoundException e) {
225-
renderSystemError("/system/404", useDefaultLayoutForErrors() ? getDefaultLayout():null, 404, e);
226-
}catch(ViewMissingException e){
227-
renderSystemError("/system/404", useDefaultLayoutForErrors() ? getDefaultLayout():null, 404, e);
228-
}catch(RouteException e){
224+
}catch(ViewMissingException | RouteException e){
229225
renderSystemError("/system/404", useDefaultLayoutForErrors() ? getDefaultLayout():null, 404, e);
230226
}catch(ViewException e){
231227
renderSystemError("/system/error", useDefaultLayoutForErrors() ? getDefaultLayout():null, 500, e);

0 commit comments

Comments
 (0)