DATAJPA-941 - Avoid causing exceptions in JPA type check.
We're now using Class.isInstance(…) in favor of .cast(…) in JpaClassUtils.isOfType(…) as the latter causes exceptions to be thrown unnecessarily.
This commit is contained in:
@@ -31,9 +31,7 @@ abstract class JpaClassUtils {
|
||||
/**
|
||||
* Private constructor to prevent instantiation.
|
||||
*/
|
||||
private JpaClassUtils() {
|
||||
|
||||
}
|
||||
private JpaClassUtils() {}
|
||||
|
||||
/**
|
||||
* Returns whether the given {@link EntityManager} is of the given type.
|
||||
@@ -56,10 +54,7 @@ abstract class JpaClassUtils {
|
||||
Assert.hasText(typeName, "Target type name must not be null or empty!");
|
||||
|
||||
try {
|
||||
|
||||
ClassUtils.forName(typeName, classLoader).cast(source);
|
||||
return true;
|
||||
|
||||
return ClassUtils.forName(typeName, classLoader).isInstance(source);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user