File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
src/main/java/com/github/mhewedy/expressions Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 23
23
public class ExpressionsRepositoryImpl <T , ID >
24
24
extends SimpleJpaRepository <T , ID > implements ExpressionsRepository <T , ID > {
25
25
26
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper ();
26
+ private static Object OBJECT_MAPPER ;
27
+ private static final boolean OBJECT_MAPPER_PRESENT = ClassUtils .isPresent ("com.fasterxml.jackson.databind.ObjectMapper" ,
28
+ ExpressionsRepositoryImpl .class .getClassLoader ());
29
+
30
+ static {
31
+ if (OBJECT_MAPPER_PRESENT ) {
32
+ OBJECT_MAPPER = new ObjectMapper ();
33
+ }
34
+ }
27
35
28
36
public ExpressionsRepositoryImpl (JpaEntityInformation <T , Long >
29
37
entityInformation , EntityManager entityManager ) {
@@ -66,12 +74,7 @@ private void logExpressions() {
66
74
if (!log .isDebugEnabled ()) {
67
75
return ;
68
76
}
69
- if (ClassUtils .isPresent ("com.fasterxml.jackson.databind.ObjectMapper" ,
70
- ExpressionsSpecification .class .getClassLoader ())) {
71
- log .debug ("expressions: {}" , OBJECT_MAPPER .writeValueAsString (expressions ));
72
- } else {
73
- log .debug ("expressions: {}" , expressions .toString ());
74
- }
77
+ log .debug ("expressions: {}" , OBJECT_MAPPER_PRESENT ? ((ObjectMapper ) OBJECT_MAPPER ).writeValueAsString (expressions ) : expressions );
75
78
}
76
79
}
77
80
}
You can’t perform that action at this time.
0 commit comments