DATACMNS-855 - Prevent memory leak in SyntheticParameterizedType.

Added proper equals(…) and hashCode() methods to SyntheticParameterizedType to make sure instances created for the same type information and type parameters are considered equal.
This commit is contained in:
Oliver Gierke
2016-05-12 16:48:01 +02:00
parent f29cbf5752
commit 9db6278e77
2 changed files with 26 additions and 15 deletions

View File

@@ -15,6 +15,10 @@
*/
package org.springframework.data.util;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -558,23 +562,12 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
* @author Oliver Gierke
* @since 1.11
*/
@EqualsAndHashCode
@RequiredArgsConstructor
private static class SyntheticParamterizedType implements ParameterizedType {
private final ClassTypeInformation<?> typeInformation;
private final List<TypeInformation<?>> typeParameters;
/**
* @param typeInformation must not be {@literal null}.
* @param typeParameters must not be {@literal null}.
*/
public SyntheticParamterizedType(ClassTypeInformation<?> typeInformation, List<TypeInformation<?>> typeParameters) {
Assert.notNull(typeInformation, "Type must not be null!");
Assert.notNull(typeParameters, "Type parameters must not be null!");
this.typeInformation = typeInformation;
this.typeParameters = typeParameters;
}
private final @NonNull ClassTypeInformation<?> typeInformation;
private final @NonNull List<TypeInformation<?>> typeParameters;
/*
* (non-Javadoc)