You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@locus.apache.org on 2000/05/17 00:50:41 UTC
cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session LocalStrings.properties ManagerBase.java StandardManager.java StandardSession.java
craigmcc 00/05/16 15:50:40
Modified: proposals/catalina/src/share/org/apache/tomcat/session
LocalStrings.properties ManagerBase.java
StandardManager.java StandardSession.java
Log:
Grumble ... even classes marked Serializable can throw
NotSerializableException if one of its instance variables cannot be
serialized. Attempt to deal with this problem if it is encountered while
serializing and deserializing sessions.
Revision Changes Path
1.5 +1 -3 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/LocalStrings.properties
Index: LocalStrings.properties
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/LocalStrings.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LocalStrings.properties 2000/04/29 18:24:28 1.4
+++ LocalStrings.properties 2000/05/16 22:50:38 1.5
@@ -16,9 +16,7 @@
standardSession.getCreationTime.ise=getCreationTime: Session already invalidated
standardSession.getMaxInactiveInterval.ise=getMaxInactiveInterval: Session already invalidated
standardSession.getValueNames.ise=getAttributeNames: Session already invalidated
+standardSession.notSerializable=Cannot serialize session attribute {0} for session {1}
standardSession.removeAttribute.ise=removeAttribute: Session already invalidated
standardSession.setAttribute.ise=setAttribute: Non-serializable attribute
standardSession.setAttribute.ise=setAttribute: Session already invalidated
-
-
-
1.5 +4 -5 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/ManagerBase.java
Index: ManagerBase.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/ManagerBase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ManagerBase.java 2000/05/16 20:26:15 1.4
+++ ManagerBase.java 2000/05/16 22:50:38 1.5
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/ManagerBase.java,v 1.4 2000/05/16 20:26:15 craigmcc Exp $
- * $Revision: 1.4 $
- * $Date: 2000/05/16 20:26:15 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/ManagerBase.java,v 1.5 2000/05/16 22:50:38 craigmcc Exp $
+ * $Revision: 1.5 $
+ * $Date: 2000/05/16 22:50:38 $
*
* ====================================================================
*
@@ -73,7 +73,6 @@
import java.util.Vector;
import org.apache.tomcat.Container;
import org.apache.tomcat.Manager;
-import org.apache.tomcat.Request;
import org.apache.tomcat.Session;
@@ -83,7 +82,7 @@
* be subclassed to create more sophisticated Manager implementations.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.4 $ $Date: 2000/05/16 20:26:15 $
+ * @version $Revision: 1.5 $ $Date: 2000/05/16 22:50:38 $
*/
public abstract class ManagerBase implements Manager {
1.15 +57 -56 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java
Index: StandardManager.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- StandardManager.java 2000/05/15 22:32:39 1.14
+++ StandardManager.java 2000/05/16 22:50:38 1.15
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java,v 1.14 2000/05/15 22:32:39 craigmcc Exp $
- * $Revision: 1.14 $
- * $Date: 2000/05/15 22:32:39 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardManager.java,v 1.15 2000/05/16 22:50:38 craigmcc Exp $
+ * $Revision: 1.15 $
+ * $Date: 2000/05/16 22:50:38 $
*
* ====================================================================
*
@@ -90,7 +90,6 @@
import org.apache.tomcat.Loader;
import org.apache.tomcat.Logger;
import org.apache.tomcat.Manager;
-import org.apache.tomcat.Request;
import org.apache.tomcat.Session;
import org.apache.tomcat.util.LifecycleSupport;
import org.apache.tomcat.util.StringManager;
@@ -107,7 +106,7 @@
* <code>stop()</code> methods of this class at the correct times.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.14 $ $Date: 2000/05/15 22:32:39 $
+ * @version $Revision: 1.15 $ $Date: 2000/05/16 22:50:38 $
*/
public final class StandardManager
@@ -474,6 +473,59 @@
}
+ // -------------------------------------------------------- Package Methods
+
+
+ /**
+ * Log a message on the Logger associated with our Container (if any).
+ *
+ * @param message Message to be logged
+ */
+ void log(String message) {
+
+ Logger logger = null;
+ if (container != null)
+ logger = container.getLogger();
+ if (logger != null)
+ logger.log("StandardManager[" + container.getName() + "]: "
+ + message);
+ else {
+ String containerName = null;
+ if (container != null)
+ containerName = container.getName();
+ System.out.println("StandardManager[" + containerName
+ + "]: " + message);
+ }
+
+ }
+
+
+ /**
+ * Log a message on the Logger associated with our Container (if any).
+ *
+ * @param message Message to be logged
+ * @param throwable Associated exception
+ */
+ void log(String message, Throwable throwable) {
+
+ Logger logger = null;
+ if (container != null)
+ logger = container.getLogger();
+ if (logger != null)
+ logger.log("StandardManager[" + container.getName() + "] "
+ + message, throwable);
+ else {
+ String containerName = null;
+ if (container != null)
+ containerName = container.getName();
+ System.out.println("StandardManager[" + containerName
+ + "]: " + message);
+ throwable.printStackTrace(System.out);
+ }
+
+ }
+
+
// -------------------------------------------------------- Private Methods
@@ -578,57 +630,6 @@
ois.close();
} catch (IOException f) {
;
- }
-
- }
-
-
- /**
- * Log a message on the Logger associated with our Container (if any)
- *
- * @param message Message to be logged
- */
- private void log(String message) {
-
- Logger logger = null;
- if (container != null)
- logger = container.getLogger();
- if (logger != null)
- logger.log("StandardManager[" + container.getName() + "]: "
- + message);
- else {
- String containerName = null;
- if (container != null)
- containerName = container.getName();
- System.out.println("StandardManager[" + containerName
- + "]: " + message);
- }
-
- }
-
-
- /**
- * Log a message on the Logger associated with our Container (if any)
- *
- * @param message Message to be logged
- * @param throwable Associated exception
- */
- private void log(String message, Throwable throwable) {
-
- Logger logger = null;
- if (container != null)
- logger = container.getLogger();
- if (logger != null)
- logger.log("StandardManager[" + container.getName() + "] "
- + message, throwable);
- else {
- String containerName = null;
- if (container != null)
- containerName = container.getName();
- System.out.println("StandardManager[" + containerName
- + "]: " + message);
- System.out.println("" + throwable);
- throwable.printStackTrace(System.out);
}
}
1.3 +60 -5 jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java
Index: StandardSession.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StandardSession.java 2000/05/15 22:32:39 1.2
+++ StandardSession.java 2000/05/16 22:50:39 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java,v 1.2 2000/05/15 22:32:39 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2000/05/15 22:32:39 $
+ * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/session/StandardSession.java,v 1.3 2000/05/16 22:50:39 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2000/05/16 22:50:39 $
*
* ====================================================================
*
@@ -66,6 +66,7 @@
import java.io.IOException;
+import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
@@ -94,7 +95,7 @@
* HttpSession view of this instance back to a Session view.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2000/05/15 22:32:39 $
+ * @version $Revision: 1.3 $ $Date: 2000/05/16 22:50:39 $
*/
final class StandardSession
@@ -121,6 +122,14 @@
/**
+ * The dummy attribute value serialized when a NotSerializableException is
+ * encountered in <code>writeObject()</code>.
+ */
+ private static final String NOT_SERIALIZED =
+ "___NOT_SERIALIZABLE_EXCEPTION___";
+
+
+ /**
* The collection of user data attributes associated with this Session.
*/
private Hashtable attributes = new Hashtable();
@@ -758,6 +767,8 @@
for (int i = 0; i < n; i++) {
String name = (String) stream.readObject();
Object value = (Object) stream.readObject();
+ if ((value instanceof String) && (value.equals(NOT_SERIALIZED)))
+ continue;
attributes.put(name, value);
}
@@ -812,13 +823,57 @@
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
stream.writeObject(name);
- stream.writeObject(attributes.get(name));
+ try {
+ stream.writeObject(attributes.get(name));
+ } catch (NotSerializableException e) {
+ log(sm.getString("standardSession.notSerializable",
+ name, id));
+ stream.writeObject(NOT_SERIALIZED);
+ unbinds.addElement(name);
+ }
}
// Unbind the non-Serializable attributes
names = unbinds.elements();
while (names.hasMoreElements())
removeAttribute((String) names.nextElement());
+
+ }
+
+
+ // -------------------------------------------------------- Private Methods
+
+
+ /**
+ * Log a message on the Logger associated with our Manager (if any).
+ *
+ * @param message Message to be logged
+ */
+ private void log(String message) {
+
+ if ((manager != null) && (manager instanceof StandardManager)) {
+ ((StandardManager) manager).log(message);
+ } else {
+ System.out.println("StandardSession: " + message);
+ }
+
+ }
+
+
+ /**
+ * Log a message on the Logger associated with our Manager (if any).
+ *
+ * @param message Message to be logged
+ * @param throwable Associated exception
+ */
+ private void log(String message, Throwable throwable) {
+
+ if ((manager != null) && (manager instanceof StandardManager)) {
+ ((StandardManager) manager).log(message, throwable);
+ } else {
+ System.out.println("StandardSession: " + message);
+ throwable.printStackTrace(System.out);
+ }
}