On Thu, Jul 21, 2011 at 9:41 PM, Bertrand, Matt
<mbertr...@cga.harvard.edu> wrote:
> Hello,
> I am running a customized GeoNode instance (which I know complicates things)
> that has been exhibiting a serious but intermittent problem when a layer is
> added or removed in the GeoServer 2.1 catalog:  many layers suddenly become
> inaccessible via WMS/WFS with NullPointerExceptions thrown in the log (see
> Exception #1 below).  In the GeoServer admin interface, all layers still
> appear in the list, but each problematic layer's 'Edit' page throws a
> similar exception (see #2 below).  Restarting geoserver's Tomcat container
> resolves the issue until it happens again.  The problem has increased in
> frequency as the site's traffic has increased.  Could this be a concurrency
> issue related to the catalog cache?
> Exception #1:
>
> 19 Jul 09:49:14 ERROR [wms.capabilities] - An error occurred trying to
> determine if the layer is geometryless
> java.lang.NullPointerException
>       at
> org.geoserver.catalog.impl.DefaultCatalogFacade.getResource(DefaultCatalogFacade.java:288)

Never seen it, but I see how this could happen. The two blocks of relevant code:

    public <T extends ResourceInfo> T getResource(String id, Class<T> clazz) {
        List l = lookup(clazz, resources);
        for (Iterator i = l.iterator(); i.hasNext();) {
            ResourceInfo resource = (ResourceInfo) i.next();
            if (id.equals(resource.getId())) {
                return ModificationProxy.create((T) resource, clazz );
            }
        }

        return null;
    }


    List lookup(Class clazz, MultiHashMap map) {
        ArrayList result = new ArrayList();
        for (Iterator k = map.keySet().iterator(); k.hasNext();) {
            Class key = (Class) k.next();
            if (clazz.isAssignableFrom(key)) {
                result.addAll(map.getCollection(key));
            }
        }

        return result;
    }

The list returned by lookup will contain a null value if the map contents
are modified (entry removed I guess) while scanning over its contents.
A concurrent data structure should be used instead imho (probably
a combination of two concurrent structures, multimap cannot be replaced
with just one).
Or, alternatively, wrap everything with read/write locks

Cheers
Andrea

-- 
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy

phone: +39 0584 962313
fax:      +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-------------------------------------------------------

------------------------------------------------------------------------------
5 Ways to Improve & Secure Unified Communications
Unified Communications promises greater efficiencies for business. UC can 
improve internal communications as well as offer faster, more efficient ways
to interact with customers and streamline customer service. Learn more!
http://www.accelacomm.com/jaw/sfnl/114/51426253/
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to