Skip to content

HTTP Connection Error in cleanupSpec() Function in Spock: "SSL is disabled" #1191

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

Open
ratnahalder opened this issue Feb 20, 2025 · 0 comments

Comments

@ratnahalder
Copy link

ratnahalder commented Feb 20, 2025

Expected Behavior

I'm encountering an issue when making an HTTP request in the cleanupSpec() function of a Spock test. The same HTTP GET request works perfectly in both the test case and the cleanup() function, but when it's called from cleanupSpec(). I expected the HTTP client to remain active until cleanupSpec() is successfully executed.

I also posted this question on StackOverflow earlier. Here is the link: https://stackoverflow.com/questions/78897561/http-connection-error-in-cleanupspec-function-in-spock-ssl-is-disabled.

Actual Behaviour

Instead of successfully executing HTTP request, I'm getting the following error:
Connect Error: Cannot send HTTPS request. SSL is disabled io.micronaut.http.client.exceptions.HttpClientException: Connect Error: Cannot send HTTPS request. SSL is disabled

Detail error message:
Connect Error: Cannot send HTTPS request. SSL is disabled io.micronaut.http.client.exceptions.HttpClientException: Connect Error: Cannot send HTTPS request. SSL is disabled at app//io.micronaut.http.client.netty.ConnectionManager$Pool.onNewConnectionFailure(ConnectionManager.java:986) at app//io.micronaut.http.client.netty.PoolResizer.doSomeWork(PoolResizer.java:157) at app//io.micronaut.http.client.netty.PoolResizer.dirty(PoolResizer.java:77) at app//io.micronaut.http.client.netty.PoolResizer.addPendingRequest(PoolResizer.java:233) at app//io.micronaut.http.client.netty.ConnectionManager$Pool.acquire(ConnectionManager.java:965) at app//io.micronaut.http.client.netty.ConnectionManager.connect(ConnectionManager.java:430) at app//io.micronaut.http.client.netty.DefaultHttpClient.exchangeImpl(DefaultHttpClient.java:1113) at app//io.micronaut.http.client.netty.DefaultHttpClient.lambda$exchange$8(DefaultHttpClient.java:811) at app//reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:152) at app//reactor.core.publisher.FluxSwitchMapNoPrefetch.subscribeOrReturn(FluxSwitchMapNoPrefetch.java:61) at app//reactor.core.publisher.Flux.subscribe(Flux.java:8759) at app//reactor.core.publisher.Flux.blockFirst(Flux.java:2703) at app//io.micronaut.http.client.netty.DefaultHttpClient$1.exchange(DefaultHttpClient.java:547) at app//io.micronaut.http.client.BlockingHttpClient.exchange(BlockingHttpClient.java:77) at app//io.micronaut.http.client.BlockingHttpClient.exchange(BlockingHttpClient.java:106) at app//com.example.TestGetSpec.cleanupSpec(TestGETSpec.groovy:34)

Temporary Solution

Manually creating the HttpClient and managing its lifecycle, but it slows down our system. Therefore, we are looking for a permanent solution to this issue.

Steps To Reproduce

Just run this sample micronaut test class:

`@MicronautTest
class TestGetSpec extends Specification {

@Shared
@Inject
HttpClient httpClient

def cleanup() {
    println("TestGETSpec:: Calling cleanup() function")

    def response = httpClient.toBlocking().exchange(
            HttpRequest.GET("https://jsonplaceholder.typicode.com/posts/1").accept(MediaType.APPLICATION_JSON),
            Object
    )
}

def cleanupSpec() {
    println("TestGETSpec:: Calling cleanupSpec() function")

    def response = httpClient.toBlocking().exchange(
            HttpRequest.GET("https://jsonplaceholder.typicode.com/posts/1").accept(MediaType.APPLICATION_JSON),
            Object
    )
}

def "test HTTP request with ReactorHttpClient"() {
    when:
    def response = httpClient.toBlocking().exchange(
            HttpRequest.GET("https://jsonplaceholder.typicode.com/posts/1").accept(MediaType.APPLICATION_JSON),
            Object
    )

    then:
    response.status.code == 200
}

}`

Environment Information

No response

Example Application

https://github.com/ratnahalder/micronaut_test

Version

3.7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant