cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hugh Sparks" <h...@csparks.com>
Subject [C22] _editor_url not set and NPE in DynamicURLStreamHandlerFactory
Date Tue, 30 Nov 2010 18:14:40 GMT
I had a simple cocoon forms application that crashed
occasionally but not reproducibly with an NPE exception:

    java.lang.NullPointerException
        java.util.LinkedList.remove(LinkedList.java:808)
        java.util.LinkedList.remove(LinkedList.java:374)
        org.apache.cocoon.jnet.DynamicURLStreamHandlerFactory
           .pop(DynamicURLStreamHandlerFactory.java:30)
        org.apache.cocoon.jnet.URLHandlerFactoryCollector
            .popUrlHandlerFactories(URLHandlerFactoryCollector.java:58)
    [...]

I had another apparently unrelated problem where the client
browser would sometimes report that "_editor_url is not set".
This occurred after the browser's page cache had been cleared, but
it would stop occurring on subsequent visits to my cforms application.

Both problems were resolved when I applied a fix suggested
by Reinhard Pötz on the mailing list in February 2010:

    http://tinyurl.com/24599z4

And most recently discussed on JIRA:

    https://issues.apache.org/jira/browse/COCOON-2277

Perhaps this fix hides some deeper issue, but all the published
samples seem to work fine with the change. If nothing better can
be suggested (it's been nearly a year), I think it would be nice if
it were committed to the trunk.

********************

For those who'd like to evaluate this fix, here's a quick summary:

In the directory:

    Cocoon22\subprojects\cocoon-jnet\src\main\java\org\apache\cocoon\jnet

In the file:

    DynamicURLStreamHandlerFactory.java

Edit line 41 so it reads:

    list = Collections.synchronizedList(new LinkedList<URLStreamHandlerFactory>()) ;

Here's the modified code in context:

OLD:

    if (list == null) {
        list = new LinkedList<URLStreamHandlerFactory>();
        FACTORIES.set(list);
    }

NEW:

    if (list == null) {
        list = Collections.synchronizedList(new LinkedList<URLStreamHandlerFactory>())
;
        FACTORIES.set(list);
    }

It's also necessary to import Collections:

    import java.util.Collections;

Thanks,

-Hugh Sparks 


Mime
View raw message