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:
@@ -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.
|
||||
@@ -103,7 +103,7 @@ final class DefaultSslInfo implements SslInfo {
|
||||
result.add((X509Certificate) certificate);
|
||||
}
|
||||
}
|
||||
return !result.isEmpty() ? result.toArray(new X509Certificate[result.size()]) : null;
|
||||
return (!result.isEmpty() ? result.toArray(new X509Certificate[0]) : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public class AnnotationConfigWebApplicationContext extends AbstractRefreshableWe
|
||||
logger.info("Registering annotated classes: [" +
|
||||
StringUtils.collectionToCommaDelimitedString(this.annotatedClasses) + "]");
|
||||
}
|
||||
reader.register(this.annotatedClasses.toArray(new Class<?>[this.annotatedClasses.size()]));
|
||||
reader.register(ClassUtils.toClassArray(this.annotatedClasses));
|
||||
}
|
||||
|
||||
if (!this.basePackages.isEmpty()) {
|
||||
|
||||
@@ -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.
|
||||
@@ -93,7 +93,7 @@ public abstract class MultipartResolutionDelegate {
|
||||
}
|
||||
if (multipartRequest != null) {
|
||||
List<MultipartFile> multipartFiles = multipartRequest.getFiles(name);
|
||||
return multipartFiles.toArray(new MultipartFile[multipartFiles.size()]);
|
||||
return multipartFiles.toArray(new MultipartFile[0]);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
@@ -164,7 +164,7 @@ public abstract class MultipartResolutionDelegate {
|
||||
result.add(part);
|
||||
}
|
||||
}
|
||||
return result.toArray(new Part[result.size()]);
|
||||
return result.toArray(new Part[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.
|
||||
@@ -21,14 +21,13 @@ import java.util.List;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebHandler;
|
||||
|
||||
/**
|
||||
* WebHandler decorator that invokes a chain of {@link WebFilter}s before the
|
||||
* delegate {@link WebHandler}.
|
||||
* {@link WebHandler} decorator that invokes a chain of {@link WebFilter}s
|
||||
* before the delegate {@link WebHandler}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 5.0
|
||||
@@ -44,8 +43,7 @@ public class FilteringWebHandler extends WebHandlerDecorator {
|
||||
*/
|
||||
public FilteringWebHandler(WebHandler webHandler, List<WebFilter> filters) {
|
||||
super(webHandler);
|
||||
this.filters = !CollectionUtils.isEmpty(filters) ?
|
||||
filters.toArray(new WebFilter[filters.size()]) : new WebFilter[0];
|
||||
this.filters = filters.toArray(new WebFilter[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user