Browse Source

DATAMONGO-917 - Improve Spring 4.0 framework version detection to avoid NPEs.

We now check for the presence of DefaultParameterNameDiscoverer in order to determine if we are running with a Spring version later than 4.0 since this avoids potential NullPointerExceptions in cases where the package version information is not available e.g. in cases where the application was bundled into an "uberjar" e.g. via the maven-shade-plugin.

Original pull request: #173.
1.4.x
Thomas Darimont 12 years ago committed by Oliver Gierke
parent
commit
332d9d95f4
  1. 5
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultDbRefResolver.java

5
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultDbRefResolver.java

@ -33,7 +33,6 @@ import org.springframework.cglib.proxy.Callback; @@ -33,7 +33,6 @@ import org.springframework.cglib.proxy.Callback;
import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.Factory;
import org.springframework.cglib.proxy.MethodProxy;
import org.springframework.core.SpringVersion;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.data.mongodb.LazyLoadingException;
@ -382,7 +381,9 @@ public class DefaultDbRefResolver implements DbRefResolver { @@ -382,7 +381,9 @@ public class DefaultDbRefResolver implements DbRefResolver {
*/
private static class ObjenesisProxyEnhancer {
private static final boolean IS_SPRING_4_OR_BETTER = SpringVersion.getVersion().startsWith("4");
private static final boolean IS_SPRING_4_OR_BETTER = ClassUtils.isPresent(
"org.springframework.core.DefaultParameterNameDiscoverer", null);
private static final InstanceCreatorStrategy INSTANCE_CREATOR;
static {

Loading…
Cancel
Save