Skip to content

Fix StackOverflowError introduced by MongoDbAtlasLocalContainerConnectionDetails.getSslBundle() #4149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2025
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