You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by ff...@apache.org on 2014/04/15 09:08:13 UTC

git commit: [KARAF-2910]Properties login module leak a PropertiesInstaller reference results in OOM

Repository: karaf
Updated Branches:
  refs/heads/karaf-2.3.x c6cb968c2 -> a1b2aac03


[KARAF-2910]Properties login module leak a PropertiesInstaller reference results in OOM


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/a1b2aac0
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/a1b2aac0
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/a1b2aac0

Branch: refs/heads/karaf-2.3.x
Commit: a1b2aac03b675fb18936674cc050135fc683eb09
Parents: c6cb968
Author: Freeman Fang <fr...@gmail.com>
Authored: Tue Apr 15 15:04:54 2014 +0800
Committer: Freeman Fang <fr...@gmail.com>
Committed: Tue Apr 15 15:04:54 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/a1b2aac0/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/a1b2aac0/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 9ce8940..a3e9b79 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
@@ -45,7 +45,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) {
@@ -54,10 +54,16 @@ public class PropertiesLoginModule extends AbstractKarafLoginModule {
         if (debug) {
             LOG.debug("Initialized debug=" + debug + " usersFile=" + 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 {