File tree Expand file tree Collapse file tree
benchmarks/src/jmh/java/io/grpc
core/src/main/java/io/grpc Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3131
3232package io .grpc ;
3333
34- import io .grpc .internal . GrpcUtil ;
34+ import static io .grpc .DecompressorRegistry . ACCEPT_ENCODING_JOINER ;
3535
3636import org .openjdk .jmh .annotations .Benchmark ;
3737import org .openjdk .jmh .annotations .BenchmarkMode ;
@@ -87,7 +87,7 @@ public InputStream decompress(InputStream is) throws IOException {
8787 @ OutputTimeUnit (TimeUnit .NANOSECONDS )
8888 public String dynamicAcceptEncoding () {
8989 if (!reg .getAdvertisedMessageEncodings ().isEmpty ()) {
90- return GrpcUtil . ACCEPT_ENCODING_JOINER .join (reg .getAdvertisedMessageEncodings ());
90+ return ACCEPT_ENCODING_JOINER .join (reg .getAdvertisedMessageEncodings ());
9191 }
9292 return "" ;
9393 }
Original file line number Diff line number Diff line change 3333
3434import static com .google .common .base .Preconditions .checkArgument ;
3535import static com .google .common .base .Preconditions .checkNotNull ;
36- import static io .grpc .internal .GrpcUtil .ACCEPT_ENCODING_JOINER ;
36+
37+ import com .google .common .base .Joiner ;
3738
3839import java .util .Collections ;
3940import java .util .HashSet ;
5152@ ExperimentalApi ("https://github.com/grpc/grpc-java/issues/1704" )
5253@ ThreadSafe
5354public final class DecompressorRegistry {
55+ static final Joiner ACCEPT_ENCODING_JOINER = Joiner .on (',' );
56+
5457 public static DecompressorRegistry emptyInstance () {
5558 return new DecompressorRegistry ();
5659 }
Original file line number Diff line number Diff line change 3434import static com .google .common .base .Preconditions .checkArgument ;
3535
3636import com .google .common .annotations .VisibleForTesting ;
37- import com .google .common .base .Joiner ;
3837import com .google .common .base .Preconditions ;
3938import com .google .common .base .Splitter ;
4039import com .google .common .collect .ImmutableMap ;
@@ -143,8 +142,6 @@ public final class GrpcUtil {
143142
144143 public static final Splitter ACCEPT_ENCODING_SPLITER = Splitter .on (',' ).trimResults ();
145144
146- public static final Joiner ACCEPT_ENCODING_JOINER = Joiner .on (',' );
147-
148145 private static final String IMPLEMENTATION_VERION = getImplementationVersion ();
149146
150147 /**
Original file line number Diff line number Diff line change 3434import static com .google .common .base .Preconditions .checkArgument ;
3535import static com .google .common .base .Preconditions .checkNotNull ;
3636import static com .google .common .base .Preconditions .checkState ;
37- import static io .grpc .internal .GrpcUtil .ACCEPT_ENCODING_JOINER ;
3837import static io .grpc .internal .GrpcUtil .ACCEPT_ENCODING_SPLITER ;
3938import static io .grpc .internal .GrpcUtil .MESSAGE_ACCEPT_ENCODING_KEY ;
4039import static io .grpc .internal .GrpcUtil .MESSAGE_ENCODING_KEY ;
5857import java .io .IOException ;
5958import java .io .InputStream ;
6059import java .util .List ;
61- import java .util .Set ;
6260
6361final class ServerCallImpl <ReqT , RespT > extends ServerCall <RespT > {
6462 private final ServerStream stream ;
@@ -139,9 +137,9 @@ public void sendHeaders(Metadata headers) {
139137 stream .setCompressor (compressor );
140138
141139 headers .removeAll (MESSAGE_ACCEPT_ENCODING_KEY );
142- Set < String > acceptEncodings = decompressorRegistry .getAdvertisedMessageEncodings ();
143- if (!acceptEncodings .isEmpty ()) {
144- headers .put (MESSAGE_ACCEPT_ENCODING_KEY , ACCEPT_ENCODING_JOINER . join ( acceptEncodings ) );
140+ String advertisedEncodings = decompressorRegistry .getRawAdvertisedMessageEncodings ();
141+ if (!advertisedEncodings .isEmpty ()) {
142+ headers .put (MESSAGE_ACCEPT_ENCODING_KEY , advertisedEncodings );
145143 }
146144
147145 // Don't check if sendMessage has been called, since it requires that sendHeaders was already
You can’t perform that action at this time.
0 commit comments