6060import java .io .InputStream ;
6161import java .net .SocketAddress ;
6262import java .net .URI ;
63+ import java .nio .charset .StandardCharsets ;
6364import java .util .Collection ;
6465import java .util .Collections ;
6566import java .util .Optional ;
@@ -106,7 +107,7 @@ public class ExternalProcessorFilterTest {
106107 private static class StringMarshaller implements MethodDescriptor .Marshaller <String > {
107108 @ Override
108109 public InputStream stream (String value ) {
109- return new ByteArrayInputStream (value .getBytes ());
110+ return new ByteArrayInputStream (value .getBytes (StandardCharsets . UTF_8 ));
110111 }
111112
112113 @ Override
@@ -119,7 +120,7 @@ public String parse(InputStream stream) {
119120 buffer .write (data , 0 , nRead );
120121 }
121122 buffer .flush ();
122- return new String (buffer .toByteArray ());
123+ return new String (buffer .toByteArray (), StandardCharsets . UTF_8 );
123124 } catch (IOException e ) {
124125 throw new RuntimeException (e );
125126 }
@@ -641,7 +642,7 @@ public void givenRequestBodyModeGrpc_whenExtProcRespondsWithMutatedBody_thenMuta
641642
642643 ArgumentCaptor <InputStream > bodyCaptor = ArgumentCaptor .forClass (InputStream .class );
643644 Mockito .verify (mockRawCall ).sendMessage (bodyCaptor .capture ());
644- assertThat (new String (com .google .common .io .ByteStreams .toByteArray (bodyCaptor .getValue ()))).isEqualTo ("Mutated" );
645+ assertThat (new String (com .google .common .io .ByteStreams .toByteArray (bodyCaptor .getValue ()), StandardCharsets . UTF_8 )).isEqualTo ("Mutated" );
645646 }
646647
647648 @ Test
@@ -855,7 +856,7 @@ public void givenResponseBodyModeGrpc_whenOnMessageCalled_thenMessageIsSentToExt
855856
856857 Mockito .verify (mockRawCall ).start (rawListenerCaptor .capture (), Mockito .any ());
857858
858- rawListenerCaptor .getValue ().onMessage (new ByteArrayInputStream ("Server Message" .getBytes ()));
859+ rawListenerCaptor .getValue ().onMessage (new ByteArrayInputStream ("Server Message" .getBytes (StandardCharsets . UTF_8 )));
859860
860861 ArgumentCaptor <ProcessingRequest > requestCaptor = ArgumentCaptor .forClass (ProcessingRequest .class );
861862 Mockito .verify (mockSidecarCall ).sendMessage (requestCaptor .capture ());
@@ -909,7 +910,7 @@ public void givenResponseBodyModeGrpc_whenExtProcRespondsWithMutatedBody_thenMut
909910 Mockito .verify (mockRawCall ).start (rawListenerCaptor .capture (), Mockito .any ());
910911 Mockito .verify (mockSidecarCall ).start (sidecarListenerCaptor .capture (), Mockito .any ());
911912
912- rawListenerCaptor .getValue ().onMessage (new ByteArrayInputStream ("Original" .getBytes ()));
913+ rawListenerCaptor .getValue ().onMessage (new ByteArrayInputStream ("Original" .getBytes (StandardCharsets . UTF_8 )));
913914
914915 ProcessingResponse resp = ProcessingResponse .newBuilder ()
915916 .setResponseBody (BodyResponse .newBuilder ()
@@ -1673,7 +1674,7 @@ public void givenUnsupportedCompressionInResponse_whenReceived_thenExtProcStream
16731674 public void givenFilter_whenClosed_thenCachedChannelManagerIsClosed () throws Exception {
16741675 CachedChannelManager mockChannelManager = Mockito .mock (CachedChannelManager .class );
16751676
1676- ExternalProcessorFilter filter = new ExternalProcessorFilter ("test" , mockChannelManager , scheduler );
1677+ ExternalProcessorFilter filter = new ExternalProcessorFilter ("test" , mockChannelManager );
16771678
16781679 filter .close ();
16791680
0 commit comments