Consistent use of Collection.toArray with zero-sized array argument
Includes consistent use of ClassUtils.toClassArray (as non-null variant) Issue: SPR-16523
This commit is contained in:
@@ -41,6 +41,7 @@ import javax.jms.TopicSession;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -254,10 +255,8 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
|
||||
if (target instanceof TopicSession) {
|
||||
classes.add(TopicSession.class);
|
||||
}
|
||||
return (Session) Proxy.newProxyInstance(
|
||||
SessionProxy.class.getClassLoader(),
|
||||
classes.toArray(new Class<?>[classes.size()]),
|
||||
new CachedSessionInvocationHandler(target, sessionList));
|
||||
return (Session) Proxy.newProxyInstance(SessionProxy.class.getClassLoader(),
|
||||
ClassUtils.toClassArray(classes), new CachedSessionInvocationHandler(target, sessionList));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,7 +48,7 @@ public class ChainedExceptionListener implements ExceptionListener {
|
||||
* Return all registered ExceptionListener delegates (as array).
|
||||
*/
|
||||
public final ExceptionListener[] getDelegates() {
|
||||
return this.delegates.toArray(new ExceptionListener[this.delegates.size()]);
|
||||
return this.delegates.toArray(new ExceptionListener[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,6 +42,7 @@ import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* A JMS ConnectionFactory adapter that returns the same Connection
|
||||
@@ -519,10 +520,8 @@ public class SingleConnectionFactory implements ConnectionFactory, QueueConnecti
|
||||
if (target instanceof TopicConnection) {
|
||||
classes.add(TopicConnection.class);
|
||||
}
|
||||
return (Connection) Proxy.newProxyInstance(
|
||||
Connection.class.getClassLoader(),
|
||||
classes.toArray(new Class<?>[classes.size()]),
|
||||
new SharedConnectionInvocationHandler());
|
||||
return (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(),
|
||||
ClassUtils.toClassArray(classes), new SharedConnectionInvocationHandler());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -37,6 +37,7 @@ import javax.jms.TransactionInProgressException;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Proxy for a target JMS {@link javax.jms.ConnectionFactory}, adding awareness of
|
||||
@@ -229,10 +230,8 @@ public class TransactionAwareConnectionFactoryProxy
|
||||
if (target instanceof TopicConnection) {
|
||||
classes.add(TopicConnection.class);
|
||||
}
|
||||
return (Connection) Proxy.newProxyInstance(
|
||||
Connection.class.getClassLoader(),
|
||||
classes.toArray(new Class<?>[classes.size()]),
|
||||
new TransactionAwareConnectionInvocationHandler(target));
|
||||
return (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(),
|
||||
ClassUtils.toClassArray(classes), new TransactionAwareConnectionInvocationHandler(target));
|
||||
}
|
||||
|
||||
|
||||
@@ -301,10 +300,8 @@ public class TransactionAwareConnectionFactoryProxy
|
||||
if (target instanceof TopicSession) {
|
||||
classes.add(TopicSession.class);
|
||||
}
|
||||
return (Session) Proxy.newProxyInstance(
|
||||
SessionProxy.class.getClassLoader(),
|
||||
classes.toArray(new Class<?>[classes.size()]),
|
||||
new CloseSuppressingSessionInvocationHandler(target));
|
||||
return (Session) Proxy.newProxyInstance(SessionProxy.class.getClassLoader(),
|
||||
ClassUtils.toClassArray(classes), new CloseSuppressingSessionInvocationHandler(target));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user