You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2012/08/30 08:19:19 UTC

[Bug 53800] New: Infinte loop cause by FileDirContext in a CDI/Weld project when using Eclipse's "Server modules without publishing"

https://issues.apache.org/bugzilla/show_bug.cgi?id=53800

          Priority: P2
            Bug ID: 53800
          Assignee: dev@tomcat.apache.org
           Summary: Infinte loop cause by FileDirContext in a CDI/Weld
                    project when using Eclipse's "Server modules without
                    publishing"
          Severity: normal
    Classification: Unclassified
                OS: All
          Reporter: kdubb@me.com
          Hardware: All
            Status: NEW
           Version: trunk
         Component: Catalina
           Product: Tomcat 7

Created attachment 29302
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29302&action=edit
Patch for FileDirContext.java

Weld's TomcatListener is using the recurse method recited below. In the case I
am encountering the DirContext that Tomcat provides is a FileDirContext.

The discovery code used by Weld encounters what appears to be a bug in
FileDirContext where FileDirContexts for child directories are created with the
current FileDirContext's path. This causes an infinite loop while it searches
the root directory over and over.

Assuming the class discovery code Weld is using is correct, I tracked down the
problem to a specific line in FileDirContext.java.  Fixing this line to set the
path of the new child FileDirContext to the matching child directory fixes the
issue I am encountering. With this change the project appears to still pass all
the unit tests ran with "ant test". I have attached the patch to this issue.


Here is Weld's recurse function which I am assuming is correct...

protected static void recurse(DirContext context, Set<String> classes, Set<URL>
urls, String prefix) throws Exception {
    if (prefix.length() > 0)
        prefix += ".";

    NamingEnumeration ne = context.listBindings("");
    while (ne.hasMoreElements()) {
        Binding next = (Binding) ne.nextElement();
        String name = prefix + next.getName();
        if (name.endsWith(".class")) {
            classes.add(name.substring(0, name.length() - 6));
            continue;
        }

        Object nextObject = next.getObject();
        if (nextObject instanceof DirContext) {
            recurse((DirContext) nextObject, classes, urls, name);
        }
    }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 53800] Infinte loop cause by FileDirContext in a CDI/Weld project when using Eclipse's "Server modules without publishing"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53800

Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #29302|0                           |1
           is patch|                            |
  Attachment #29302|application/octet-stream    |text/plain
          mime type|                            |

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 53800] Infinte loop cause by FileDirContext in a CDI/Weld project when using Eclipse's "Server modules without publishing"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53800

--- Comment #2 from Mark Thomas <ma...@apache.org> ---
Fixed in 6.0.x and will be included in 6.0.36

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 53800] Infinte loop cause by FileDirContext in a CDI/Weld project when using Eclipse's "Server modules without publishing"

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53800

Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Konstantin Kolinko <kn...@gmail.com> ---
Fixed in 7.0 with r1378819 and will be in 7.0.30.
Proposed for 6.0.


> Here is Weld's recurse function which I am assuming is correct...

It would be a lot better if they used Servlet API
(ServletContext.getResourcePaths(..)) for their task.
Well, I do not know all circumstances.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org