Skip to content

Commit c228d3e

Browse files
committed
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.
1 parent 23a963f commit c228d3e

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/main/java/org/springframework/data/jpa/provider/JpaClassUtils.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ abstract class JpaClassUtils {
3131
/**
3232
* Private constructor to prevent instantiation.
3333
*/
34-
private JpaClassUtils() {
35-
36-
}
34+
private JpaClassUtils() {}
3735

3836
/**
3937
* Returns whether the given {@link EntityManager} is of the given type.
@@ -56,10 +54,7 @@ private static boolean isOfType(Object source, String typeName, ClassLoader clas
5654
Assert.hasText(typeName, "Target type name must not be null or empty!");
5755

5856
try {
59-
60-
ClassUtils.forName(typeName, classLoader).cast(source);
61-
return true;
62-
57+
return ClassUtils.forName(typeName, classLoader).isInstance(source);
6358
} catch (Exception e) {
6459
return false;
6560
}

0 commit comments

Comments
 (0)