Hao Zhong created ARIES-1748:
--------------------------------
Summary: Resouce leak in Subsystems
Key: ARIES-1748
URL: https://issues.apache.org/jira/browse/ARIES-1748
Project: Aries
Issue Type: Bug
Reporter: Hao Zhong
The Subsystems_getRootSubsystem method has the following code:
{code:java}
try {
root = new BasicSubsystem(resource);
// TODO This initialization is a bit
brittle. The root subsystem
// must be gotten before anything else
will be able to use the
// graph. At the very least, throw
IllegalStateException where
// appropriate.
graph = new SubsystemGraph(root);
ResourceInstaller.newInstance(coordination, root, root).install();
populateRootSubsystem(root,
coordination);
} catch (Exception e) {
coordination.fail(e);
} finally {
coordination.end();
}
{code}
Here, coordination.end() can fail to clean up resources. Indeed, ARIES-1187
fixed a similar problem. The fixed code handles the problem more seriously:
{code:java}
public BasicSubsystem run() {
...
finally {
try {
coordination.end();
}
catch (CoordinationException e) {
Throwable t = e.getCause();
if (t instanceof SubsystemException)
throw (SubsystemException)t;
if (t instanceof SecurityException)
throw (SecurityException)t;
throw new SubsystemException(t);
}
finally {
closeContentIfIClosable();
}
}
closeContentIfIClosable();
...
}
private void closeContentIfIClosable() {
//clean up temp file
if (content instanceof ICloseableDirectory) {
try{
((ICloseableDirectory) content).close();
}
catch (IOException ioex) {
logger.info("Exception calling close for
content {}. Exception {}",
content, ioex);
}
}
}
{code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)