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

View File

@ -438,7 +438,7 @@ public class TypeDescriptor implements Serializable {
return false; return false;
} }
TypeDescriptor other = (TypeDescriptor) obj; TypeDescriptor other = (TypeDescriptor) obj;
if (!ObjectUtils.nullSafeEquals(this.type, other.type)) { if (!ObjectUtils.nullSafeEquals(getType(), other.getType())) {
return false; return false;
} }
if (getAnnotations().length != other.getAnnotations().length) { 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"); 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 * Used as a cache entry when no converter is available.
* returned. * This converter is never returned.
*/ */
private static final GenericConverter NO_MATCH = new NoOpConverter("NO_MATCH"); private static final GenericConverter NO_MATCH = new NoOpConverter("NO_MATCH");
private final Converters converters = new Converters(); private final Converters converters = new Converters();
private final Map<ConverterCacheKey, GenericConverter> converterCache = private final Map<ConverterCacheKey, GenericConverter> converterCache = new ConcurrentReferenceHashMap<>(64);
new ConcurrentReferenceHashMap<>(64);
// ConverterRegistry implementation // ConverterRegistry implementation
@ -489,8 +488,7 @@ public class GenericConversionService implements ConfigurableConversionService {
private final Set<GenericConverter> globalConverters = new LinkedHashSet<>(); private final Set<GenericConverter> globalConverters = new LinkedHashSet<>();
private final Map<ConvertiblePair, ConvertersForPair> converters = private final Map<ConvertiblePair, ConvertersForPair> converters = new LinkedHashMap<>(36);
new LinkedHashMap<>(36);
public void add(GenericConverter converter) { public void add(GenericConverter converter) {
Set<ConvertiblePair> convertibleTypes = converter.getConvertibleTypes(); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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. * Get the user for the given name.
* @param userName the name of the user to look up * @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); SimpUser getUser(String userName);
/** /**
* Return a snapshot of all connected users. The returned set is a copy and * Return a snapshot of all connected users.
* will never be modified. * <p>The returned set is a copy and will not reflect further changes.
* @return the connected users or an empty set. * @return the connected users, or an empty set if none
*/ */
Set<SimpUser> getUsers(); Set<SimpUser> getUsers();
/** /**
* Return the count of all connected users. * Return the count of all connected users.
* @return the connected user count. * @return the number of connected users
* @since 4.3.5 * @since 4.3.5
*/ */
int getUserCount(); int getUserCount();
@ -50,7 +50,7 @@ public interface SimpUserRegistry {
/** /**
* Find subscriptions with the given matcher. * Find subscriptions with the given matcher.
* @param matcher the matcher to use * @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); Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher);

View File

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