Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -144,7 +144,6 @@ public final class ResponseCookie extends HttpCookie {
|
||||
long millis = this.maxAge.getSeconds() > 0 ? System.currentTimeMillis() + this.maxAge.toMillis() : 0;
|
||||
sb.append(HttpHeaders.formatDate(millis));
|
||||
}
|
||||
|
||||
if (this.secure) {
|
||||
sb.append("; Secure");
|
||||
}
|
||||
@@ -160,7 +159,7 @@ public final class ResponseCookie extends HttpCookie {
|
||||
* with a name-value pair and may also include attributes.
|
||||
* @param name the cookie name
|
||||
* @param value the cookie value
|
||||
* @return the created cookie instance
|
||||
* @return a builder to create the cookie with
|
||||
*/
|
||||
public static ResponseCookieBuilder from(final String name, final String value) {
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public abstract class AbstractJackson2Decoder extends Jackson2CodecSupport imple
|
||||
|
||||
@Override
|
||||
public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType) {
|
||||
JavaType javaType = getObjectMapper().getTypeFactory().constructType(elementType.getType());
|
||||
JavaType javaType = getObjectMapper().constructType(elementType.getType());
|
||||
// Skip String: CharSequenceDecoder + "*/*" comes after
|
||||
return (!CharSequence.class.isAssignableFrom(elementType.resolve(Object.class)) &&
|
||||
getObjectMapper().canDeserialize(javaType) && supportsMimeType(mimeType));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -27,7 +27,6 @@ import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.core.MethodParameter;
|
||||
@@ -95,8 +94,7 @@ public abstract class Jackson2CodecSupport {
|
||||
}
|
||||
|
||||
protected JavaType getJavaType(Type type, @Nullable Class<?> contextClass) {
|
||||
TypeFactory typeFactory = this.objectMapper.getTypeFactory();
|
||||
return typeFactory.constructType(GenericTypeResolver.resolveType(type, contextClass));
|
||||
return this.objectMapper.constructType(GenericTypeResolver.resolveType(type, contextClass));
|
||||
}
|
||||
|
||||
protected Map<String, Object> getHints(ResolvableType resolvableType) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-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.
|
||||
@@ -25,11 +25,12 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Strategy interface that specifies a converter that can convert from and to HTTP requests and responses.
|
||||
* Strategy interface for converting from and to HTTP requests and responses.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Juergen Hoeller
|
||||
* @since 3.0
|
||||
* @param <T> the converted object type
|
||||
*/
|
||||
public interface HttpMessageConverter<T> {
|
||||
|
||||
@@ -53,7 +54,7 @@ public interface HttpMessageConverter<T> {
|
||||
|
||||
/**
|
||||
* Return the list of {@link MediaType} objects supported by this converter.
|
||||
* @return the list of supported media types
|
||||
* @return the list of supported media types, potentially an immutable copy
|
||||
*/
|
||||
List<MediaType> getSupportedMediaTypes();
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import com.fasterxml.jackson.databind.SerializationConfig;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.exc.InvalidDefinitionException;
|
||||
import com.fasterxml.jackson.databind.ser.FilterProvider;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
|
||||
import org.springframework.core.GenericTypeResolver;
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
@@ -319,8 +318,7 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
|
||||
* @return the Jackson JavaType
|
||||
*/
|
||||
protected JavaType getJavaType(Type type, @Nullable Class<?> contextClass) {
|
||||
TypeFactory typeFactory = this.objectMapper.getTypeFactory();
|
||||
return typeFactory.constructType(GenericTypeResolver.resolveType(type, contextClass));
|
||||
return this.objectMapper.constructType(GenericTypeResolver.resolveType(type, contextClass));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -233,7 +233,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||
}
|
||||
builder.scheme(scheme);
|
||||
if (opaque) {
|
||||
String ssp = uri.substring(scheme.length()).substring(1);
|
||||
String ssp = uri.substring(scheme.length() + 1);
|
||||
if (StringUtils.hasLength(fragment)) {
|
||||
ssp = ssp.substring(0, ssp.length() - (fragment.length() + 1));
|
||||
}
|
||||
@@ -394,9 +394,8 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||
* characters that should have been encoded.
|
||||
*/
|
||||
public UriComponents build(boolean encoded) {
|
||||
return buildInternal(encoded ?
|
||||
EncodingHint.FULLY_ENCODED :
|
||||
this.encodeTemplate ? EncodingHint.ENCODE_TEMPLATE : EncodingHint.NONE);
|
||||
return buildInternal(encoded ? EncodingHint.FULLY_ENCODED :
|
||||
(this.encodeTemplate ? EncodingHint.ENCODE_TEMPLATE : EncodingHint.NONE));
|
||||
}
|
||||
|
||||
private UriComponents buildInternal(EncodingHint hint) {
|
||||
@@ -408,8 +407,7 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||
HierarchicalUriComponents uric = new HierarchicalUriComponents(this.scheme, this.fragment,
|
||||
this.userInfo, this.host, this.port, this.pathBuilder.build(), this.queryParams,
|
||||
hint == EncodingHint.FULLY_ENCODED);
|
||||
|
||||
result = hint == EncodingHint.ENCODE_TEMPLATE ? uric.encodeTemplate(this.charset) : uric;
|
||||
result = (hint == EncodingHint.ENCODE_TEMPLATE ? uric.encodeTemplate(this.charset) : uric);
|
||||
}
|
||||
if (!this.uriVariables.isEmpty()) {
|
||||
result = result.expand(name -> this.uriVariables.getOrDefault(name, UriTemplateVariables.SKIP_VALUE));
|
||||
@@ -466,9 +464,8 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||
* @see UriComponents#toUriString()
|
||||
*/
|
||||
public String toUriString() {
|
||||
return this.uriVariables.isEmpty() ?
|
||||
build().encode().toUriString() :
|
||||
buildInternal(EncodingHint.ENCODE_TEMPLATE).toUriString();
|
||||
return (this.uriVariables.isEmpty() ? build().encode().toUriString() :
|
||||
buildInternal(EncodingHint.ENCODE_TEMPLATE).toUriString());
|
||||
}
|
||||
|
||||
|
||||
@@ -841,12 +838,10 @@ public class UriComponentsBuilder implements UriBuilder, Cloneable {
|
||||
scheme(StringUtils.tokenizeToStringArray(protocolHeader, ",")[0]);
|
||||
port(null);
|
||||
}
|
||||
|
||||
String hostHeader = headers.getFirst("X-Forwarded-Host");
|
||||
if (StringUtils.hasText(hostHeader)) {
|
||||
adaptForwardedHost(StringUtils.tokenizeToStringArray(hostHeader, ",")[0]);
|
||||
}
|
||||
|
||||
String portHeader = headers.getFirst("X-Forwarded-Port");
|
||||
if (StringUtils.hasText(portHeader)) {
|
||||
port(Integer.parseInt(StringUtils.tokenizeToStringArray(portHeader, ",")[0]));
|
||||
|
||||
Reference in New Issue
Block a user