Repository: karaf Updated Branches: refs/heads/karaf-3.0.x 9386e2344 -> cec142435
[KARAF-2910]Properties login module leak a PropertiesInstaller reference results in OOM (cherry picked from commit a1b2aac03b675fb18936674cc050135fc683eb09) (cherry picked from commit f74a1dcdcf28f0615ab28519716b844c20b84edc) Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/20601d2b Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/20601d2b Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/20601d2b Branch: refs/heads/karaf-3.0.x Commit: 20601d2b4a99fed54453e407f6b428fbb86a6bea Parents: 9386e23 Author: Freeman Fang <[email protected]> Authored: Tue Apr 15 15:04:54 2014 +0800 Committer: Freeman Fang <[email protected]> Committed: Tue Apr 15 15:18:56 2014 +0800 ---------------------------------------------------------------------- .../modules/properties/PropertiesInstaller.java | 4 ++++ .../modules/properties/PropertiesLoginModule.java | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/20601d2b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/PropertiesInstaller.java ---------------------------------------------------------------------- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/PropertiesInstaller.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/PropertiesInstaller.java index d8bcacd..5cc0c11 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/PropertiesInstaller.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/PropertiesInstaller.java @@ -64,5 +64,9 @@ public class PropertiesInstaller implements ArtifactInstaller { public void uninstall(File artifact) throws Exception { LOGGER.warn("the users.properties was removed"); } + + public String getUsersFileName() { + return this.usersFileName; + } } http://git-wip-us.apache.org/repos/asf/karaf/blob/20601d2b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/PropertiesLoginModule.java ---------------------------------------------------------------------- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/PropertiesLoginModule.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/PropertiesLoginModule.java index b7d375d..d78f891 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/PropertiesLoginModule.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/properties/PropertiesLoginModule.java @@ -49,7 +49,7 @@ public class PropertiesLoginModule extends AbstractKarafLoginModule { private String usersFile; - private PropertiesInstaller propertiesInstaller; + private static PropertiesInstaller propertiesInstaller; public void initialize(Subject sub, CallbackHandler handler, Map sharedState, Map options) { @@ -58,10 +58,16 @@ public class PropertiesLoginModule extends AbstractKarafLoginModule { if (debug) { LOGGER.debug("Initialized debug={} usersFile={}", debug, usersFile); } - propertiesInstaller = new PropertiesInstaller(this, usersFile); - if (this.bundleContext != null) { - this.bundleContext.registerService("org.apache.felix.fileinstall.ArtifactInstaller", propertiesInstaller, null); - } + + if (propertiesInstaller == null || !usersFile.equals(propertiesInstaller.getUsersFileName()) ) { + + LOG.debug("Register PropertiesInstaller service"); + + propertiesInstaller = new PropertiesInstaller(this, usersFile); + if (this.bundleContext != null) { + this.bundleContext.registerService("org.apache.felix.fileinstall.ArtifactInstaller", propertiesInstaller, null); + } + } } public boolean login() throws LoginException {
