1313import io .contract_testing .contractcase .grpc .ContractCaseGrpc .ContractCaseStub ;
1414import io .contract_testing .contractcase .grpc .ContractCaseStream .BoundaryResult ;
1515import io .contract_testing .contractcase .grpc .ContractCaseStream .ResultResponse ;
16+ import io .grpc .ManagedChannel ;
1617import io .grpc .ManagedChannelBuilder ;
1718import io .grpc .Status ;
1819import io .grpc .stub .StreamObserver ;
@@ -35,20 +36,22 @@ abstract class AbstractRpcConnector<T extends AbstractMessage, B extends Builder
3536 private final SendingWorker <T > worker ;
3637 private Status errorStatus ;
3738
39+ private ManagedChannel channel ;
40+
3841 private static final int DEFAULT_TIMEOUT_SECONDS = 60 ;
3942
4043
4144 public AbstractRpcConnector (
4245 @ NotNull LogPrinter logPrinter ,
4346 @ NotNull ConfigHandle configHandle ,
4447 @ NotNull RunTestCallback runTestCallback ) {
48+ this .channel = ManagedChannelBuilder
49+ // TODO: Allow configuration of the port
50+ .forAddress ("localhost" , DEFAULT_PORT )
51+ .usePlaintext ()
52+ .build ();
4553 this .worker = new SendingWorker <T >(createConnection (
46- ContractCaseGrpc .newStub (
47- ManagedChannelBuilder
48- // TODO: Allow configuration of the port
49- .forAddress ("localhost" , DEFAULT_PORT )
50- .usePlaintext ()
51- .build ()),
54+ ContractCaseGrpc .newStub (channel ),
5255 new ContractResponseStreamObserver <>(
5356 this ,
5457 logPrinter ,
@@ -182,6 +185,7 @@ public void setErrorStatus(Status errorStatus) {
182185
183186 public void close () {
184187 worker .close ();
188+ this .channel .shutdown ();
185189 }
186190
187191
0 commit comments