DATACMNS-733 - Made all references to DefaultParameterNameDiscoverer non-static.

To prevent classes from being garbage collected due to Class<?> references within DefaultParameterNameDiscoverer we no keep all ParameterNameDiscoverer instances in a non-static field.
This commit is contained in:
Oliver Gierke
2015-07-20 08:28:26 +02:00
parent c5e5244162
commit ac080bacf7
3 changed files with 9 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 by the original author(s).
* Copyright 2011-2015 by the original author(s).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ import org.springframework.data.util.TypeInformation;
*/
public class PreferredConstructorDiscoverer<T, P extends PersistentProperty<P>> {
private static final ParameterNameDiscoverer PARAMETER_DISCOVERER = new DefaultParameterNameDiscoverer();
private final ParameterNameDiscoverer discoverer = new DefaultParameterNameDiscoverer();
private PreferredConstructor<T, P> constructor;
@@ -106,7 +106,7 @@ public class PreferredConstructorDiscoverer<T, P extends PersistentProperty<P>>
return new PreferredConstructor<T, P>((Constructor<T>) constructor);
}
String[] parameterNames = PARAMETER_DISCOVERER.getParameterNames(constructor);
String[] parameterNames = discoverer.getParameterNames(constructor);
Parameter<Object, P>[] parameters = new Parameter[parameterTypes.size()];
Annotation[][] parameterAnnotations = constructor.getParameterAnnotations();