From 9bf4d7cf4e6a6aa303616d9e496cdad26a3c1ceb Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 22 Nov 2016 14:57:00 +0100 Subject: [PATCH] Polishing --- .../ExpressionCachingIntegrationTests.java | 19 +++++++++++++++---- .../core/convert/TypeDescriptor.java | 2 +- .../support/GenericConversionService.java | 10 ++++------ .../messaging/simp/user/SimpUserRegistry.java | 14 +++++++------- .../springframework/web/util/UriTemplate.java | 4 ++-- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java b/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java index 2986c8cfc3..493b65178f 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java @@ -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 userDao() { return new UserDaoImpl(); @@ -65,10 +65,13 @@ public class ExpressionCachingIntegrationTests { private interface BaseDao { + T persist(T t); } + private static class UserDaoImpl implements BaseDao { + @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 { + @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() { diff --git a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java index b51c84aace..f582295c03 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java +++ b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java @@ -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) { diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java index e19c89b8b9..39f4cd95b4 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java @@ -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 converterCache = - new ConcurrentReferenceHashMap<>(64); + private final Map converterCache = new ConcurrentReferenceHashMap<>(64); // ConverterRegistry implementation @@ -489,8 +488,7 @@ public class GenericConversionService implements ConfigurableConversionService { private final Set globalConverters = new LinkedHashSet<>(); - private final Map converters = - new LinkedHashMap<>(36); + private final Map converters = new LinkedHashMap<>(36); public void add(GenericConverter converter) { Set convertibleTypes = converter.getConvertibleTypes(); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/SimpUserRegistry.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/SimpUserRegistry.java index b76be434cc..ea5f9ab342 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/SimpUserRegistry.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/SimpUserRegistry.java @@ -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. + *

The returned set is a copy and will not reflect further changes. + * @return the connected users, or an empty set if none */ Set 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 findSubscriptions(SimpSubscriptionMatcher matcher); diff --git a/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java b/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java index a5c0bff5fd..3809eb477a 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriTemplate.java @@ -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 variableNames; private final Pattern matchPattern; - private final String uriTemplate; - /** * Construct a new {@code UriTemplate} with the given URI String.