scantor commented on code in PR #51:
URL: https://github.com/apache/velocity-engine/pull/51#discussion_r1747036987


##########
spring-velocity-support/src/main/java/org/apache/velocity/spring/VelocityEngineFactory.java:
##########
@@ -259,41 +281,61 @@ protected VelocityEngine newVelocityEngine() throws 
IOException, VelocityExcepti
      */
     protected void initVelocityResourceLoader(VelocityEngine velocityEngine, 
String resourceLoaderPath) {
        if (isPreferFileSystemAccess()) {
+           
+           // Only used with enhanced processing.
+            final List<String> filePaths = new ArrayList<>();
+            final List<String> nonFilePaths = new ArrayList<>();
+
+            String[] paths = 
StringUtils.commaDelimitedListToStringArray(resourceLoaderPath);
+
                // Try to load via the file system, fall back to 
SpringResourceLoader
                // (for hot detection of template changes, if possible).
-               try {
-                       StringBuilder resolvedPath = new StringBuilder();
-                       String[] paths = 
StringUtils.commaDelimitedListToStringArray(resourceLoaderPath);
-                       for (int i = 0; i < paths.length; i++) {
-                               String path = paths[i];
+                       for (int i = 0; i < paths.length; i++) {
+                               String path = paths[i];
+                               
+                // Don't check classpath: locations, they're not file-based.
+                // Some containers will expand jars and trigger false 
positives.
+                               // If enhanced behavior isn't on, this will 
fall into the usual code it did before.
+                if (isSupportClasspathEnhancements() && 
path.startsWith(ResourceLoader.CLASSPATH_URL_PREFIX)) {

Review Comment:
   Ir's configured via Spring, you'd set the property in your 
VelocityEngineFactoryBean instance (which is a subclass of this class for what 
I guess are historical reasons). The point is that it's not an engine setting, 
but a control point for how the factory bean installs the 2 resource loaders by 
injecting engine properties.
   
   However, I still believe it's unneeded. There is no value to not setting it 
to true because false (the old behavior) is just wrong and broken.
   
   My advice is that I redo the patch without the option and we just fix the 
bug.
   
   I phrased it to begin with as an enhancement, but as I reviewed the original 
code again, I just realize it's wrong. Whoeever wrote it either didn't have a 
clear goal, or didn't manage to implement what they meant to.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org

Reply via email to