[
https://issues.apache.org/jira/browse/TRB-101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17340149#comment-17340149
]
Thomas Vandahl commented on TRB-101:
------------------------------------
I guess the key issue here is the lifecycle of the pooled group objects within
the tool. It looks like the location you mention is not the only one where
group objects are leaked. We need to think of a better solution.
In the meantime, as a workaround, copying the code of IntakeTool into a class
of your own and patching this could be the way to go.
> Object leak in IntakeTool
> -------------------------
>
> Key: TRB-101
> URL: https://issues.apache.org/jira/browse/TRB-101
> Project: Turbine
> Issue Type: Bug
> Components: Core
> Affects Versions: Core 4.0 Final, Core 5.0
> Environment: Linux
> Reporter: Susi Berrington
> Priority: Major
>
> We're trying to upgrade to Turbine4.0 and are finding that everything works
> fine for a while but then seizes up (blocks).
> Turns out that there's an object leak in the init() method in IntakeTool.
> [http://svn.apache.org/viewvc/turbine/core/trunk/src/java/org/apache/turbine/services/intake/IntakeTool.java?revision=1886259&view=markup#l134]
> {code:java}
> List<Group> foundGroups = intakeService.getGroup(groupNames[i])
> .getObjects(pp);{code}
> getGroup() is doing borrowObject() on a commons-pool2 pool but when we do
> getObjects() our reference to the object borrowed by getGroup() is lost, we
> can never release the borrowed object.
> I couldn't believe that this was new to 4.0 so I reverted to 2.3.3. This
> code is the same but the object pool is 1.5.6 and the limit is not enforced
> so we get away with the number of objects just going up and up.
> A fix could be:
> {code:java}
> for (int i = groupNames.length - 1; i >= 0; i--)
> {
> Group foundGroup = null;
> try
> {
> foundGroup = intakeService.getGroup(groupNames[i]);
> List<Group> foundGroups = foundGroup.getObjects(pp);
> if (foundGroups != null)
> {
> for (Group group : foundGroups)
> {
> groups.put(group.getObjectKey(), group);
> }
> }
> }
> catch (IntakeException e)
> {
> log.error(e);
> } finally {
> if (foundGroup != null)
> {
> try
> {
> intakeService.releaseGroup(foundGroup);
> } catch (IntakeException intakeException) {
> log.error(intakeException, intakeException);
> }
> }
> }
> }
> {code}
>
> I'm trying to find a way to hack round this. I've created a class which
> extends IntakeTool and just implements the init() method but I can't
> initialise pullMap so whenever we tried to actually use Intake we get a
> NullPointerException as pullMap is still null but is assumed to be
> initialised, which is fair enough! Can think of a better work around?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)