[jboss-dev] How to fix vfs?

Adrian Brock abrock at redhat.com
Tue Feb 17 11:25:21 EST 2009


On Tue, 2009-02-17 at 17:31 +0200, Dimitris Andreadis wrote:
> https://jira.jboss.org/jira/browse/JBAS-6513

This should be fixed with Ales's latest changes?

> https://jira.jboss.org/jira/browse/JBCTS-900
> 

This is broken because of ...

On Tue, 2009-02-17 at 16:53 +0100, Ales Justin wrote: 
> e.g. with some TCK tests and (6) it was such a small detail as '/' at 
> the end of URI.

The main reason I originally looked at the VFS code was because
it was unusable due to inconsistencies between paths (not URI/URLs)
that may or not may not end with a /

Sometimes they did and sometimes they didn't and it was very random
(even internally within the same VFS call).

I changed the code so that the internal VFS paths always used the
version without the trailing / which meant
1) It was always consistent
2) You didn't have to play around with complicated path matching
or string manipulation within the critical (i.e. potentially slow)
sections of the code.

This change
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java?r1=83684&r2=83683&pathrev=83684
and its current usage within the VFS make all that for nothing.

e.g. in DefaultVFSRegistry.getFile(URI)

      VFSContext context = getCache().findContext(uri);
      if (context != null)
      {

// THIS ALWAYS ADD AS A / TO THE END OF THE PATH
// IT SHOULD NOT, ITS USED AS AN INTERNAL VFS PATH (SEE BELOW)

         String relativePath = VFSUtils.getRelativePath(context, uri);
         for (TempInfo ti : context.getTempInfos())
         {
            String path = ti.getPath();
            if (relativePath.startsWith(path))
            {

// THIS WILL FAIL BECAUSE OF THE / ON THE INTERNAL VFS PATH
// IT TRANSLATES TO root.getChild(path + "/")

               String subpath = relativePath.substring(path.length());
               VirtualFileHandler child = findHandler(ti.getHandler(),
subpath, true);
               if (child != null)
                  return child.getVirtualFile();
            }
         }

If you include the URL <-> URI mapping in that code, its also likely to
be far too much string manipulation/searching to be performant under any
kind of load.

>From the part of the stacktrace that is failing, there's at least 5
potentially expensive operations always performed.

at
org.jboss.virtual.plugins.registry.DefaultVFSRegistry.findHandler(DefaultVFSRegistry.java:107)

1) stripProtocol => StringBuffer construction
2) substring in VFSUtils.getRelativePath()
3) relativePath.startsWith()
4) relativePath.substring()

at
org.jboss.virtual.plugins.registry.DefaultVFSRegistry.getFile(DefaultVFSRegistry.java:81) 
at

5) URL -> URI mapping

org.jboss.virtual.plugins.registry.DefaultVFSRegistry.getFile(DefaultVFSRegistry.java:119) 
at
org.jboss.virtual.protocol.AbstractVFSHandler.openConnection(AbstractVFSHandler.java:71)
-- 
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Adrian Brock
Chief Scientist
JBoss, a division of Red Hat
xxxxxxxxxxxxxxxxxxxxxxxxxxxx




More information about the jboss-development mailing list