From 902dca06caf4ed1546efaa48977edba18a53d66b Mon Sep 17 00:00:00 2001 From: Kusal Kithul-Godage Date: Fri, 26 Jul 2024 19:28:12 +1000 Subject: [PATCH] WW-5449 Minor clean up --- .../views/velocity/VelocityManager.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java index 2b06e84bc..e1cfa8cd0 100644 --- a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java +++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java @@ -208,25 +208,24 @@ public class VelocityManager implements VelocityManagerInterface { */ private void applyUserConfiguration(ServletContext context, Properties properties) { String configFile = requireNonNullElse(customConfigFile, "velocity.properties").trim(); - boolean isLoaded = false; try { - isLoaded = loadFile(properties, context.getRealPath(configFile)); + if (loadFile(properties, context.getRealPath(configFile))) { + return; + } } catch (IOException e) { LOG.warn("Unable to load Velocity configuration from servlet context path", e); } - if (!isLoaded) { - try { - isLoaded = loadFile(properties, context.getRealPath("/WEB-INF/" + configFile)); - } catch (IOException e) { - LOG.warn("Unable to load Velocity configuration from WEB-INF path", e); + try { + if (loadFile(properties, context.getRealPath("/WEB-INF/" + configFile))) { + return; } + } catch (IOException e) { + LOG.warn("Unable to load Velocity configuration from WEB-INF path", e); } - if (!isLoaded) { - try { - isLoaded = loadClassPathFile(properties, configFile); - } catch (IOException e) { - LOG.warn("Unable to load Velocity configuration from classpath", e); - } + try { + loadClassPathFile(properties, configFile); + } catch (IOException e) { + LOG.warn("Unable to load Velocity configuration from classpath", e); } }