Use array.clone() instead of manual array creation
This commit is contained in:
parent
f61d728db9
commit
f2b3953d76
|
|
@ -212,8 +212,7 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
|
||||||
Object[] cloneArguments = this.arguments;
|
Object[] cloneArguments = this.arguments;
|
||||||
if (this.arguments.length > 0) {
|
if (this.arguments.length > 0) {
|
||||||
// Build an independent copy of the arguments array.
|
// Build an independent copy of the arguments array.
|
||||||
cloneArguments = new Object[this.arguments.length];
|
cloneArguments = this.arguments.clone();
|
||||||
System.arraycopy(this.arguments, 0, cloneArguments, 0, this.arguments.length);
|
|
||||||
}
|
}
|
||||||
return invocableClone(cloneArguments);
|
return invocableClone(cloneArguments);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -276,9 +276,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] copy(String[] state) {
|
private static String[] copy(String[] state) {
|
||||||
String[] copy = new String[state.length];
|
return state.clone();
|
||||||
System.arraycopy(state, 0, copy, 0, state.length);
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,7 @@ public class SimpleKey implements Serializable {
|
||||||
*/
|
*/
|
||||||
public SimpleKey(Object... elements) {
|
public SimpleKey(Object... elements) {
|
||||||
Assert.notNull(elements, "Elements must not be null");
|
Assert.notNull(elements, "Elements must not be null");
|
||||||
this.params = new Object[elements.length];
|
this.params = elements.clone();
|
||||||
System.arraycopy(elements, 0, this.params, 0, elements.length);
|
|
||||||
this.hashCode = Arrays.deepHashCode(this.params);
|
this.hashCode = Arrays.deepHashCode(this.params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -206,9 +206,7 @@ public class FastByteArrayOutputStream extends OutputStream {
|
||||||
*/
|
*/
|
||||||
public byte[] toByteArray() {
|
public byte[] toByteArray() {
|
||||||
byte[] bytesUnsafe = toByteArrayUnsafe();
|
byte[] bytesUnsafe = toByteArrayUnsafe();
|
||||||
byte[] ret = new byte[bytesUnsafe.length];
|
return bytesUnsafe.clone();
|
||||||
System.arraycopy(bytesUnsafe, 0, ret, 0, bytesUnsafe.length);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue