@@ -5,7 +5,6 @@ package kotlinx.rpc.grpc.test
5
5
6
6
import kotlinx.coroutines.CompletableDeferred
7
7
import kotlinx.coroutines.delay
8
- import kotlinx.coroutines.launch
9
8
import kotlinx.coroutines.runBlocking
10
9
import kotlinx.coroutines.withTimeout
11
10
import kotlinx.rpc.grpc.GrpcServer
@@ -62,8 +61,12 @@ class GrpcCoreClientTest {
62
61
this .timeout = timeout
63
62
}
64
63
65
- private fun shutdownAndWait (channel : ManagedChannel ) {
66
- channel.shutdown()
64
+ private fun shutdownAndWait (channel : ManagedChannel , now : Boolean = false) {
65
+ if (now) {
66
+ channel.shutdownNow()
67
+ } else {
68
+ channel.shutdown()
69
+ }
67
70
runBlocking { channel.awaitTermination() }
68
71
}
69
72
@@ -190,10 +193,10 @@ class GrpcCoreClientTest {
190
193
@Test
191
194
fun halfCloseBeforeSendingMessage_errorWithoutCrashing () {
192
195
val channel = createChannel()
193
- val call = channel.newHelloCall()
194
- val statusDeferred = CompletableDeferred < Status >( )
196
+ // val call = channel.newHelloCall()
197
+ val call = channel.newHelloCall(fullName = " helloworld.Greeter/SayHello " )
195
198
val listener = createClientCallListener<HelloReply >(
196
- onClose = { status, _ -> statusDeferred.complete( status) }
199
+ onClose = { status, _ -> println ( " Status: ${ status.statusCode} , Message: ${status.getDescription()} " ) }
197
200
)
198
201
assertFailsWith<IllegalStateException > {
199
202
try {
@@ -277,24 +280,15 @@ class GreeterServiceImpl : GreeterService {
277
280
builder = { registerService<GreeterService > { GreeterServiceImpl () } }
278
281
)
279
282
280
- launch {
281
- println (" Terminating in 10 seconds" )
282
- delay(10000 )
283
- server.shutdown()
284
- server.awaitTermination()
285
- }
286
-
287
- launch {
283
+ try {
288
284
server.start()
289
285
println (" Server started" )
290
286
server.awaitTermination()
287
+ } finally {
288
+ server.shutdown()
289
+ server.awaitTermination()
291
290
}
292
291
}
293
-
294
- // runBlocking {
295
- // println("Waiting, so GC is collecting stuff")
296
- // delay(20000)
297
- // }
298
292
}
299
293
300
294
}
0 commit comments