Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[JBMAR-142] Fix clone order of classes and replacements

  • Loading branch information...
commit 9439b7983d59a274f78ef4b97d8ab4e5b60b669d 1 parent 9bb775f
@dmlloyd dmlloyd authored
Showing with 13 additions and 13 deletions.
  1. +13 −13 api/src/main/java/org/jboss/marshalling/cloner/SerializingCloner.java
View
26 api/src/main/java/org/jboss/marshalling/cloner/SerializingCloner.java
@@ -154,6 +154,19 @@ private Object clone(final Object orig, final boolean replace) throws IOExceptio
return cached;
}
final Class<? extends Object> objClass = orig.getClass();
+ final SerializableClass info = registry.lookup(objClass);
+ if (replace) {
+ Object replaced = orig;
+ if (info.hasWriteReplace()) {
+ replaced = info.callWriteReplace(replaced);
+ }
+ replaced = objectResolver.writeReplace(replaced);
+ if (replaced != orig) {
+ Object clone = clone(replaced, false);
+ clones.put(orig, clone);
+ return clone;
+ }
+ }
final Class<?> clonedClass = (Class<?>) clone(objClass);
final boolean sameClass = objClass == clonedClass;
if (orig instanceof Enum) {
@@ -206,20 +219,7 @@ private Object clone(final Object orig, final boolean replace) throws IOExceptio
}
return clone;
}
- final SerializableClass info = registry.lookup(objClass);
final SerializableClass cloneInfo = sameClass ? info : registry.lookup(clonedClass);
- if (replace) {
- Object replaced = orig;
- if (info.hasWriteReplace()) {
- replaced = info.callWriteReplace(replaced);
- }
- replaced = objectResolver.writeReplace(replaced);
- if (replaced != orig) {
- Object clone = clone(replaced, false);
- clones.put(orig, clone);
- return clone;
- }
- }
// Now check the serializable types
final Object clone;
if (orig instanceof Externalizable) {
Please sign in to comment.
Something went wrong with that request. Please try again.