qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject svn commit: r981103 - /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabase.java
Date Sat, 31 Jul 2010 23:46:15 GMT
Author: grkvlt
Date: Sat Jul 31 23:46:15 2010
New Revision: 981103

URL: http://svn.apache.org/viewvc?rev=981103&view=rev
Log:
QPID-2668: Improve PlainPasswordPrincipalDatabase lock management

Applied patch from Sorin Suciu <ssuciu@gmail.com>

Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabase.java

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabase.java?rev=981103&r1=981102&r2=981103&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabase.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/security/auth/database/PlainPasswordFilePrincipalDatabase.java
Sat Jul 31 23:46:15 2010
@@ -179,39 +179,28 @@ public class PlainPasswordFilePrincipalD
             throw new AccountNotFoundException(principal.getName());
         }
 
+        char[] orig = user.getPassword();
+        _userUpdate.lock();
         try
         {
-            try
-            {
-                _userUpdate.lock();
-                char[] orig = user.getPassword();
-                user.setPassword(password);
+            user.setPassword(password);
 
-                try
-                {
-                    savePasswordFile();
-                }
-                catch (IOException e)
-                {
-                    _logger.error("Unable to save password file, password change for user
'" + principal + "' discarded");
-                    //revert the password change
-                    user.setPassword(orig);
-                    return false;
-                }
-                return true;
-            }
-            finally
-            {
-                if (_userUpdate.isHeldByCurrentThread())
-                {
-                    _userUpdate.unlock();
-                }
-            }
+            savePasswordFile();
+
+            return true;
         }
-        catch (Exception e)
+        catch (IOException e)
         {
+            _logger.error("Unable to save password file due to '"+e.getMessage()
+                          +"', password change for user '" + principal + "' discarded");
+            //revert the password change
+            user.setPassword(orig);
             return false;
         }
+        finally
+        {                                   
+            _userUpdate.unlock();
+        }
     }
 
     public boolean createPrincipal(Principal principal, char[] password)



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message