Properly release linkResolver to avoid memory leak.
git-svn-id: https://svn.apache.org/repos/asf/lenya/branches/BRANCH_2_1_X@1670315 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/UuidToUrlModule.java b/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/UuidToUrlModule.java
index a121045..94fedc3 100644
--- a/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/UuidToUrlModule.java
+++ b/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/UuidToUrlModule.java
@@ -44,9 +44,10 @@
public Object getAttribute(String name, Configuration modeConf, Map objectModel)
throws ConfigurationException {
Request request = ObjectModelHelper.getRequest(objectModel);
+ LinkResolver linkResolver = null;
try {
DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
- LinkResolver linkResolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE);
+ linkResolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE);
String currentUrl = ServletHelper.getWebappURI(request);
UuidToUrlRewriter rewriter = new UuidToUrlRewriter(currentUrl, linkResolver, factory);
@@ -58,6 +59,10 @@
} catch (final Exception e) {
throw new ConfigurationException("Resolving link " + name + " failed: ", e);
+ } finally {
+ if (linkResolver != null) {
+ this.manager.release(linkResolver);
+ }
}
}
diff --git a/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java b/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java
index c116513..810fda0 100644
--- a/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java
+++ b/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java
@@ -169,6 +169,10 @@
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
+ } finally {
+ if (resolver != null) {
+ this.manager.release(resolver);
+ }
}
}
diff --git a/src/modules/navigation/java/src/org/apache/lenya/modules/navigation/SiteMetaDataTransformer.java b/src/modules/navigation/java/src/org/apache/lenya/modules/navigation/SiteMetaDataTransformer.java
index 2acbabf..e1a3ea0 100644
--- a/src/modules/navigation/java/src/org/apache/lenya/modules/navigation/SiteMetaDataTransformer.java
+++ b/src/modules/navigation/java/src/org/apache/lenya/modules/navigation/SiteMetaDataTransformer.java
@@ -75,7 +75,7 @@
public void dispose() {
super.dispose();
- if (this.linkResolver == null) {
+ if (this.linkResolver != null) {
this.manager.release(linkResolver);
}
}