From cf3cd0be486e6594cd2c330934ea671c33d4fc7c Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Fri, 5 Jun 2020 17:20:16 +0200 Subject: [PATCH] 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 --- .../mappings/reactive/HandlerFunctionDescription.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/HandlerFunctionDescription.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/HandlerFunctionDescription.java index 044e27da9c3..f4ecb17d084 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/reactive/HandlerFunctionDescription.java +++ b/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"); * you may not use this file except in compliance with the License. @@ -29,11 +29,17 @@ public class HandlerFunctionDescription { private final String className; HandlerFunctionDescription(HandlerFunction handlerFunction) { - this.className = handlerFunction.getClass().getCanonicalName(); + this.className = getHandlerFunctionClassName(handlerFunction); } public String getClassName() { return this.className; } + private String getHandlerFunctionClassName(HandlerFunction handlerFunction) { + Class functionClass = handlerFunction.getClass(); + String canonicalName = functionClass.getCanonicalName(); + return canonicalName != null ? canonicalName : functionClass.getName(); + } + }