Skip to content

Commit

Permalink
android: make response handler arguments non-optional (#395)
Browse files Browse the repository at this point in the history
Description: these fields should not be optional. The callbacks must send up that data.
Risk Level: low
Testing: tested with e2e demo

Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
  • Loading branch information
junr03 authored and jpsim committed Nov 28, 2022
1 parent 6e9aaef commit 525e1e6
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class ResponseHandler(val executor: Executor) {

override fun getExecutor(): Executor = responseHandler.executor

override fun onHeaders(headers: Map<String, List<String>>?, endStream: Boolean) {
override fun onHeaders(headers: Map<String, List<String>>, endStream: Boolean) {
val statusCode = headers!![":status"]?.first()?.toIntOrNull() ?: 0
responseHandler.onHeadersClosure(headers, statusCode, endStream)
}

override fun onData(byteBuffer: ByteBuffer?, endStream: Boolean) {
override fun onData(byteBuffer: ByteBuffer, endStream: Boolean) {
responseHandler.onDataClosure(byteBuffer, endStream)
}

Expand All @@ -45,7 +45,7 @@ class ResponseHandler(val executor: Executor) {
internal val underlyingObserver = EnvoyObserverAdapter(this)

private var onHeadersClosure: (headers: Map<String, List<String>>, statusCode: Int, endStream: Boolean) -> Unit = { _, _, _ -> Unit }
private var onDataClosure: (byteBuffer: ByteBuffer?, endStream: Boolean) -> Unit = { _, _ -> Unit }
private var onDataClosure: (byteBuffer: ByteBuffer, endStream: Boolean) -> Unit = { _, _ -> Unit }
private var onMetadataClosure: (metadata: Map<String, List<String>>) -> Unit = { Unit }
private var onTrailersClosure: (trailers: Map<String, List<String>>) -> Unit = { Unit }
private var onErrorClosure: () -> Unit = { Unit }
Expand All @@ -72,7 +72,7 @@ class ResponseHandler(val executor: Executor) {
* and flag indicating if the stream is complete.
* @return ResponseHandler, this ResponseHandler.
*/
fun onData(closure: (byteBuffer: ByteBuffer?, endStream: Boolean) -> Unit): ResponseHandler {
fun onData(closure: (byteBuffer: ByteBuffer, endStream: Boolean) -> Unit): ResponseHandler {
this.onDataClosure = closure
return this
}
Expand Down

0 comments on commit 525e1e6

Please sign in to comment.