Search in sources :

Example 1 with WriteAbortedException

use of java.io.WriteAbortedException in project tomcat by apache.

the class DeltaSession method doReadObject.

private void doReadObject(ObjectInput stream) throws ClassNotFoundException, IOException {
    // Deserialize the scalar instance variables (except Manager)
    // Transient only
    authType = null;
    creationTime = ((Long) stream.readObject()).longValue();
    lastAccessedTime = ((Long) stream.readObject()).longValue();
    maxInactiveInterval = ((Integer) stream.readObject()).intValue();
    isNew = ((Boolean) stream.readObject()).booleanValue();
    isValid = ((Boolean) stream.readObject()).booleanValue();
    thisAccessedTime = ((Long) stream.readObject()).longValue();
    version = ((Long) stream.readObject()).longValue();
    boolean hasPrincipal = stream.readBoolean();
    principal = null;
    if (hasPrincipal) {
        principal = (Principal) stream.readObject();
    }
    // setId((String) stream.readObject());
    id = (String) stream.readObject();
    if (log.isDebugEnabled()) {
        log.debug(sm.getString("deltaSession.readSession", id));
    }
    // Deserialize the attribute count and attribute values
    if (attributes == null) {
        attributes = new ConcurrentHashMap<>();
    }
    int n = ((Integer) stream.readObject()).intValue();
    boolean isValidSave = isValid;
    isValid = true;
    for (int i = 0; i < n; i++) {
        String name = (String) stream.readObject();
        final Object value;
        try {
            value = stream.readObject();
        } catch (WriteAbortedException wae) {
            if (wae.getCause() instanceof NotSerializableException) {
                // Skip non serializable attributes
                continue;
            }
            throw wae;
        }
        // the web application was stopped.
        if (exclude(name, value)) {
            continue;
        }
        // ConcurrentHashMap does not allow null keys or values
        if (null != value) {
            attributes.put(name, value);
        }
    }
    isValid = isValidSave;
    // Session listeners
    n = ((Integer) stream.readObject()).intValue();
    if (listeners == null || n > 0) {
        listeners = new ArrayList<>();
    }
    for (int i = 0; i < n; i++) {
        SessionListener listener = (SessionListener) stream.readObject();
        listeners.add(listener);
    }
    if (notes == null) {
        notes = new Hashtable<>();
    }
    activate();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NotSerializableException(java.io.NotSerializableException) WriteAbortedException(java.io.WriteAbortedException) SessionListener(org.apache.catalina.SessionListener)

Example 2 with WriteAbortedException

use of java.io.WriteAbortedException in project tomcat70 by apache.

the class DeltaSession method readObject.

private void readObject(ObjectInput stream) throws ClassNotFoundException, IOException {
    // Deserialize the scalar instance variables (except Manager)
    // Transient only
    authType = null;
    creationTime = ((Long) stream.readObject()).longValue();
    lastAccessedTime = ((Long) stream.readObject()).longValue();
    maxInactiveInterval = ((Integer) stream.readObject()).intValue();
    isNew = ((Boolean) stream.readObject()).booleanValue();
    isValid = ((Boolean) stream.readObject()).booleanValue();
    thisAccessedTime = ((Long) stream.readObject()).longValue();
    version = ((Long) stream.readObject()).longValue();
    boolean hasPrincipal = stream.readBoolean();
    principal = null;
    if (hasPrincipal) {
        principal = SerializablePrincipal.readPrincipal(stream);
    }
    // setId((String) stream.readObject());
    id = (String) stream.readObject();
    if (log.isDebugEnabled())
        log.debug(sm.getString("deltaSession.readSession", id));
    // Deserialize the attribute count and attribute values
    if (attributes == null)
        attributes = new ConcurrentHashMap<String, Object>();
    int n = ((Integer) stream.readObject()).intValue();
    boolean isValidSave = isValid;
    isValid = true;
    for (int i = 0; i < n; i++) {
        String name = (String) stream.readObject();
        final Object value;
        try {
            value = stream.readObject();
        } catch (WriteAbortedException wae) {
            if (wae.getCause() instanceof NotSerializableException) {
                // Skip non serializable attributes
                continue;
            }
            throw wae;
        }
        // the web application was stopped.
        if (exclude(name, value)) {
            continue;
        }
        attributes.put(name, value);
    }
    isValid = isValidSave;
    // Session listeners
    n = ((Integer) stream.readObject()).intValue();
    if (listeners == null || n > 0) {
        listeners = new ArrayList<SessionListener>();
    }
    for (int i = 0; i < n; i++) {
        SessionListener listener = (SessionListener) stream.readObject();
        listeners.add(listener);
    }
    if (notes == null) {
        notes = new Hashtable<String, Object>();
    }
    activate();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NotSerializableException(java.io.NotSerializableException) WriteAbortedException(java.io.WriteAbortedException) SessionListener(org.apache.catalina.SessionListener) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

NotSerializableException (java.io.NotSerializableException)2 WriteAbortedException (java.io.WriteAbortedException)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 SessionListener (org.apache.catalina.SessionListener)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1