incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r483252 - /incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ClassLoaderUtils.java
Date Wed, 06 Dec 2006 21:52:50 GMT
Author: awiner
Date: Wed Dec  6 13:52:45 2006
New Revision: 483252

URL: http://svn.apache.org/viewvc?view=rev&rev=483252
Log:
Common mistake when using ClassLoader.getResource() or getResourceAsStream() is to pass an
URL that begins with a slash.  Works on some app servers, doesn't work on others.  Log a warning
when this happens.

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ClassLoaderUtils.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ClassLoaderUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ClassLoaderUtils.java?view=diff&rev=483252&r1=483251&r2=483252
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ClassLoaderUtils.java
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-api/src/main/java/org/apache/myfaces/trinidad/util/ClassLoaderUtils.java
Wed Dec  6 13:52:45 2006
@@ -147,6 +147,8 @@
     String      name,
     ClassLoader callerClassLoader)
   {
+    _checkResourceName(name);
+
     URL url = null;
 
     ClassLoader loader = getContextClassLoader();
@@ -180,6 +182,8 @@
     String      name,
     ClassLoader callerClassLoader)
   {
+    _checkResourceName(name);
+
     InputStream stream = null;
 
     ClassLoader loader = getContextClassLoader();
@@ -293,6 +297,15 @@
     return null;
   }
 
+  private static void _checkResourceName(String name)
+  {
+    if ((name != null) && name.startsWith("/"))
+    {
+      _LOG.warning("Resource name \"" + name + "\" begins with a slash, " +
+                   "which is not portable.");
+                   
+    }
+  }
 
   private static final TrinidadLogger _LOG =
     TrinidadLogger.createTrinidadLogger(ClassLoaderUtils.class);



Mime
View raw message