Browse Source

Use Class.getName() as fallback in HandlerFunctionDescription

In JDK 15 the concept of hidden classes was introduced, which also
affects Lambdas in so far that Class.getCanonicalName() will return null
for those. This commit uses Class.getName() as a fallback when no
canonical name is available.

See gh-21713
pull/21936/head
dreis2211 6 years ago committed by Stephane Nicoll
parent
commit
cf3cd0be48
  1. 10
      spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/HandlerFunctionDescription.java

10
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/HandlerFunctionDescription.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,11 +29,17 @@ public class HandlerFunctionDescription {
private final String className; private final String className;
HandlerFunctionDescription(HandlerFunction<?> handlerFunction) { HandlerFunctionDescription(HandlerFunction<?> handlerFunction) {
this.className = handlerFunction.getClass().getCanonicalName(); this.className = getHandlerFunctionClassName(handlerFunction);
} }
public String getClassName() { public String getClassName() {
return this.className; return this.className;
} }
private String getHandlerFunctionClassName(HandlerFunction<?> handlerFunction) {
Class<?> functionClass = handlerFunction.getClass();
String canonicalName = functionClass.getCanonicalName();
return canonicalName != null ? canonicalName : functionClass.getName();
}
} }

Loading…
Cancel
Save