Resources ending in "/" cannot be loaded
----------------------------------------

                 Key: PAXWEB-233
                 URL: http://issues.ops4j.org/browse/PAXWEB-233
             Project: Pax Web
          Issue Type: Bug
          Components: Web Container
    Affects Versions: 0.8.1
         Environment: Java 1.6.0_22, Apache Felix 3.0.7
            Reporter: Bryan Keller
            Assignee: Alin Dreghiciu


In pax-web-jetty, resources are not loaded properly if the path ends with a 
trailing slash ("/"). The following code change fixes the problem (this fix is 
tested in 0.8.1 and 1.0.0-SNAPSHOT):
{code}
        @Override
        public URL getResource( final String path )
        {
            if( LOG.isDebugEnabled() )
            {
                LOG.debug( "getting resource: [" + path + "]" );
            }
            URL resource = null;
            
            //FIX start
            final String p;
            if (path != null && path.endsWith("/")) {
                p = path.substring(0, path.length() - 1);
            } else {
                p = path;
            }
            //FIX end
            
            try
            {
                resource = AccessController.doPrivileged(
                    new PrivilegedExceptionAction<URL>()
                    {
                        public URL run()
                            throws Exception
                        {
                            //FIX start
                            return m_httpContext.getResource( p );
                            //return m_httpContext.getResource( path );
                            //FIX end
                        }
                    },
                    m_accessControllerContext
                );
                if( LOG.isDebugEnabled() )
                {
                    LOG.debug( "found resource: " + resource );
                }
            }
            catch( PrivilegedActionException e )
            {
                LOG.warn( "Unauthorized access: " + e.getMessage() );
            }
            return resource;
        }
{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.ops4j.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

_______________________________________________
general mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to