From f202ea520d4f3f241deaddf3390f9d70221ec68b Mon Sep 17 00:00:00 2001 From: Mike Schore Date: Tue, 25 Jan 2022 12:16:18 -0800 Subject: [PATCH] stream intel: update kotlin public interface to align with swift (#2013) Description: For terminal callbacks (onError, onCancel, onComplete) changes public interface to provide a single FinalStreamIntel struct that extends from the base StreamIntel available on other callbacks. Risk Level: Low Testing: Local & CI Signed-off-by: Mike Schore --- examples/java/hello_world/MainActivity.java | 2 +- examples/kotlin/hello_world/AsyncDemoFilter.kt | 5 ++--- examples/kotlin/hello_world/BufferDemoFilter.kt | 5 ++--- examples/kotlin/hello_world/DemoFilter.kt | 5 ++--- examples/kotlin/hello_world/MainActivity.kt | 2 +- .../io/envoyproxy/envoymobile/FinalStreamIntel.kt | 9 +++++++-- .../io/envoyproxy/envoymobile/StreamCallbacks.kt | 13 ++++++------- .../kotlin/io/envoyproxy/envoymobile/StreamIntel.kt | 2 +- .../io/envoyproxy/envoymobile/StreamPrototype.kt | 5 ++--- .../io/envoyproxy/envoymobile/filters/Filter.kt | 6 +++--- .../envoymobile/filters/ResponseFilter.kt | 9 +++------ .../envoymobile/grpc/GRPCStreamPrototype.kt | 4 ++-- .../integration/AndroidEnvoyExplicitFlowTest.java | 12 ++++++------ test/java/integration/AndroidEnvoyFlowTest.java | 4 ++-- .../engine/testing/QuicTestServerTest.java | 6 +++--- test/kotlin/integration/CancelStreamTest.kt | 8 ++++---- test/kotlin/integration/DrainConnectionsTest.kt | 4 ++-- test/kotlin/integration/GRPCReceiveErrorTest.kt | 10 +++++----- test/kotlin/integration/ReceiveDataTest.kt | 2 +- test/kotlin/integration/ReceiveErrorTest.kt | 10 +++++----- test/kotlin/integration/SendDataTest.kt | 2 +- test/kotlin/integration/SendHeadersTest.kt | 2 +- test/kotlin/integration/SendTrailersTest.kt | 2 +- test/kotlin/integration/StreamIdleTimeoutTest.kt | 8 ++++---- 24 files changed, 67 insertions(+), 70 deletions(-) diff --git a/examples/java/hello_world/MainActivity.java b/examples/java/hello_world/MainActivity.java index cf121e56eb..5d1ebcd4ac 100644 --- a/examples/java/hello_world/MainActivity.java +++ b/examples/java/hello_world/MainActivity.java @@ -125,7 +125,7 @@ private void makeRequest() { } return Unit.INSTANCE; }) - .setOnError((error, ignored, also_ignored) -> { + .setOnError((error, ignored) -> { String message = "failed with error after " + error.getAttemptCount() + " attempts: " + error.getMessage(); Log.d("MainActivity", message); diff --git a/examples/kotlin/hello_world/AsyncDemoFilter.kt b/examples/kotlin/hello_world/AsyncDemoFilter.kt index 72f6ab8463..a45ec5f7af 100644 --- a/examples/kotlin/hello_world/AsyncDemoFilter.kt +++ b/examples/kotlin/hello_world/AsyncDemoFilter.kt @@ -81,16 +81,15 @@ class AsyncDemoFilter : AsyncResponseFilter { @Suppress("EmptyFunctionBlock") override fun onError( error: EnvoyError, - streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel ) { } @Suppress("EmptyFunctionBlock") - override fun onCancel(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onCancel(finalStreamIntel: FinalStreamIntel) { } @Suppress("EmptyFunctionBlock") - override fun onComplete(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onComplete(finalStreamIntel: FinalStreamIntel) { } } diff --git a/examples/kotlin/hello_world/BufferDemoFilter.kt b/examples/kotlin/hello_world/BufferDemoFilter.kt index dee61511e5..f158d1b1e6 100644 --- a/examples/kotlin/hello_world/BufferDemoFilter.kt +++ b/examples/kotlin/hello_world/BufferDemoFilter.kt @@ -59,16 +59,15 @@ class BufferDemoFilter : ResponseFilter { @Suppress("EmptyFunctionBlock") override fun onError( error: EnvoyError, - streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel ) { } @Suppress("EmptyFunctionBlock") - override fun onCancel(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onCancel(finalStreamIntel: FinalStreamIntel) { } @Suppress("EmptyFunctionBlock") - override fun onComplete(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onComplete(finalStreamIntel: FinalStreamIntel) { } } diff --git a/examples/kotlin/hello_world/DemoFilter.kt b/examples/kotlin/hello_world/DemoFilter.kt index f9c005f997..2f231fd130 100644 --- a/examples/kotlin/hello_world/DemoFilter.kt +++ b/examples/kotlin/hello_world/DemoFilter.kt @@ -43,17 +43,16 @@ class DemoFilter : ResponseFilter { override fun onError( error: EnvoyError, - streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel ) { Log.d("DemoFilter", "On error!") } - override fun onCancel(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onCancel(finalStreamIntel: FinalStreamIntel) { Log.d("DemoFilter", "On cancel!") } @Suppress("EmptyFunctionBlock") - override fun onComplete(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onComplete(finalStreamIntel: FinalStreamIntel) { } } diff --git a/examples/kotlin/hello_world/MainActivity.kt b/examples/kotlin/hello_world/MainActivity.kt index 7fc060ee25..d58c7b40c1 100644 --- a/examples/kotlin/hello_world/MainActivity.kt +++ b/examples/kotlin/hello_world/MainActivity.kt @@ -135,7 +135,7 @@ class MainActivity : Activity() { recyclerView.post { viewAdapter.add(Failure(message)) } } } - .setOnError { error, _, _ -> + .setOnError { error, _ -> val attemptCount = error.attemptCount ?: -1 val message = "failed with error after $attemptCount attempts: ${error.message}" Log.d("MainActivity", message) diff --git a/library/kotlin/io/envoyproxy/envoymobile/FinalStreamIntel.kt b/library/kotlin/io/envoyproxy/envoymobile/FinalStreamIntel.kt index 5375146578..9ceb9db423 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/FinalStreamIntel.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/FinalStreamIntel.kt @@ -1,6 +1,7 @@ package io.envoyproxy.envoymobile import io.envoyproxy.envoymobile.engine.types.EnvoyFinalStreamIntel +import io.envoyproxy.envoymobile.engine.types.EnvoyStreamIntel /** * Exposes one time HTTP stream metrics, context, and other details. @@ -29,6 +30,9 @@ import io.envoyproxy.envoymobile.engine.types.EnvoyFinalStreamIntel */ @Suppress("LongParameterList") class FinalStreamIntel constructor( + streamId: Long, + connectionId: Long, + attemptCount: Long, val requestStartMs: Long, val dnsStartMs: Long, val dnsEndMs: Long, @@ -43,8 +47,9 @@ class FinalStreamIntel constructor( val socketReused: Boolean, val sentByteCount: Long, val receivedByteCount: Long -) { - constructor(base: EnvoyFinalStreamIntel) : this( +) : StreamIntel(streamId, connectionId, attemptCount) { + constructor(superBase: EnvoyStreamIntel, base: EnvoyFinalStreamIntel) : this( + superBase.streamId, superBase.connectionId, superBase.attemptCount, base.requestStartMs, base.dnsStartMs, base.dnsEndMs, base.connectStartMs, base.connectEndMs, base.sslStartMs, diff --git a/library/kotlin/io/envoyproxy/envoymobile/StreamCallbacks.kt b/library/kotlin/io/envoyproxy/envoymobile/StreamCallbacks.kt index 43e3251a9d..9bd34c3579 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/StreamCallbacks.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/StreamCallbacks.kt @@ -18,12 +18,12 @@ internal class StreamCallbacks { )? = null var onData: ((data: ByteBuffer, endStream: Boolean, streamIntel: StreamIntel) -> Unit)? = null var onTrailers: ((trailers: ResponseTrailers, streamIntel: StreamIntel) -> Unit)? = null - var onCancel: ((streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) -> Unit)? = null + var onCancel: ((finalStreamIntel: FinalStreamIntel) -> Unit)? = null var onError: ( - (error: EnvoyError, streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) -> Unit + (error: EnvoyError, finalStreamIntel: FinalStreamIntel) -> Unit )? = null var onSendWindowAvailable: ((streamIntel: StreamIntel) -> Unit)? = null - var onComplete: ((streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) -> Unit)? = null + var onComplete: ((finalStreamIntel: FinalStreamIntel) -> Unit)? = null } /** @@ -63,13 +63,12 @@ internal class EnvoyHTTPCallbacksAdapter( ) { callbacks.onError?.invoke( EnvoyError(errorCode, message, attemptCount), - StreamIntel(streamIntel), - FinalStreamIntel(finalStreamIntel) + FinalStreamIntel(streamIntel, finalStreamIntel) ) } override fun onCancel(streamIntel: EnvoyStreamIntel, finalStreamIntel: EnvoyFinalStreamIntel) { - callbacks.onCancel?.invoke(StreamIntel(streamIntel), FinalStreamIntel(finalStreamIntel)) + callbacks.onCancel?.invoke(FinalStreamIntel(streamIntel, finalStreamIntel)) } override fun onSendWindowAvailable(streamIntel: EnvoyStreamIntel) { @@ -77,6 +76,6 @@ internal class EnvoyHTTPCallbacksAdapter( } override fun onComplete(streamIntel: EnvoyStreamIntel, finalStreamIntel: EnvoyFinalStreamIntel) { - callbacks.onComplete?.invoke(StreamIntel(streamIntel), FinalStreamIntel(finalStreamIntel)) + callbacks.onComplete?.invoke(FinalStreamIntel(streamIntel, finalStreamIntel)) } } diff --git a/library/kotlin/io/envoyproxy/envoymobile/StreamIntel.kt b/library/kotlin/io/envoyproxy/envoymobile/StreamIntel.kt index f5c78549ee..29238d361b 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/StreamIntel.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/StreamIntel.kt @@ -9,7 +9,7 @@ import io.envoyproxy.envoymobile.engine.types.EnvoyStreamIntel * @param attemptCount The number of internal attempts to carry out a request/operation. 0 if * not set. */ -class StreamIntel constructor( +open class StreamIntel constructor( val streamId: Long, val connectionId: Long, val attemptCount: Long diff --git a/library/kotlin/io/envoyproxy/envoymobile/StreamPrototype.kt b/library/kotlin/io/envoyproxy/envoymobile/StreamPrototype.kt index cfca4cdb93..748351905a 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/StreamPrototype.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/StreamPrototype.kt @@ -113,7 +113,6 @@ open class StreamPrototype(private val engine: EnvoyEngine) { fun setOnError( closure: ( error: EnvoyError, - streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel ) -> Unit ): StreamPrototype { @@ -129,7 +128,7 @@ open class StreamPrototype(private val engine: EnvoyEngine) { * @return This stream, for chaining syntax. */ fun setOnComplete( - closure: (streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) -> Unit + closure: (finalStreamIntel: FinalStreamIntel) -> Unit ): StreamPrototype { callbacks.onComplete = closure return this @@ -143,7 +142,7 @@ open class StreamPrototype(private val engine: EnvoyEngine) { * @return This stream, for chaining syntax. */ fun setOnCancel( - closure: (streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) -> Unit + closure: (finalStreamIntel: FinalStreamIntel) -> Unit ): StreamPrototype { callbacks.onCancel = closure return this diff --git a/library/kotlin/io/envoyproxy/envoymobile/filters/Filter.kt b/library/kotlin/io/envoyproxy/envoymobile/filters/Filter.kt index 1741b85f2b..d83845ff94 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/filters/Filter.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/filters/Filter.kt @@ -102,19 +102,19 @@ internal class EnvoyHTTPFilterAdapter( override fun onError(errorCode: Int, message: String, attemptCount: Int, streamIntel: EnvoyStreamIntel, finalStreamIntel: EnvoyFinalStreamIntel) { (filter as? ResponseFilter)?.let { responseFilter -> - responseFilter.onError(EnvoyError(errorCode, message, attemptCount), StreamIntel(streamIntel), FinalStreamIntel(finalStreamIntel)) + responseFilter.onError(EnvoyError(errorCode, message, attemptCount), FinalStreamIntel(streamIntel, finalStreamIntel)) } } override fun onCancel(streamIntel: EnvoyStreamIntel, finalStreamIntel: EnvoyFinalStreamIntel) { (filter as? ResponseFilter)?.let { responseFilter -> - responseFilter.onCancel(StreamIntel(streamIntel), FinalStreamIntel(finalStreamIntel)) + responseFilter.onCancel(FinalStreamIntel(streamIntel, finalStreamIntel)) } } override fun onComplete(streamIntel: EnvoyStreamIntel, finalStreamIntel: EnvoyFinalStreamIntel) { (filter as? ResponseFilter)?.let { responseFilter -> - responseFilter.onComplete(StreamIntel(streamIntel), FinalStreamIntel(finalStreamIntel)) + responseFilter.onComplete(FinalStreamIntel(streamIntel, finalStreamIntel)) } } diff --git a/library/kotlin/io/envoyproxy/envoymobile/filters/ResponseFilter.kt b/library/kotlin/io/envoyproxy/envoymobile/filters/ResponseFilter.kt index 41991cb44a..fa7ce9a5ee 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/filters/ResponseFilter.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/filters/ResponseFilter.kt @@ -55,10 +55,9 @@ interface ResponseFilter : Filter { * `stopIteration{...}`. * * @param error: The error that occurred within Envoy. - * @param streamIntel: Internal HTTP stream metrics, context, and other details. * @param finalStreamIntel: Final internal HTTP stream metrics, context, and other details. */ - fun onError(error: EnvoyError, streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) + fun onError(error: EnvoyError, finalStreamIntel: FinalStreamIntel) /** * Called at most once when the client cancels the stream. @@ -67,10 +66,9 @@ interface ResponseFilter : Filter { * This should be considered a terminal state, and invalidates any previous attempts to * `stopIteration{...}`. * - * @param streamIntel: Internal HTTP stream metrics, context, and other details. * @param finalStreamIntel: Final internal HTTP stream metrics, context, and other details. */ - fun onCancel(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) + fun onCancel(finalStreamIntel: FinalStreamIntel) /** * Called at most once when the stream completes gracefully. @@ -79,8 +77,7 @@ interface ResponseFilter : Filter { * This should be considered a terminal state, and invalidates any previous attempts to * `stopIteration{...}`. * - * @param streamIntel: Internal HTTP stream metrics, context, and other details. * @param finalStreamIntel: Final internal HTTP stream metrics, context, and other details. */ - fun onComplete(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) + fun onComplete(finalStreamIntel: FinalStreamIntel) } diff --git a/library/kotlin/io/envoyproxy/envoymobile/grpc/GRPCStreamPrototype.kt b/library/kotlin/io/envoyproxy/envoymobile/grpc/GRPCStreamPrototype.kt index 6192c7d4d3..7b35796c52 100644 --- a/library/kotlin/io/envoyproxy/envoymobile/grpc/GRPCStreamPrototype.kt +++ b/library/kotlin/io/envoyproxy/envoymobile/grpc/GRPCStreamPrototype.kt @@ -89,7 +89,7 @@ class GRPCStreamPrototype( * @return This stream, for chaining syntax. */ fun setOnError( - closure: (error: EnvoyError, streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) -> Unit + closure: (error: EnvoyError, finalStreamIntel: FinalStreamIntel) -> Unit ): GRPCStreamPrototype { underlyingStream.setOnError(closure) return this @@ -103,7 +103,7 @@ class GRPCStreamPrototype( * @return This stream, for chaining syntax. */ fun setOnCancel( - closure: (streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) -> Unit + closure: (finalStreamIntel: FinalStreamIntel) -> Unit ): GRPCStreamPrototype { underlyingStream.setOnCancel(closure) return this diff --git a/test/java/integration/AndroidEnvoyExplicitFlowTest.java b/test/java/integration/AndroidEnvoyExplicitFlowTest.java index fc8cd5c4f1..09f2e50675 100644 --- a/test/java/integration/AndroidEnvoyExplicitFlowTest.java +++ b/test/java/integration/AndroidEnvoyExplicitFlowTest.java @@ -500,22 +500,22 @@ private Response sendRequest(RequestScenario requestScenario) throws Exception { response.get().addStreamIntel(streamIntel); return null; }) - .setOnError((error, streamIntel, finalStreamIntel) -> { + .setOnError((error, finalStreamIntel) -> { response.get().setEnvoyError(error); - response.get().addStreamIntel(streamIntel); + response.get().addStreamIntel(finalStreamIntel); response.get().setFinalStreamIntel(finalStreamIntel); latch.countDown(); return null; }) - .setOnCancel((streamIntel, finalStreamIntel) -> { + .setOnCancel((finalStreamIntel) -> { response.get().setCancelled(); - response.get().addStreamIntel(streamIntel); + response.get().addStreamIntel(finalStreamIntel); response.get().setFinalStreamIntel(finalStreamIntel); latch.countDown(); return null; }) - .setOnComplete((streamIntel, finalStreamIntel) -> { - response.get().addStreamIntel(streamIntel); + .setOnComplete((finalStreamIntel) -> { + response.get().addStreamIntel(finalStreamIntel); response.get().setFinalStreamIntel(finalStreamIntel); latch.countDown(); return null; diff --git a/test/java/integration/AndroidEnvoyFlowTest.java b/test/java/integration/AndroidEnvoyFlowTest.java index a1a57e8904..7d1bf250c9 100644 --- a/test/java/integration/AndroidEnvoyFlowTest.java +++ b/test/java/integration/AndroidEnvoyFlowTest.java @@ -302,12 +302,12 @@ private Response sendRequest(RequestScenario requestScenario) throws Exception { latch.countDown(); return null; }) - .setOnError((error, ignored, also_ignored) -> { + .setOnError((error, ignored) -> { response.get().setEnvoyError(error); latch.countDown(); return null; }) - .setOnCancel((ignored, also_ignored) -> { + .setOnCancel((ignored) -> { response.get().setCancelled(); latch.countDown(); return null; diff --git a/test/java/io/envoyproxy/envoymobile/engine/testing/QuicTestServerTest.java b/test/java/io/envoyproxy/envoymobile/engine/testing/QuicTestServerTest.java index 982b4f5a21..4a50ef8414 100644 --- a/test/java/io/envoyproxy/envoymobile/engine/testing/QuicTestServerTest.java +++ b/test/java/io/envoyproxy/envoymobile/engine/testing/QuicTestServerTest.java @@ -157,17 +157,17 @@ private QuicTestServerTest.Response sendRequest(RequestScenario requestScenario) response.get().setTrailers(trailers); return null; }) - .setOnError((error, ignored1, ignored2) -> { + .setOnError((error, ignored) -> { response.get().setEnvoyError(error); latch.countDown(); return null; }) - .setOnCancel((ignored1, ignored2) -> { + .setOnCancel((ignored) -> { response.get().setCancelled(); latch.countDown(); return null; }) - .setOnComplete((ignored1, ignored2) -> { + .setOnComplete((ignored) -> { latch.countDown(); return null; }) diff --git a/test/kotlin/integration/CancelStreamTest.kt b/test/kotlin/integration/CancelStreamTest.kt index 31321010fd..9964f4770e 100644 --- a/test/kotlin/integration/CancelStreamTest.kt +++ b/test/kotlin/integration/CancelStreamTest.kt @@ -109,10 +109,10 @@ class CancelStreamTest { return FilterTrailersStatus.Continue(trailers) } - override fun onError(error: EnvoyError, streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) {} - override fun onComplete(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) {} + override fun onError(error: EnvoyError, finalStreamIntel: FinalStreamIntel) {} + override fun onComplete(finalStreamIntel: FinalStreamIntel) {} - override fun onCancel(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onCancel(finalStreamIntel: FinalStreamIntel) { latch.countDown() } } @@ -139,7 +139,7 @@ class CancelStreamTest { .build() client.newStreamPrototype() - .setOnCancel { _, _ -> + .setOnCancel { _ -> runExpectation.countDown() } .start(Executors.newSingleThreadExecutor()) diff --git a/test/kotlin/integration/DrainConnectionsTest.kt b/test/kotlin/integration/DrainConnectionsTest.kt index f43c04a2a4..597c659120 100644 --- a/test/kotlin/integration/DrainConnectionsTest.kt +++ b/test/kotlin/integration/DrainConnectionsTest.kt @@ -85,7 +85,7 @@ class DrainConnectionsTest { resultEndStream1 = endStream headersExpectation.countDown() } - .setOnError { _, _, _ -> fail("Unexpected error") } + .setOnError { _, _ -> fail("Unexpected error") } .start() .sendHeaders(requestHeaders, true) @@ -101,7 +101,7 @@ class DrainConnectionsTest { resultEndStream2 = endStream headersExpectation.countDown() } - .setOnError { _, _, _ -> fail("Unexpected error") } + .setOnError { _, _ -> fail("Unexpected error") } .start() .sendHeaders(requestHeaders, true) diff --git a/test/kotlin/integration/GRPCReceiveErrorTest.kt b/test/kotlin/integration/GRPCReceiveErrorTest.kt index e83c87382f..8da673736f 100644 --- a/test/kotlin/integration/GRPCReceiveErrorTest.kt +++ b/test/kotlin/integration/GRPCReceiveErrorTest.kt @@ -96,12 +96,12 @@ class GRPCReceiveErrorTest { return FilterTrailersStatus.Continue(trailers) } - override fun onError(error: EnvoyError, streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onError(error: EnvoyError, finalStreamIntel: FinalStreamIntel) { receivedError.countDown() } - override fun onComplete(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) {} + override fun onComplete(finalStreamIntel: FinalStreamIntel) {} - override fun onCancel(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onCancel(finalStreamIntel: FinalStreamIntel) { notCancelled.countDown() } } @@ -126,10 +126,10 @@ class GRPCReceiveErrorTest { .newGRPCStreamPrototype() .setOnResponseHeaders { _, _, _ -> } .setOnResponseMessage { _, _ -> } - .setOnError { _, _, _ -> + .setOnError { _, _ -> callbackReceivedError.countDown() } - .setOnCancel { _, _ -> + .setOnCancel { _ -> fail("Unexpected call to onCancel response callback") } .start() diff --git a/test/kotlin/integration/ReceiveDataTest.kt b/test/kotlin/integration/ReceiveDataTest.kt index 36702adbf5..4059e14587 100644 --- a/test/kotlin/integration/ReceiveDataTest.kt +++ b/test/kotlin/integration/ReceiveDataTest.kt @@ -94,7 +94,7 @@ class ReceiveDataTest { body = data dataExpectation.countDown() } - .setOnError { _, _, _ -> fail("Unexpected error") } + .setOnError { _, _ -> fail("Unexpected error") } .start() .sendHeaders(requestHeaders, true) diff --git a/test/kotlin/integration/ReceiveErrorTest.kt b/test/kotlin/integration/ReceiveErrorTest.kt index b7f61b239f..0e71279f51 100644 --- a/test/kotlin/integration/ReceiveErrorTest.kt +++ b/test/kotlin/integration/ReceiveErrorTest.kt @@ -93,12 +93,12 @@ class ReceiveErrorTest { return FilterTrailersStatus.Continue(trailers) } - override fun onError(error: EnvoyError, streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onError(error: EnvoyError, finalStreamIntel: FinalStreamIntel) { receivedError.countDown() } - override fun onComplete(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) {} + override fun onComplete(finalStreamIntel: FinalStreamIntel) {} - override fun onCancel(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onCancel(finalStreamIntel: FinalStreamIntel) { notCancelled.countDown() } } @@ -127,11 +127,11 @@ class ReceiveErrorTest { .setOnResponseData { _, _, _ -> fail("Data received instead of expected error") } // The unmatched expectation will cause a local reply which gets translated in Envoy Mobile to // an error. - .setOnError { error, _, _ -> + .setOnError { error, _ -> errorCode = error.errorCode callbackReceivedError.countDown() } - .setOnCancel { _, _ -> + .setOnCancel { _ -> fail("Unexpected call to onCancel response callback") } .start() diff --git a/test/kotlin/integration/SendDataTest.kt b/test/kotlin/integration/SendDataTest.kt index 1fe9075a8a..925e9f3bea 100644 --- a/test/kotlin/integration/SendDataTest.kt +++ b/test/kotlin/integration/SendDataTest.kt @@ -93,7 +93,7 @@ class SendDataTest { responseHeadersEndStream = endStream expectation.countDown() } - .setOnError { _, _, _ -> + .setOnError { _, _ -> fail("Unexpected error") } .start() diff --git a/test/kotlin/integration/SendHeadersTest.kt b/test/kotlin/integration/SendHeadersTest.kt index 823a524d7a..20cdb99f01 100644 --- a/test/kotlin/integration/SendHeadersTest.kt +++ b/test/kotlin/integration/SendHeadersTest.kt @@ -85,7 +85,7 @@ class SendHeadersTest { resultEndStream = endStream headersExpectation.countDown() } - .setOnError { _, _, _ -> fail("Unexpected error") } + .setOnError { _, _ -> fail("Unexpected error") } .start() .sendHeaders(requestHeaders, true) diff --git a/test/kotlin/integration/SendTrailersTest.kt b/test/kotlin/integration/SendTrailersTest.kt index 1391ced880..1392583e19 100644 --- a/test/kotlin/integration/SendTrailersTest.kt +++ b/test/kotlin/integration/SendTrailersTest.kt @@ -98,7 +98,7 @@ class SendTrailersTest { responseStatus = headers.httpStatus expectation.countDown() } - .setOnError { _, _, _ -> + .setOnError { _, _ -> fail("Unexpected error") } .start() diff --git a/test/kotlin/integration/StreamIdleTimeoutTest.kt b/test/kotlin/integration/StreamIdleTimeoutTest.kt index 8d1117961f..4b787242dc 100644 --- a/test/kotlin/integration/StreamIdleTimeoutTest.kt +++ b/test/kotlin/integration/StreamIdleTimeoutTest.kt @@ -132,13 +132,13 @@ class CancelStreamTest { return FilterTrailersStatus.StopIteration() } - override fun onError(error: EnvoyError, streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onError(error: EnvoyError, finalStreamIntel: FinalStreamIntel) { assertThat(error.errorCode).isEqualTo(4) latch.countDown() } - override fun onComplete(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) {} + override fun onComplete(finalStreamIntel: FinalStreamIntel) {} - override fun onCancel(streamIntel: StreamIntel, finalStreamIntel: FinalStreamIntel) { + override fun onCancel(finalStreamIntel: FinalStreamIntel) { fail("Unexpected call to onCancel filter callback") } } @@ -165,7 +165,7 @@ class CancelStreamTest { .build() client.newStreamPrototype() - .setOnError { error, _, _ -> + .setOnError { error, _ -> assertThat(error.errorCode).isEqualTo(4) callbackExpectation.countDown() }