Skip to content
Snippets Groups Projects
Commit 7d017c8c authored by hg's avatar hg
Browse files

Merge OpenOLAT 9.4 to OpenOLAT 10.0 with 267542b23e14f1e7ae909d3e76b451d1317cd378

parents 3f11f4e2 c0c5c747
No related branches found
No related tags found
No related merge requests found
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.ims.qti.process;
import java.io.IOException;
import java.io.InputStream;
import java.io.InvalidClassException;
import java.io.ObjectInputStream;
import java.io.ObjectStreamClass;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
/**
*
* http://stackoverflow.com/questions/795470/how-to-deserialize-an-object-persisted-in-a-db-now-when-the-object-has-different
*
* @author jorge, java forums
*
*/
public class DecompressibleInputStream extends ObjectInputStream {
private static final OLog log = Tracing.createLoggerFor(DecompressibleInputStream.class);
public DecompressibleInputStream(InputStream in) throws IOException {
super(in);
}
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
ObjectStreamClass resultClassDescriptor = super.readClassDescriptor(); // initially streams descriptor
Class<?> localClass = Class.forName(resultClassDescriptor.getName()); // the class in the local JVM that this descriptor represents.
if (localClass == null) {
log.error("No local class for " + resultClassDescriptor.getName());
return resultClassDescriptor;
}
ObjectStreamClass localClassDescriptor = ObjectStreamClass.lookup(localClass);
if (localClassDescriptor != null) { // only if class implements serializable
final long localSUID = localClassDescriptor.getSerialVersionUID();
final long streamSUID = resultClassDescriptor.getSerialVersionUID();
if (streamSUID != localSUID) { // check for serialVersionUID mismatch.
final StringBuilder s = new StringBuilder("Overriding serialized class version mismatch: ");
s.append("local serialVersionUID = ").append(localSUID).append(" stream serialVersionUID = ").append(streamSUID);
Exception e = new InvalidClassException(s.toString());
log.warn(s.toString(), e);
resultClassDescriptor = localClassDescriptor;
}
}
return resultClassDescriptor;
}
}
......@@ -156,7 +156,7 @@ public class FilePersister implements Persister {
}
is = new FileInputStream(new File(fSerialDir, QTI_FILE));
BufferedInputStream bis = new BufferedInputStream(is, 262144);
ObjectInputStream oistream = new ObjectInputStream(bis);
ObjectInputStream oistream = new DecompressibleInputStream(bis);
o = oistream.readObject();
oistream.close();
is.close();
......@@ -166,6 +166,7 @@ public class FilePersister implements Persister {
}
} catch (Exception e) {
log.error("", e);
try {
if (is != null) is.close();
} catch (IOException e1) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment