pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

gRPC channel not shutdown properly when error occurs #1698

Open rkrishnan2012 opened 1 year ago

rkrishnan2012 commented 1 year ago

Hello,

DefaultPluginManager currently creates a ManagedChannel inside tryInitPlugin, however if the call to initPlugin fails inside it, we don't ever call shutdown() on the created channel, so there's an error logged. It would be great if the channel is shutdown prior to the exception propagating up.

EVERE: *~*~*~ Previous channel ManagedChannelImpl{logId=1, target=[::1]:51216} was not shutdown properly!!! ~*~*~*
    Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
java.lang.RuntimeException: ManagedChannel allocation site
    at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.<init>(ManagedChannelOrphanWrapper.java:100)
    at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:60)
    at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:51)
    at io.grpc.internal.ManagedChannelImplBuilder.build(ManagedChannelImplBuilder.java:631)
    at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:297)
    at io.pact.plugins.jvm.core.DefaultPluginManager$tryInitPlugin$1.invoke(PluginManager.kt:887)

I'm on Pact JVM Core library 0.4.0

Subhojit-Dey1234 commented 1 year ago

Yes I am also getting this error.