[jboss-cvs] JBossAS SVN: r102072 - branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 8 12:15:09 EST 2010
Author: smarlow at redhat.com
Date: 2010-03-08 12:15:09 -0500 (Mon, 08 Mar 2010)
New Revision: 102072
Modified:
branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java
Log:
JBPAPP-3677 MBean operation JBossManagedConnectionPool.testConnection results in a failed connection when using a security-domain
Modified: branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java
===================================================================
--- branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java 2010-03-08 17:10:52 UTC (rev 102071)
+++ branches/JBPAPP_5_0/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java 2010-03-08 17:15:09 UTC (rev 102072)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -24,7 +24,6 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Iterator;
-import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -337,6 +336,38 @@
}
}
+ private boolean internalTestConnection(Subject subject)
+ {
+ boolean result = false;
+ ConnectionListener cl = null;
+ try
+ {
+ if (getAvailableConnectionCount() > 0)
+ {
+ cl = poolingStrategy.getConnection(null, subject, null);
+ result = true;
+ }
+ }
+ catch (Exception ignored)
+ {
+ }
+ finally
+ {
+ if (cl != null)
+ {
+ try
+ {
+ poolingStrategy.returnConnection(cl, false);
+ }
+ catch (ResourceException ire)
+ {
+ }
+ }
+ }
+ return result;
+ }
+
+
/**
* Test if a connection can be obtained using default values
* @return True if a connection was obtained; otherwise false
@@ -347,30 +378,30 @@
{
boolean result = false;
ConnectionListener cl = null;
- try
+ // first try to get connection with Subject
+ if (poolingStrategy instanceof BasePool)
{
- if (getAvailableConnectionCount() > 0)
+ BasePool basePool = (BasePool)poolingStrategy;
+ if (basePool.clf instanceof BaseConnectionManager2)
{
- cl = poolingStrategy.getConnection(null, null, null);
- result = true;
- }
- }
- catch (ResourceException re)
- {
- }
- finally
- {
- if (cl != null)
- {
- try
- {
- poolingStrategy.returnConnection(cl, false);
+ try {
+ BaseConnectionManager2 baseConnectionMgr = (BaseConnectionManager2)basePool.clf;
+ Subject subject = baseConnectionMgr.getSubjectFactory().createSubject(baseConnectionMgr.getSecurityDomainJndiName());
+ result = internalTestConnection(subject);
}
- catch (ResourceException ire)
+ catch ( Exception ignored ) // createSubject could throw security exception, ignore it
{
+
}
}
}
+
+ // then try to get connection without Subject
+ if (!result)
+ {
+ result = internalTestConnection(null);
+ }
+
return result;
}
More information about the jboss-cvs-commits
mailing list