On Sun, Apr 28, 2013 at 2:03 AM, Andrea Aime
<[email protected]>wrote:

> Hi,
> I was playing around with the INSPIRE extension and I've noticed this
> issue.
> Basically, ModificationProxy fails to guard against modification of
> collections, when the modification hits a mutable item contained in it.
>
> ModificationProxy collection handling basically clones then collection
> before returning it, so that the caller works against a copy, but fails to
> deep clone it,
> as a result:
> * if the client adds/removes items from the returned collection nothing
> bad happens
> * if the client grabs an item from the collection and alters it, it's
> actually modifying the same item referred by the original collection
>
> One example where this is happening in our GUI is the metadata links.
> Here is a little experiment:
> 1) Go to a layer, add a new metadata link with url "http://www.test.com";,
> save the layer.
> 2) Open the same layer, modify the url to be "http://www.test.com/123";
> 3) Add a new link (this will force wicket to partially submit the form and
> thus change the state of the objects behind the GUI, which are coming from
> the ModificationProxy anyways)
> 4) Exit by pressing cancel
> 5) Open back the same layer and observe the results. The new link is not
> there, but the url of the first one got modified.
>
> I haven't tried, but guess anything that's mutable and stuck in the
> metadata map will follow the same destiny (e.g., SQL view definitions).
>
> Now... what to do about it.
> We cannot wrap the collection contents in other ModificationProxies,
> because we don't have a target interface for them.
> I guess we can deep clone them. Deep cloning is not simple, and one might
> need some way to control how to stop the cloning at some point (so cloning
> by serialization is out of the question).
> I've found this library that seems to be doing a decent job at deep
> cloning in memory with some cloning control:
> https://code.google.com/p/cloning/wiki/Usage
>
> The library is also quite small. The idea is that we'd use a Spring
> registered Cloner object to deep clone the contents of all collections
> before returning them out of a modification proxy.
>

Hmmm... i am kind of hesitant to add a new library dependency at such a
core level. Thinking, what about using annotations for this? Basically we
could come up with something that looked like this:

LayerInfo {

  @Proxy(target=MetadataLinkInfo.class)
  List<MetadataLinkinfo> getMetadataLinks();

}

Which could then be recognized by ModProxy and an appropriate collection
wrapper wrapping individual elements in a proxy could be implemented.


> What do you think?
>
> Cheers
> Andrea
>
> PS: I know this is yet another band aid, however I don't see any good
> solution in sight until we can replace the whole config subsystem with a
> storage that's not memory based and understands transactions.
> At the moment I'm just trying to get the INSPIRE piugin going, not trying
> to start a crusade to improve the config subsytem...
>
> --
> ==
> GeoServer training in Milan, 6th & 7th June 2013!  Visit
> http://geoserver.geo-solutions.it for more information.
> ==
>
> Ing. Andrea Aime
> @geowolf
> Technical Lead
>
> GeoSolutions S.A.S.
> Via Poggio alle Viti 1187
> 55054  Massarosa (LU)
> Italy
> phone: +39 0584 962313
> fax: +39 0584 1660272
> mob: +39  339 8844549
>
> http://www.geo-solutions.it
> http://twitter.com/geosolutions_it
>
> -------------------------------------------------------
>
>
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
> _______________________________________________
> Geoserver-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geoserver-devel
>
>


-- 
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to