Skip to content

Commit db2fe48

Browse files
committed
minor change
1 parent 244e62e commit db2fe48

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/main/java/org/xmlobjects/util/copy/CopyBuilder.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,6 @@ private <T> T copy(T src, T dest, Class<T> template, boolean shallowCopy) {
130130
isCloning = true;
131131
}
132132

133-
// avoid copying parents not belonging to the hierarchy of the initial source object
134-
if (src instanceof Child child) {
135-
Child parent = child.getParent();
136-
if (parent != null) {
137-
clones.putIfAbsent(parent, parent);
138-
}
139-
}
140-
141133
T clone = (T) clones.get(src);
142134
try {
143135
if (clone == null) {
@@ -151,6 +143,14 @@ private <T> T copy(T src, T dest, Class<T> template, boolean shallowCopy) {
151143
template = (Class<T>) src.getClass();
152144
}
153145

146+
// avoid copying parents not belonging to the hierarchy of the initial source object
147+
if (src instanceof Child child) {
148+
Child parent = child.getParent();
149+
if (parent != null) {
150+
clones.putIfAbsent(parent, parent);
151+
}
152+
}
153+
154154
AbstractCloner<T> cloner = (AbstractCloner<T>) findCloner(template);
155155
if (cloner != IDENTITY_CLONER && cloner != NULL_CLONER) {
156156
if (dest == null) {

0 commit comments

Comments
 (0)