sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r612819 - /incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScriptResolver.java
Date Thu, 17 Jan 2008 13:58:36 GMT
Author: cziegeler
Date: Thu Jan 17 05:57:32 2008
New Revision: 612819

URL: http://svn.apache.org/viewvc?rev=612819&view=rev
Log:
issue SLING-171: NPE in SlingScriptResolver#findScript() implementation 
https://issues.apache.org/jira/browse/SLING-171

Modified:
    incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScriptResolver.java

Modified: incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScriptResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScriptResolver.java?rev=612819&r1=612818&r2=612819&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScriptResolver.java
(original)
+++ incubator/sling/trunk/scripting/resolver/src/main/java/org/apache/sling/scripting/resolver/impl/DefaultSlingScriptResolver.java
Thu Jan 17 05:57:32 2008
@@ -154,6 +154,7 @@
             } else {
                 log.debug("Returning script {} for path {}",
                     scriptResource.getPath(), path);
+                return script;
             }
         } else {
             log.error("No resource found at " + path);
@@ -306,15 +307,18 @@
         String path = resource.getPath();
         String name = path.substring(path.lastIndexOf('/') + 1);
 
-        if (baseName == null || name.startsWith(baseName)) {
-            String ext = name.substring(baseName.length());
-            ScriptEngine engine = getScriptEngineManager().getEngineByExtension(
-                ext);
+        String ext = null;
+        if (baseName == null && name.indexOf(".")>-1) {
+            ext = name.substring(name.lastIndexOf(".")+1);
+        } else if (name.startsWith(baseName)) {
+            ext = name.substring(baseName.length());
+        }
+        if (ext !=null) {
+            ScriptEngine engine = getScriptEngineManager().getEngineByExtension(ext);
             if (engine != null) {
                 return new DefaultSlingScript(resource, engine);
             }
         }
-
         return null;
     }
 }



Mime
View raw message