Avoid Class.getPackage() in favor of plain Class.getName() checks

Fixes #22306
This commit is contained in:
Juergen Hoeller
2019-01-25 15:35:49 +01:00
parent 4732f83d70
commit 85ec9b9df2
4 changed files with 12 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -285,15 +285,12 @@ public abstract class AbstractHandlerMethodMapping<T> extends AbstractHandlerMap
}
private String formatMappings(Class<?> userType, Map<Method, T> methods) {
String formattedType = Arrays.stream(userType.getPackage().getName().split("\\."))
String formattedType = Arrays.stream(ClassUtils.getPackageName(userType).split("\\."))
.map(p -> p.substring(0, 1))
.collect(Collectors.joining(".", "", ".")) + userType.getSimpleName();
Function<Method, String> methodFormatter = method -> Arrays.stream(method.getParameterTypes())
.map(Class::getSimpleName)
.collect(Collectors.joining(",", "(", ")"));
return methods.entrySet().stream()
.map(e -> {
Method method = e.getKey();