From c5f95e4d1d2027839e888b0c2b5bbed2b46779d2 Mon Sep 17 00:00:00 2001 From: Ian Bennett Date: Thu, 23 Jul 2020 23:29:34 +0000 Subject: [PATCH] finagle-core: introduce new type-safe ReqRep variant Problem `ReqRep` is not type-safe. For most scenarios, `ReqRep` can be type-safe. Solution Introduce a generic, type-safe `ReqRepT` and modify the existing `ReqRep` to be compatible. This means that `ReqRepT` is itself a `ReqRep` and can be used as a drop-in replacement where type-safety is allowed. JIRA Issues: CSL-10019 Differential Revision: https://phabricator.twitter.biz/D520027 --- .../com/twitter/scrooge/test/gold/thriftjava/GoldService.java | 2 +- .../twitter/scrooge/test/gold/thriftjava/PlatinumService.java | 2 +- .../src/main/resources/apachejavagen/service.mustache | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scrooge-generator-tests/src/test/resources/gold_file_output_java/com/twitter/scrooge/test/gold/thriftjava/GoldService.java b/scrooge-generator-tests/src/test/resources/gold_file_output_java/com/twitter/scrooge/test/gold/thriftjava/GoldService.java index 38e0daa99..889b2de78 100644 --- a/scrooge-generator-tests/src/test/resources/gold_file_output_java/com/twitter/scrooge/test/gold/thriftjava/GoldService.java +++ b/scrooge-generator-tests/src/test/resources/gold_file_output_java/com/twitter/scrooge/test/gold/thriftjava/GoldService.java @@ -706,7 +706,7 @@ public Future apply(noExceptionCall_args args) { private void setReqRepContext(Object req, com.twitter.util.Try rep) { scala.Option serdeCtx = com.twitter.finagle.context.Contexts.local().get(ServerToReqRep.Key()); if (serdeCtx.nonEmpty()) { - serdeCtx.get().setReqRep(new com.twitter.finagle.service.ReqRep(req, rep)); + serdeCtx.get().setReqRep(com.twitter.finagle.service.ReqRep.apply(req, rep)); } } diff --git a/scrooge-generator-tests/src/test/resources/gold_file_output_java/com/twitter/scrooge/test/gold/thriftjava/PlatinumService.java b/scrooge-generator-tests/src/test/resources/gold_file_output_java/com/twitter/scrooge/test/gold/thriftjava/PlatinumService.java index 32d733325..8cd534956 100644 --- a/scrooge-generator-tests/src/test/resources/gold_file_output_java/com/twitter/scrooge/test/gold/thriftjava/PlatinumService.java +++ b/scrooge-generator-tests/src/test/resources/gold_file_output_java/com/twitter/scrooge/test/gold/thriftjava/PlatinumService.java @@ -471,7 +471,7 @@ public Future apply(moreCoolThings_args args) { private void setReqRepContext(Object req, com.twitter.util.Try rep) { scala.Option serdeCtx = com.twitter.finagle.context.Contexts.local().get(ServerToReqRep.Key()); if (serdeCtx.nonEmpty()) { - serdeCtx.get().setReqRep(new com.twitter.finagle.service.ReqRep(req, rep)); + serdeCtx.get().setReqRep(com.twitter.finagle.service.ReqRep.apply(req, rep)); } } diff --git a/scrooge-generator/src/main/resources/apachejavagen/service.mustache b/scrooge-generator/src/main/resources/apachejavagen/service.mustache index 36a2e03da..401b847e2 100644 --- a/scrooge-generator/src/main/resources/apachejavagen/service.mustache +++ b/scrooge-generator/src/main/resources/apachejavagen/service.mustache @@ -616,7 +616,7 @@ public class {{name}} { private void setReqRepContext(Object req, com.twitter.util.Try rep) { scala.Option serdeCtx = com.twitter.finagle.context.Contexts.local().get(ServerToReqRep.Key()); if (serdeCtx.nonEmpty()) { - serdeCtx.get().setReqRep(new com.twitter.finagle.service.ReqRep(req, rep)); + serdeCtx.get().setReqRep(com.twitter.finagle.service.ReqRep.apply(req, rep)); } }