Browse Source

Polishing

pull/25598/head
Juergen Hoeller 7 years ago
parent
commit
c28cadbafc
  1. 9
      spring-core/src/main/java/org/springframework/util/PatternMatchUtils.java
  2. 17
      spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java
  3. 13
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java

9
spring-core/src/main/java/org/springframework/util/PatternMatchUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@ -39,20 +39,22 @@ public abstract class PatternMatchUtils { @@ -39,20 +39,22 @@ public abstract class PatternMatchUtils {
if (pattern == null || str == null) {
return false;
}
int firstIndex = pattern.indexOf('*');
if (firstIndex == -1) {
return pattern.equals(str);
}
if (firstIndex == 0) {
if (pattern.length() == 1) {
return true;
}
int nextIndex = pattern.indexOf('*', firstIndex + 1);
int nextIndex = pattern.indexOf('*', 1);
if (nextIndex == -1) {
return str.endsWith(pattern.substring(1));
}
String part = pattern.substring(1, nextIndex);
if ("".equals(part)) {
if (part.isEmpty()) {
return simpleMatch(pattern.substring(nextIndex), str);
}
int partIndex = str.indexOf(part);
@ -64,6 +66,7 @@ public abstract class PatternMatchUtils { @@ -64,6 +66,7 @@ public abstract class PatternMatchUtils {
}
return false;
}
return (str.length() >= firstIndex &&
pattern.substring(0, firstIndex).equals(str.substring(0, firstIndex)) &&
simpleMatch(pattern.substring(firstIndex), str.substring(firstIndex)));

17
spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java

@ -299,7 +299,7 @@ public class Jackson2ObjectMapperBuilder { @@ -299,7 +299,7 @@ public class Jackson2ObjectMapperBuilder {
* @param mixinSource class (or interface) whose annotations are to be "added"
* to target's annotations as value
* @since 4.1.2
* @see com.fasterxml.jackson.databind.ObjectMapper#addMixInAnnotations(Class, Class)
* @see com.fasterxml.jackson.databind.ObjectMapper#addMixIn(Class, Class)
*/
public Jackson2ObjectMapperBuilder mixIn(Class<?> target, Class<?> mixinSource) {
this.mixIns.put(target, mixinSource);
@ -308,11 +308,11 @@ public class Jackson2ObjectMapperBuilder { @@ -308,11 +308,11 @@ public class Jackson2ObjectMapperBuilder {
/**
* Add mix-in annotations to use for augmenting specified class or interface.
* @param mixIns Map of entries with target classes (or interface) whose annotations
* @param mixIns a Map of entries with target classes (or interface) whose annotations
* to effectively override as key and mix-in classes (or interface) whose
* annotations are to be "added" to target's annotations as value.
* @since 4.1.2
* @see com.fasterxml.jackson.databind.ObjectMapper#addMixInAnnotations(Class, Class)
* @see com.fasterxml.jackson.databind.ObjectMapper#addMixIn(Class, Class)
*/
public Jackson2ObjectMapperBuilder mixIns(Map<Class<?>, Class<?>> mixIns) {
this.mixIns.putAll(mixIns);
@ -337,8 +337,8 @@ public class Jackson2ObjectMapperBuilder { @@ -337,8 +337,8 @@ public class Jackson2ObjectMapperBuilder {
/**
* Configure a custom serializer for the given type.
* @see #serializers(JsonSerializer...)
* @since 4.1.2
* @see #serializers(JsonSerializer...)
*/
public Jackson2ObjectMapperBuilder serializerByType(Class<?> type, JsonSerializer<?> serializer) {
this.serializers.put(type, serializer);
@ -482,6 +482,8 @@ public class Jackson2ObjectMapperBuilder { @@ -482,6 +482,8 @@ public class Jackson2ObjectMapperBuilder {
/**
* Specify one or more modules to be registered with the {@link ObjectMapper}.
* Multiple invocations are not additive, the last one defines the modules to
* register.
* <p>Note: If this is set, no finding of modules is going to happen - not by
* Jackson, and not by Spring either (see {@link #findModulesViaServiceLoader}).
* As a consequence, specifying an empty list here will suppress any kind of
@ -497,6 +499,8 @@ public class Jackson2ObjectMapperBuilder { @@ -497,6 +499,8 @@ public class Jackson2ObjectMapperBuilder {
/**
* Set a complete list of modules to be registered with the {@link ObjectMapper}.
* Multiple invocations are not additive, the last one defines the modules to
* register.
* <p>Note: If this is set, no finding of modules is going to happen - not by
* Jackson, and not by Spring either (see {@link #findModulesViaServiceLoader}).
* As a consequence, specifying an empty list here will suppress any kind of
@ -514,6 +518,8 @@ public class Jackson2ObjectMapperBuilder { @@ -514,6 +518,8 @@ public class Jackson2ObjectMapperBuilder {
/**
* Specify one or more modules to be registered with the {@link ObjectMapper}.
* Multiple invocations are not additive, the last one defines the modules
* to register.
* <p>Modules specified here will be registered after
* Spring's autodetection of JSR-310 and Joda-Time, or Jackson's
* finding of modules (see {@link #findModulesViaServiceLoader}),
@ -530,7 +536,8 @@ public class Jackson2ObjectMapperBuilder { @@ -530,7 +536,8 @@ public class Jackson2ObjectMapperBuilder {
/**
* Specify one or more modules by class to be registered with
* the {@link ObjectMapper}.
* the {@link ObjectMapper}. Multiple invocations are not additive,
* the last one defines the modules to register.
* <p>Modules specified here will be registered after
* Spring's autodetection of JSR-310 and Joda-Time, or Jackson's
* finding of modules (see {@link #findModulesViaServiceLoader}),

13
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java

@ -1,5 +1,5 @@ @@ -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.
@ -111,12 +111,9 @@ public class InvocableHandlerMethod extends HandlerMethod { @@ -111,12 +111,9 @@ public class InvocableHandlerMethod extends HandlerMethod {
}
/**
* Configure a reactive registry. This is needed for cases where the response
* is fully handled within the controller in combination with an async void
* return value.
* <p>By default this is an instance of {@link ReactiveAdapterRegistry} with
* default settings.
* @param registry the registry to use
* Configure a reactive adapter registry. This is needed for cases where the response is
* fully handled within the controller in combination with an async void return value.
* <p>By default this is a {@link ReactiveAdapterRegistry} with default settings.
*/
public void setReactiveAdapterRegistry(ReactiveAdapterRegistry registry) {
this.reactiveAdapterRegistry = registry;
@ -128,7 +125,7 @@ public class InvocableHandlerMethod extends HandlerMethod { @@ -128,7 +125,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
* @param exchange the current exchange
* @param bindingContext the binding context to use
* @param providedArgs optional list of argument values to match by type
* @return a Mono with a {@link HandlerResult}.
* @return a Mono with a {@link HandlerResult}
*/
public Mono<HandlerResult> invoke(
ServerWebExchange exchange, BindingContext bindingContext, Object... providedArgs) {

Loading…
Cancel
Save