]
Peter Palaga updated GTNPORTAL-3510:
------------------------------------
Status: Pull Request Sent (was: Open)
Git Pull Request:
Possible memory leaks, consistency issues and concurrency issues in
ScriptGraph
-------------------------------------------------------------------------------
Key: GTNPORTAL-3510
URL:
https://issues.jboss.org/browse/GTNPORTAL-3510
Project: GateIn Portal
Issue Type: Feature Request
Security Level: Public(Everyone can see)
Reporter: Peter Palaga
Assignee: Peter Palaga
h4. Problems in the Present State
(1) Consitency: there are {{IllegalStateException}} s thrown when adding resources from a
deployment. Those exceptions can be thrown in the middle of such an adding which can lead
to an inconsistent state when resources from a particular deployment are partly there and
partly not there in the {{ScriptGraph}}.
(2) Consitency: The present resource removal code does not ensure that a removed resource
is also removed from dependent resources, closures and load groups. There are also no
tests checking that.
(3) Possible leaks: closures and load groups are not cleaned upon resource removals which
can lead to memory leaks. This is a consequence of (2).
(4) Concurrency: add and remove operations manipulate directly with collection instances
that can be read (e.g. via {{getResource()}}) concurrently from other threads.
h4. Solution proposal
\(i) Make {{ScriptGraph}} immutable and always create a new instance (using some kind of
builder pattern) when adding or removing resources. This should solve problems (1) and
(4).
(ii) Improve the resource removal code to the effect that dependencies, closures and load
groups are kept consistent upon removals. Add tests. This should solve problems (2) and
(3).