Polishing

This commit is contained in:
Juergen Hoeller 2016-11-22 14:57:00 +01:00
parent 85b0ce1ef7
commit 9bf4d7cf4e
5 changed files with 29 additions and 20 deletions

View File

@ -33,8 +33,8 @@ import org.springframework.context.annotation.Configuration;
*/
public class ExpressionCachingIntegrationTests {
@Test // SPR-11692
@SuppressWarnings("unchecked")
@Test // SPR-11692
public void expressionIsCacheBasedOnActualMethod() {
ConfigurableApplicationContext context =
new AnnotationConfigApplicationContext(SharedConfig.class, Spr11692Config.class);
@ -49,9 +49,9 @@ public class ExpressionCachingIntegrationTests {
}
@Configuration
static class Spr11692Config {
@Bean
public BaseDao<User> userDao() {
return new UserDaoImpl();
@ -65,10 +65,13 @@ public class ExpressionCachingIntegrationTests {
private interface BaseDao<T> {
T persist(T t);
}
private static class UserDaoImpl implements BaseDao<User> {
@Override
@CachePut(value = "users", key = "#user.id")
public User persist(User user) {
@ -76,7 +79,9 @@ public class ExpressionCachingIntegrationTests {
}
}
private static class OrderDaoImpl implements BaseDao<Order> {
@Override
@CachePut(value = "orders", key = "#order.id")
public Order persist(Order order) {
@ -84,10 +89,12 @@ public class ExpressionCachingIntegrationTests {
}
}
private static class User {
private final String id;
private User(String id) {
public User(String id) {
this.id = id;
}
@ -97,10 +104,12 @@ public class ExpressionCachingIntegrationTests {
}
}
private static class Order {
private final String id;
private Order(String id) {
public Order(String id) {
this.id = id;
}
@ -110,9 +119,11 @@ public class ExpressionCachingIntegrationTests {
}
}
@Configuration
@EnableCaching
static class SharedConfig extends CachingConfigurerSupport {
@Override
@Bean
public CacheManager cacheManager() {

View File

@ -438,7 +438,7 @@ public class TypeDescriptor implements Serializable {
return false;
}
TypeDescriptor other = (TypeDescriptor) obj;
if (!ObjectUtils.nullSafeEquals(this.type, other.type)) {
if (!ObjectUtils.nullSafeEquals(getType(), other.getType())) {
return false;
}
if (getAnnotations().length != other.getAnnotations().length) {

View File

@ -68,16 +68,15 @@ public class GenericConversionService implements ConfigurableConversionService {
private static final GenericConverter NO_OP_CONVERTER = new NoOpConverter("NO_OP");
/**
* Used as a cache entry when no converter is available. This converter is never
* returned.
* Used as a cache entry when no converter is available.
* This converter is never returned.
*/
private static final GenericConverter NO_MATCH = new NoOpConverter("NO_MATCH");
private final Converters converters = new Converters();
private final Map<ConverterCacheKey, GenericConverter> converterCache =
new ConcurrentReferenceHashMap<>(64);
private final Map<ConverterCacheKey, GenericConverter> converterCache = new ConcurrentReferenceHashMap<>(64);
// ConverterRegistry implementation
@ -489,8 +488,7 @@ public class GenericConversionService implements ConfigurableConversionService {
private final Set<GenericConverter> globalConverters = new LinkedHashSet<>();
private final Map<ConvertiblePair, ConvertersForPair> converters =
new LinkedHashMap<>(36);
private final Map<ConvertiblePair, ConvertersForPair> converters = new LinkedHashMap<>(36);
public void add(GenericConverter converter) {
Set<ConvertiblePair> convertibleTypes = converter.getConvertibleTypes();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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,20 +29,20 @@ public interface SimpUserRegistry {
/**
* Get the user for the given name.
* @param userName the name of the user to look up
* @return the user or {@code null} if not connected
* @return the user, or {@code null} if not connected
*/
SimpUser getUser(String userName);
/**
* Return a snapshot of all connected users. The returned set is a copy and
* will never be modified.
* @return the connected users or an empty set.
* Return a snapshot of all connected users.
* <p>The returned set is a copy and will not reflect further changes.
* @return the connected users, or an empty set if none
*/
Set<SimpUser> getUsers();
/**
* Return the count of all connected users.
* @return the connected user count.
* @return the number of connected users
* @since 4.3.5
*/
int getUserCount();
@ -50,7 +50,7 @@ public interface SimpUserRegistry {
/**
* Find subscriptions with the given matcher.
* @param matcher the matcher to use
* @return a set of matching subscriptions or an empty set.
* @return a set of matching subscriptions, or an empty set if none
*/
Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher);

View File

@ -44,14 +44,14 @@ import org.springframework.util.Assert;
@SuppressWarnings("serial")
public class UriTemplate implements Serializable {
private final String uriTemplate;
private final UriComponents uriComponents;
private final List<String> variableNames;
private final Pattern matchPattern;
private final String uriTemplate;
/**
* Construct a new {@code UriTemplate} with the given URI String.