diff --git a/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java index 8f1a6179282e..def8ff942e01 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/DecoderHttpMessageReader.java @@ -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. @@ -61,15 +61,14 @@ public class DecoderHttpMessageReader implements HttpMessageReader { */ public DecoderHttpMessageReader(Decoder decoder) { Assert.notNull(decoder, "Decoder is required"); + initLogger(decoder); this.decoder = decoder; this.mediaTypes = MediaType.asMediaTypes(decoder.getDecodableMimeTypes()); - initLogger(decoder); } - private void initLogger(Decoder decoder) { + private static void initLogger(Decoder decoder) { if (decoder instanceof AbstractDecoder && - decoder.getClass().getPackage().getName().startsWith("org.springframework.core.codec")) { - + decoder.getClass().getName().startsWith("org.springframework.core.codec")) { Log logger = HttpLogging.forLog(((AbstractDecoder) decoder).getLogger()); ((AbstractDecoder) decoder).setLogger(logger); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java index c174b5842c63..8f1dfd1b858d 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/EncoderHttpMessageWriter.java @@ -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. @@ -67,16 +67,15 @@ public class EncoderHttpMessageWriter implements HttpMessageWriter { */ public EncoderHttpMessageWriter(Encoder encoder) { Assert.notNull(encoder, "Encoder is required"); + initLogger(encoder); this.encoder = encoder; this.mediaTypes = MediaType.asMediaTypes(encoder.getEncodableMimeTypes()); this.defaultMediaType = initDefaultMediaType(this.mediaTypes); - initLogger(encoder); } - private void initLogger(Encoder encoder) { + private static void initLogger(Encoder encoder) { if (encoder instanceof AbstractEncoder && - encoder.getClass().getPackage().getName().startsWith("org.springframework.core.codec")) { - + encoder.getClass().getName().startsWith("org.springframework.core.codec")) { Log logger = HttpLogging.forLog(((AbstractEncoder) encoder).getLogger()); ((AbstractEncoder) encoder).setLogger(logger); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java index 4ee674b58cfd..ad9e9719ae6b 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/AbstractHandlerMethodMapping.java @@ -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. @@ -215,15 +215,12 @@ protected void detectHandlerMethods(final Object handler) { } private String formatMappings(Class userType, Map 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 methodFormatter = method -> Arrays.stream(method.getParameterTypes()) .map(Class::getSimpleName) .collect(Collectors.joining(",", "(", ")")); - return methods.entrySet().stream() .map(e -> { Method method = e.getKey(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java index 75b43146b0ab..38dbfd485353 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.java @@ -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 @@ protected void detectHandlerMethods(Object handler) { } private String formatMappings(Class userType, Map 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 methodFormatter = method -> Arrays.stream(method.getParameterTypes()) .map(Class::getSimpleName) .collect(Collectors.joining(",", "(", ")")); - return methods.entrySet().stream() .map(e -> { Method method = e.getKey();