Polishing
This commit is contained in:
parent
56721669d1
commit
1195b3a0b0
|
|
@ -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.
|
||||
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||
import org.springframework.aop.Advisor;
|
||||
import org.springframework.aop.PointcutAdvisor;
|
||||
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -74,7 +75,7 @@ public abstract class AspectJProxyUtils {
|
|||
((PointcutAdvisor) advisor).getPointcut() instanceof AspectJExpressionPointcut));
|
||||
}
|
||||
|
||||
static boolean isVariableName(String name) {
|
||||
static boolean isVariableName(@Nullable String name) {
|
||||
if (!StringUtils.hasLength(name)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -88,4 +89,5 @@ public abstract class AspectJProxyUtils {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,9 +100,9 @@ public class KotlinSerializationJsonHttpMessageConverter extends AbstractGeneric
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrite(@Nullable Type type, @Nullable Class<?> clazz, @Nullable MediaType mediaType) {
|
||||
public boolean canWrite(@Nullable Type type, Class<?> clazz, @Nullable MediaType mediaType) {
|
||||
try {
|
||||
serializer(GenericTypeResolver.resolveType(type, clazz));
|
||||
serializer(type != null ? GenericTypeResolver.resolveType(type, clazz) : clazz);
|
||||
return canWrite(mediaType);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
|
|
|||
|
|
@ -97,7 +97,8 @@ class KotlinSerializationJsonDecoderTests : AbstractDecoderTests<KotlinSerializa
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Serializable
|
||||
data class Pojo(val foo: String, val bar: String)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,8 @@ class KotlinSerializationJsonEncoderTests : AbstractEncoderTests<KotlinSerializa
|
|||
Assertions.assertThat(encoder.canEncode(sseType, MediaType.APPLICATION_JSON)).isFalse()
|
||||
}
|
||||
|
||||
|
||||
@Serializable
|
||||
data class Pojo(val foo: String, val bar: String)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,10 +69,10 @@ class KotlinSerializationJsonHttpMessageConverterTests {
|
|||
assertThat(converter.canWrite(List::class.java, MediaType.APPLICATION_JSON)).isTrue()
|
||||
assertThat(converter.canWrite(Set::class.java, MediaType.APPLICATION_JSON)).isTrue()
|
||||
|
||||
assertThat(converter.canWrite(typeTokenOf<List<Int>>(), null, MediaType.APPLICATION_JSON)).isTrue()
|
||||
assertThat(converter.canWrite(typeTokenOf<List<SerializableBean>>(), null, MediaType.APPLICATION_JSON)).isTrue()
|
||||
assertThat(converter.canWrite(typeTokenOf<ArrayList<Int>>(), null, MediaType.APPLICATION_JSON)).isTrue()
|
||||
assertThat(converter.canWrite(typeTokenOf<List<Int>>(), null, MediaType.APPLICATION_PDF)).isFalse()
|
||||
assertThat(converter.canWrite(typeTokenOf<List<Int>>(), List::class.java, MediaType.APPLICATION_JSON)).isTrue()
|
||||
assertThat(converter.canWrite(typeTokenOf<List<SerializableBean>>(), List::class.java, MediaType.APPLICATION_JSON)).isTrue()
|
||||
assertThat(converter.canWrite(typeTokenOf<ArrayList<Int>>(), List::class.java, MediaType.APPLICATION_JSON)).isTrue()
|
||||
assertThat(converter.canWrite(typeTokenOf<List<Int>>(), List::class.java, MediaType.APPLICATION_PDF)).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -297,6 +297,7 @@ class KotlinSerializationJsonHttpMessageConverterTests {
|
|||
assertThat(result).isEqualTo("\"H\u00e9llo W\u00f6rld\"")
|
||||
}
|
||||
|
||||
|
||||
@Serializable
|
||||
@Suppress("ArrayInDataClass")
|
||||
data class SerializableBean(
|
||||
|
|
@ -317,4 +318,5 @@ class KotlinSerializationJsonHttpMessageConverterTests {
|
|||
val superType = base::class.java.genericSuperclass!!
|
||||
return (superType as ParameterizedType).actualTypeArguments.first()!!
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package org.springframework.web.socket.server.support;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -31,6 +31,7 @@ import org.springframework.http.server.ServerHttpRequest;
|
|||
import org.springframework.http.server.ServerHttpResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.socket.WebSocketHandler;
|
||||
import org.springframework.web.socket.server.HandshakeInterceptor;
|
||||
|
|
@ -84,9 +85,9 @@ public class OriginHandshakeInterceptor implements HandshakeInterceptor {
|
|||
* @since 4.1.5
|
||||
*/
|
||||
public Collection<String> getAllowedOrigins() {
|
||||
return (this.corsConfiguration.getAllowedOrigins() != null ?
|
||||
Collections.unmodifiableSet(new HashSet<>(this.corsConfiguration.getAllowedOrigins())) :
|
||||
Collections.emptyList());
|
||||
List<String> allowedOrigins = this.corsConfiguration.getAllowedOrigins();
|
||||
return (CollectionUtils.isEmpty(allowedOrigins) ? Collections.emptySet() :
|
||||
Collections.unmodifiableSet(new LinkedHashSet<>(allowedOrigins)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -104,14 +105,13 @@ public class OriginHandshakeInterceptor implements HandshakeInterceptor {
|
|||
|
||||
/**
|
||||
* Return the allowed {@code Origin} pattern header values.
|
||||
*
|
||||
* @since 5.3.2
|
||||
* @see CorsConfiguration#getAllowedOriginPatterns()
|
||||
*/
|
||||
public Collection<String> getAllowedOriginPatterns() {
|
||||
return (this.corsConfiguration.getAllowedOriginPatterns() != null ?
|
||||
Collections.unmodifiableSet(new HashSet<>(this.corsConfiguration.getAllowedOriginPatterns())) :
|
||||
Collections.emptyList());
|
||||
List<String> allowedOriginPatterns = this.corsConfiguration.getAllowedOriginPatterns();
|
||||
return (CollectionUtils.isEmpty(allowedOriginPatterns) ? Collections.emptySet() :
|
||||
Collections.unmodifiableSet(new LinkedHashSet<>(allowedOriginPatterns)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue