File tree 1 file changed +6
-2
lines changed
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package org .springframework .data .mongodb .util ;
17
17
18
+ import java .lang .reflect .Field ;
19
+
18
20
import org .springframework .data .util .Version ;
19
21
import org .springframework .lang .Nullable ;
20
22
import org .springframework .util .ClassUtils ;
23
+ import org .springframework .util .ReflectionUtils ;
21
24
22
25
import com .mongodb .internal .build .MongoDriverVersion ;
23
26
@@ -96,8 +99,9 @@ private static Version getVersionFromPackage(ClassLoader classLoader) {
96
99
97
100
if (ClassUtils .isPresent ("com.mongodb.internal.build.MongoDriverVersion" , classLoader )) {
98
101
try {
99
- return Version .parse (MongoDriverVersion .VERSION );
100
- } catch (IllegalArgumentException exception ) {
102
+ Field field = ReflectionUtils .findField (MongoDriverVersion .class , "VERSION" );
103
+ return field != null ? Version .parse ("" + field .get (null )) : null ;
104
+ } catch (ReflectiveOperationException | IllegalArgumentException exception ) {
101
105
// well not much we can do, right?
102
106
}
103
107
}
You can’t perform that action at this time.
0 commit comments