if (stateManager.isSavingStateInClient(context)) {
ObjectOutputStream oos = null;
try {
Base64OutputStreamWriter bos =
new Base64OutputStreamWriter(csBuffSize,
writer);
OutputStream base;
if (compressState) {
base = new GZIPOutputStream(bos, 1024);
} else {
base = bos;
}
if (guard != null) {
oos = serialProvider.createObjectOutputStream(
new BufferedOutputStream(
new CipherOutputStream(base, guard.getEncryptionCipher())));
} else {
oos = serialProvider
.createObjectOutputStream(new BufferedOutputStream(
base,
1024));
}
if (webConfig.isSet(WebContextInitParameter.ClientStateTimeout)) {
oos.writeLong(System.currentTimeMillis());
}
//noinspection NonSerializableObjectPassedToObjectStream
oos.writeObject(view.getStructure());
//noinspection NonSerializableObjectPassedToObjectStream
oos.writeObject(view.getState());
oos.flush();
oos.close();
// flush everything to the underlying writer
bos.finish();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Client State: total number of characters"
+ " written: " + bos.getTotalCharsWritten());
}
} finally {
if (oos != null) {
try {
oos.close();