mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-08 19:42:48 +00:00
SEC-547: Release database connections between each layer of parent lookups.
This commit is contained in:
parent
677607bcad
commit
d79485a975
@ -275,7 +275,7 @@ public final class BasicLookupStrategy implements LookupStrategy {
|
|||||||
String sql = computeRepeatingSql("(ACL_OBJECT_IDENTITY.OBJECT_ID_IDENTITY = ? and ACL_CLASS.CLASS = ?)",
|
String sql = computeRepeatingSql("(ACL_OBJECT_IDENTITY.OBJECT_ID_IDENTITY = ? and ACL_CLASS.CLASS = ?)",
|
||||||
objectIdentities.length);
|
objectIdentities.length);
|
||||||
|
|
||||||
jdbcTemplate.query(sql,
|
Set parentsToLookup = (Set) jdbcTemplate.query(sql,
|
||||||
new PreparedStatementSetter() {
|
new PreparedStatementSetter() {
|
||||||
public void setValues(PreparedStatement ps)
|
public void setValues(PreparedStatement ps)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
@ -293,6 +293,11 @@ public final class BasicLookupStrategy implements LookupStrategy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new ProcessResultSet(acls, sids));
|
}, new ProcessResultSet(acls, sids));
|
||||||
|
|
||||||
|
// Lookup the parents, now that our JdbcTemplate has released the database connection (SEC-547)
|
||||||
|
if (parentsToLookup.size() > 0) {
|
||||||
|
lookupPrimaryKeys(acls, parentsToLookup, sids);
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, convert our "acls" containing StubAclParents into true Acls
|
// Finally, convert our "acls" containing StubAclParents into true Acls
|
||||||
Map resultMap = new HashMap();
|
Map resultMap = new HashMap();
|
||||||
@ -324,7 +329,7 @@ public final class BasicLookupStrategy implements LookupStrategy {
|
|||||||
|
|
||||||
String sql = computeRepeatingSql("(ACL_OBJECT_IDENTITY.ID = ?)", findNow.size());
|
String sql = computeRepeatingSql("(ACL_OBJECT_IDENTITY.ID = ?)", findNow.size());
|
||||||
|
|
||||||
jdbcTemplate.query(sql,
|
Set parentsToLookup = (Set) jdbcTemplate.query(sql,
|
||||||
new PreparedStatementSetter() {
|
new PreparedStatementSetter() {
|
||||||
public void setValues(PreparedStatement ps)
|
public void setValues(PreparedStatement ps)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
@ -337,6 +342,11 @@ public final class BasicLookupStrategy implements LookupStrategy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new ProcessResultSet(acls, sids));
|
}, new ProcessResultSet(acls, sids));
|
||||||
|
|
||||||
|
// Lookup the parents, now that our JdbcTemplate has released the database connection (SEC-547)
|
||||||
|
if (parentsToLookup.size() > 0) {
|
||||||
|
lookupPrimaryKeys(acls, parentsToLookup, sids);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -428,6 +438,17 @@ public final class BasicLookupStrategy implements LookupStrategy {
|
|||||||
this.sids = sids; // can be null
|
this.sids = sids; // can be null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of {@link ResultSetExtractor#extractData(ResultSet)}.
|
||||||
|
* Creates an {@link Acl} for each row in the {@link ResultSet} and
|
||||||
|
* ensures it is in member field <tt>acls</tt>. Any {@link Acl} with
|
||||||
|
* a parent will have the parents id returned in a set. The returned
|
||||||
|
* set of ids may requires further processing.
|
||||||
|
* @param rs The {@link ResultSet} to be processed
|
||||||
|
* @return a list of parent IDs remaining to be looked up (may be empty, but never <tt>null</tt>)
|
||||||
|
* @throws SQLException
|
||||||
|
* @throws DataAccessException
|
||||||
|
*/
|
||||||
public Object extractData(ResultSet rs) throws SQLException, DataAccessException {
|
public Object extractData(ResultSet rs) throws SQLException, DataAccessException {
|
||||||
Set parentIdsToLookup = new HashSet(); // Set of parent_id Longs
|
Set parentIdsToLookup = new HashSet(); // Set of parent_id Longs
|
||||||
|
|
||||||
@ -457,13 +478,8 @@ public final class BasicLookupStrategy implements LookupStrategy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup parents, adding Acls (with StubAclParents) to "acl" map
|
// Return the parents left to lookup to the calller
|
||||||
if (parentIdsToLookup.size() > 0) {
|
return parentIdsToLookup;
|
||||||
lookupPrimaryKeys(acls, parentIdsToLookup, sids);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return null to meet ResultSetExtractor method contract
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user