From 51d7f044b51ac79806a39118475d58bcb4c9bbac Mon Sep 17 00:00:00 2001 From: remm Date: Fri, 14 Apr 2006 21:30:28 +0000 Subject: [PATCH] - Port patches. - Change to session: it doesn't make sense to me that getAttribute is a good place to synchronously make a check for session expiration (of course, with accessCount, this is not going to happen anyway, but still). git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@394202 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/catalina/realm/DataSourceRealm.java | 43 +++++++++++----------- .../apache/catalina/session/StandardSession.java | 37 ++++++++++++------- .../apache/catalina/valves/JDBCAccessLogValve.java | 10 ++--- java/org/apache/jasper/compiler/Generator.java | 3 +- 4 files changed, 52 insertions(+), 41 deletions(-) diff --git a/java/org/apache/catalina/realm/DataSourceRealm.java b/java/org/apache/catalina/realm/DataSourceRealm.java index f346126b8..7cfcf17aa 100644 --- a/java/org/apache/catalina/realm/DataSourceRealm.java +++ b/java/org/apache/catalina/realm/DataSourceRealm.java @@ -1,5 +1,5 @@ /* - * Copyright 1999,2004 The Apache Software Foundation. + * Copyright 1999,2004-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ import org.apache.catalina.util.StringManager; * @author Craig R. McClanahan * @author Carson McDonald * @author Ignacio Ortega -* @version $Revision: 373023 $ +* @version $Revision: 394121 $ */ public class DataSourceRealm @@ -57,13 +57,13 @@ public class DataSourceRealm /** * The generated string for the roles PreparedStatement */ - private StringBuffer preparedRoles = null; + private String preparedRoles = null; /** * The generated string for the credentials PreparedStatement */ - private StringBuffer preparedCredentials = null; + private String preparedCredentials = null; /** @@ -581,7 +581,7 @@ public class DataSourceRealm throws SQLException { PreparedStatement credentials = - dbConnection.prepareStatement(preparedCredentials.toString()); + dbConnection.prepareStatement(preparedCredentials); credentials.setString(1, username); return (credentials); @@ -601,7 +601,7 @@ public class DataSourceRealm throws SQLException { PreparedStatement roles = - dbConnection.prepareStatement(preparedRoles.toString()); + dbConnection.prepareStatement(preparedRoles); roles.setString(1, username); return (roles); @@ -624,23 +624,24 @@ public class DataSourceRealm super.start(); // Create the roles PreparedStatement string - preparedRoles = new StringBuffer("SELECT "); - preparedRoles.append(roleNameCol); - preparedRoles.append(" FROM "); - preparedRoles.append(userRoleTable); - preparedRoles.append(" WHERE "); - preparedRoles.append(userNameCol); - preparedRoles.append(" = ?"); + StringBuffer temp = new StringBuffer("SELECT "); + temp.append(roleNameCol); + temp.append(" FROM "); + temp.append(userRoleTable); + temp.append(" WHERE "); + temp.append(userNameCol); + temp.append(" = ?"); + preparedRoles = temp.toString(); // Create the credentials PreparedStatement string - preparedCredentials = new StringBuffer("SELECT "); - preparedCredentials.append(userCredCol); - preparedCredentials.append(" FROM "); - preparedCredentials.append(userTable); - preparedCredentials.append(" WHERE "); - preparedCredentials.append(userNameCol); - preparedCredentials.append(" = ?"); - + temp = new StringBuffer("SELECT "); + temp.append(userCredCol); + temp.append(" FROM "); + temp.append(userTable); + temp.append(" WHERE "); + temp.append(userNameCol); + temp.append(" = ?"); + preparedCredentials = temp.toString(); } diff --git a/java/org/apache/catalina/session/StandardSession.java b/java/org/apache/catalina/session/StandardSession.java index 1a5088e5b..19d7506b3 100644 --- a/java/org/apache/catalina/session/StandardSession.java +++ b/java/org/apache/catalina/session/StandardSession.java @@ -156,7 +156,7 @@ public class StandardSession /** * Set of attribute names which are not allowed to be persisted. */ - private static final String[] excludedAttributes = { + protected static final String[] excludedAttributes = { Globals.SUBJECT_ATTR }; @@ -422,9 +422,9 @@ public class StandardSession */ public long getLastAccessedTime() { - if ( !isValid() ) { + if (!isValidInternal()) { throw new IllegalStateException - (sm.getString("standardSession.getId.ise")); + (sm.getString("standardSession.getId.ise")); } return (this.lastAccessedTime); @@ -564,7 +564,7 @@ public class StandardSession return true; } - if (!this.isValid ) { + if (!this.isValid) { return false; } @@ -948,7 +948,7 @@ public class StandardSession */ public long getCreationTime() { - if (!isValid()) + if (!isValidInternal()) throw new IllegalStateException (sm.getString("standardSession.getCreationTime.ise")); @@ -1003,7 +1003,7 @@ public class StandardSession */ public Object getAttribute(String name) { - if (!isValid()) + if (!isValidInternal()) throw new IllegalStateException (sm.getString("standardSession.getAttribute.ise")); @@ -1021,7 +1021,7 @@ public class StandardSession */ public Enumeration getAttributeNames() { - if (!isValid()) + if (!isValidInternal()) throw new IllegalStateException (sm.getString("standardSession.getAttributeNames.ise")); @@ -1061,7 +1061,7 @@ public class StandardSession */ public String[] getValueNames() { - if (!isValid()) + if (!isValidInternal()) throw new IllegalStateException (sm.getString("standardSession.getValueNames.ise")); @@ -1078,7 +1078,7 @@ public class StandardSession */ public void invalidate() { - if (!isValid()) + if (!isValidInternal()) throw new IllegalStateException (sm.getString("standardSession.invalidate.ise")); @@ -1100,7 +1100,7 @@ public class StandardSession */ public boolean isNew() { - if (!isValid()) + if (!isValidInternal()) throw new IllegalStateException (sm.getString("standardSession.isNew.ise")); @@ -1175,7 +1175,7 @@ public class StandardSession public void removeAttribute(String name, boolean notify) { // Validate our current state - if (!isValid()) + if (!isValidInternal()) throw new IllegalStateException (sm.getString("standardSession.removeAttribute.ise")); @@ -1239,7 +1239,7 @@ public class StandardSession } // Validate our current state - if (!isValid()) + if (!isValidInternal()) throw new IllegalStateException (sm.getString("standardSession.setAttribute.ise")); if ((manager != null) && manager.getDistributable() && @@ -1342,6 +1342,15 @@ public class StandardSession /** + * Return the isValid flag for this session without any expiration + * check. + */ + protected boolean isValidInternal() { + return (this.isValid || this.expiring); + } + + + /** * Read a serialized version of this session object from the specified * object input stream. *

@@ -1353,7 +1362,7 @@ public class StandardSession * @exception ClassNotFoundException if an unknown class is specified * @exception IOException if an input/output error occurs */ - private void readObject(ObjectInputStream stream) + protected void readObject(ObjectInputStream stream) throws ClassNotFoundException, IOException { // Deserialize the scalar instance variables (except Manager) @@ -1418,7 +1427,7 @@ public class StandardSession * * @exception IOException if an input/output error occurs */ - private void writeObject(ObjectOutputStream stream) throws IOException { + protected void writeObject(ObjectOutputStream stream) throws IOException { // Write the scalar instance variables (except Manager) stream.writeObject(new Long(creationTime)); diff --git a/java/org/apache/catalina/valves/JDBCAccessLogValve.java b/java/org/apache/catalina/valves/JDBCAccessLogValve.java index adb978303..228e4cc2c 100644 --- a/java/org/apache/catalina/valves/JDBCAccessLogValve.java +++ b/java/org/apache/catalina/valves/JDBCAccessLogValve.java @@ -44,7 +44,7 @@ import org.apache.catalina.util.StringManager; * To use, copy into the server/classes directory of the Tomcat installation * and configure in server.xml as: *

- * 		<Valve className="AccessLogDBValve"
+ * 		<Valve className="org.apache.catalina.valves.JDBCAccessLogValve"
  *        	driverName="your_jdbc_driver"
  *        	connectionURL="your_jdbc_url"
  *        	pattern="combined" resolveHosts="false"
@@ -76,7 +76,7 @@ import org.apache.catalina.util.StringManager;
  * id INT UNSIGNED AUTO_INCREMENT NOT NULL,
  * ts TIMESTAMP NOT NULL,
  * remoteHost CHAR(15) NOT NULL,
- * user CHAR(15),
+ * userName CHAR(15),
  * timestamp TIMESTAMP NOT NULL,
  * virtualHost VARCHAR(64) NOT NULL,
  * method VARCHAR(8) NOT NULL,
@@ -124,7 +124,7 @@ public final class JDBCAccessLogValve
      * 		connectionURL = null;
      * 		tableName = "access";
      * 		remoteHostField = "remoteHost";
-     * 		userField = "user";
+     * 		userField = "userName";
      * 		timestampField = "timestamp";
      * 		virtualHostField = "virtualHost";
      * 		methodField = "method";
@@ -143,7 +143,7 @@ public final class JDBCAccessLogValve
         connectionURL = null;
         tableName = "access";
         remoteHostField = "remoteHost";
-        userField = "user";
+        userField = "userName";
         timestampField = "timestamp";
         virtualHostField = "virtualHost";
         methodField = "method";
@@ -208,7 +208,7 @@ public final class JDBCAccessLogValve
      * The descriptive information about this implementation.
      */
     protected static String info = 
-        "org.apache.catalina.valves.JDBCAccessLogValve/1.0";
+        "org.apache.catalina.valves.JDBCAccessLogValve/1.1";
 
 
     /**
diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java
index 61687c31d..ddf0af59e 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -2255,7 +2255,7 @@ class Generator {
                     out.printin("if (");
                     out.print(tagEvalVar);
                     out
-                            .println(" != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE)");
+                            .println(" != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {");
                     out.pushIndent();
                     out.printil("out = _jspx_page_context.popBody();");
                     if (n.implementsTryCatchFinally()) {
@@ -2266,6 +2266,7 @@ class Generator {
                         out.println("[0]--;");
                     }
                     out.popIndent();
+                    out.printil("}");
                 }
 
                 out.popIndent(); // EVAL_BODY
-- 
2.11.0