384896 JDBCSessionManager fails to load existing sessions on oracle when contextPath is /

This commit is contained in:
Jan Bartel 2012-07-16 14:10:53 +10:00
parent 9315ed8b73
commit b62473b58f
2 changed files with 37 additions and 9 deletions

View File

@ -85,7 +85,6 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
protected String _insertSession;
protected String _deleteSession;
protected String _selectSession;
protected String _updateSession;
protected String _updateSessionNode;
protected String _updateSessionAccessTime;
@ -110,6 +109,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
String _dbName;
boolean _isLower;
boolean _isUpper;
public DatabaseAdaptor (DatabaseMetaData dbMeta)
@ -189,6 +189,39 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
return "rowId";
}
public boolean isEmptyStringNull ()
{
return (_dbName.startsWith("oracle"));
}
public PreparedStatement getLoadStatement (Connection connection, String rowId, String contextPath, String virtualHosts)
throws SQLException
{
if (contextPath == null || "".equals(contextPath))
{
if (isEmptyStringNull())
{
PreparedStatement statement = connection.prepareStatement("select * from "+_sessionTable+
" where sessionId = ? and contextPath is null and virtualHost = ?");
statement.setString(1, rowId);
statement.setString(2, virtualHosts);
return statement;
}
}
PreparedStatement statement = connection.prepareStatement("select * from "+_sessionTable+
" where sessionId = ? and contextPath = ? and virtualHost = ?");
statement.setString(1, rowId);
statement.setString(2, contextPath);
statement.setString(3, virtualHosts);
return statement;
}
}
@ -628,10 +661,7 @@ public class JDBCSessionIdManager extends AbstractSessionIdManager
_deleteSession = "delete from "+_sessionTable+
" where "+_sessionTableRowId+" = ?";
_selectSession = "select * from "+_sessionTable+
" where sessionId = ? and contextPath = ? and virtualHost = ?";
_updateSession = "update "+_sessionTable+
" set lastNode = ?, accessTime = ?, lastAccessTime = ?, lastSavedTime = ?, expiryTime = ?, map = ? where "+_sessionTableRowId+" = ?";

View File

@ -24,6 +24,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
@ -831,10 +832,7 @@ public class JDBCSessionManager extends AbstractSessionManager
try
{
connection = getConnection();
statement = connection.prepareStatement(_jdbcSessionIdMgr._selectSession);
statement.setString(1, id);
statement.setString(2, canonicalContextPath);
statement.setString(3, vhost);
statement = _jdbcSessionIdMgr._dbAdaptor.getLoadStatement(connection, id, canonicalContextPath, vhost);
ResultSet result = statement.executeQuery();
if (result.next())
{