Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.ai.testcontainers.service.connection.mongo;

import java.lang.invoke.MethodHandles;
import java.lang.reflect.Method;

import com.mongodb.ConnectionString;
Expand All @@ -41,6 +42,7 @@
*
* @author Eddú Meléndez
* @author Soby Chacko
* @author Yanming Zhou
* @since 1.0.0
* @see ContainerConnectionDetailsFactory
* @see MongoConnectionDetails
Expand Down Expand Up @@ -80,7 +82,16 @@ public ConnectionString getConnectionString() {
// Conditional implementation based on whether the method exists
public SslBundle getSslBundle() {
if (GET_SSL_BUNDLE_METHOD != null) { // Boot 3.5.x+
return (SslBundle) ReflectionUtils.invokeMethod(GET_SSL_BUNDLE_METHOD, this);
try {
return (SslBundle) MethodHandles.lookup()
.in(GET_SSL_BUNDLE_METHOD.getDeclaringClass())
.unreflectSpecial(GET_SSL_BUNDLE_METHOD, GET_SSL_BUNDLE_METHOD.getDeclaringClass())
.bindTo(this)
.invokeWithArguments();
}
catch (Throwable e) {
throw new RuntimeException(e);
}
}
return null; // Boot 3.4.x (No-Op)
}
Expand Down