Skip to content

Commit

Permalink
Fix BigInteger/BigDecimal cloning
Browse files Browse the repository at this point in the history
These objects are immutable so there's no point in cloning them.
  • Loading branch information
mederly committed Sep 6, 2019
1 parent 596a5ea commit 440a1f3
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -19,6 +19,8 @@
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
Expand Down Expand Up @@ -124,6 +126,10 @@ public static <T> T clone(T orig) {
//noinspection unchecked
return (T) XmlTypeConverter.createDuration(((Duration) orig));
}
if (orig instanceof BigInteger || orig instanceof BigDecimal) {
// todo could we use "instanceof Number" here instead?
return (T) orig;
}
if (orig instanceof Cloneable) {
T clone = javaLangClone(orig);
if (clone != null) {
Expand Down

0 comments on commit 440a1f3

Please sign in to comment.