From e616c6a950359c670400f0b5d502610cc7e74151 Mon Sep 17 00:00:00 2001 From: navid Date: Thu, 31 Oct 2024 10:31:26 +0100 Subject: [PATCH] Apply trailer only optimization for responseForSingleElement (#396) * apply trailer only optimization for responseForSingleElement * remove unused import --- .../apache/pekko/grpc/internal/GrpcResponseHelpers.scala | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcResponseHelpers.scala b/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcResponseHelpers.scala index 75cb3e2b..848fc629 100644 --- a/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcResponseHelpers.scala +++ b/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcResponseHelpers.scala @@ -24,7 +24,6 @@ import pekko.http.scaladsl.model.HttpEntity.ChunkStreamPart import pekko.http.scaladsl.model.{ HttpEntity, HttpResponse, Trailer } import pekko.stream.Materializer import pekko.stream.scaladsl.Source -import pekko.util.ByteString import io.grpc.Status import scala.collection.immutable @@ -60,12 +59,7 @@ object GrpcResponseHelpers { val responseHeaders = headers.`Message-Encoding`(writer.messageEncoding.name) :: Nil try writer.encodeDataToResponse(m.serialize(e), responseHeaders, TrailerOkAttribute) catch { - case NonFatal(ex) => - val trailers = GrpcEntityHelpers.handleException(ex, eHandler) - writer.encodeDataToResponse( - ByteString.empty, - responseHeaders, - Trailer(GrpcEntityHelpers.trailer(trailers.status, trailers.metadata).trailers)) + case NonFatal(ex) => status(GrpcEntityHelpers.handleException(ex, eHandler)) } }