Browse Source

DATACMNS-815 - Made static type cache non-static in SimpleTypeInformationMapper.

We now use a non-static cache for TypeInformation instances in SimpleTypeInformationMapper to make sure Spring Boot's development tools can correctly reload classes. Removed the static singleton instance of SimpleTypeInformationMapper in favor instantiating it directly.
pull/155/head
Oliver Gierke 10 years ago
parent
commit
e0d2907905
  1. 4
      src/main/java/org/springframework/data/convert/DefaultTypeMapper.java
  2. 5
      src/main/java/org/springframework/data/convert/SimpleTypeInformationMapper.java

4
src/main/java/org/springframework/data/convert/DefaultTypeMapper.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2011-2013 the original author or authors.
* Copyright 2011-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.
@ -50,7 +50,7 @@ public class DefaultTypeMapper<S> implements TypeMapper<S> { @@ -50,7 +50,7 @@ public class DefaultTypeMapper<S> implements TypeMapper<S> {
* @param accessor must not be {@literal null}.
*/
public DefaultTypeMapper(TypeAliasAccessor<S> accessor) {
this(accessor, Arrays.asList(SimpleTypeInformationMapper.INSTANCE));
this(accessor, Arrays.asList(new SimpleTypeInformationMapper()));
}
/**

5
src/main/java/org/springframework/data/convert/SimpleTypeInformationMapper.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-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.
@ -32,8 +32,7 @@ import org.springframework.util.StringUtils; @@ -32,8 +32,7 @@ import org.springframework.util.StringUtils;
*/
public class SimpleTypeInformationMapper implements TypeInformationMapper {
public static final SimpleTypeInformationMapper INSTANCE = new SimpleTypeInformationMapper();
private static final Map<String, ClassTypeInformation<?>> CACHE = new ConcurrentHashMap<String, ClassTypeInformation<?>>();
private final Map<String, ClassTypeInformation<?>> CACHE = new ConcurrentHashMap<String, ClassTypeInformation<?>>();
/**
* Returns the {@link TypeInformation} that shall be used when the given {@link String} value is found as type hint.

Loading…
Cancel
Save