in src/main/java/org/apache/sling/event/dea/impl/ResourceHelper.java [40:86]
public static Map<String, Object> cloneValueMap(final ValueMap vm) throws InstantiationException {
List<Exception> hasReadError = null;
try {
final Map<String, Object> result = new HashMap<String, Object>(vm);
for(final Map.Entry<String, Object> entry : result.entrySet()) {
if ( entry.getValue() instanceof InputStream ) {
final Object value = vm.get(entry.getKey(), Serializable.class);
if ( value != null ) {
entry.setValue(value);
} else {
if ( hasReadError == null ) {
hasReadError = new ArrayList<Exception>();
}
final int count = hasReadError.size();
// let's find out which class might be missing
ObjectInputStream ois = null;
try {
ois = new ObjectInputStream((InputStream)entry.getValue());
ois.readObject();
} catch (final ClassNotFoundException cnfe) {
hasReadError.add(new Exception("Unable to deserialize property '" + entry.getKey() + "'", cnfe));
} catch (final IOException ioe) {
hasReadError.add(new Exception("Unable to deserialize property '" + entry.getKey() + "'", ioe));
} finally {
if ( ois != null ) {
try {
ois.close();
} catch (IOException ignore) {
// ignore
}
}
}
if ( hasReadError.size() == count ) {
hasReadError.add(new Exception("Unable to deserialize property '" + entry.getKey() + "'"));
}
}
}
}
if ( hasReadError != null ) {
result.put(PROPERTY_MARKER_READ_ERROR_LIST, hasReadError);
}
return result;
} catch ( final IllegalArgumentException iae) {
// the JCR implementation might throw an IAE if something goes wrong
throw (InstantiationException)new InstantiationException(iae.getMessage()).initCause(iae);
}
}