@@ -71,6 +71,9 @@ final class ByteBufferBsonOutputTest {
7171 range (1 , MIN_HIGH_SURROGATE ).boxed (),
7272 rangeClosed (MAX_LOW_SURROGATE + 1 , MAX_CODE_POINT ).boxed ())
7373 .collect (toList ());
74+ private static final List <Integer > ALL_SURROGATE_CODE_POINTS = Stream .concat (
75+ range (MIN_LOW_SURROGATE , MAX_LOW_SURROGATE ).boxed (),
76+ range (MIN_HIGH_SURROGATE , MAX_HIGH_SURROGATE ).boxed ()).collect (toList ());
7477
7578 static Stream <BufferProvider > bufferProviders () {
7679 return Stream .of (
@@ -807,11 +810,7 @@ void shouldWriteStringAcrossBuffersUTF8WithBranch(final BufferProvider bufferPro
807810 @ ParameterizedTest
808811 @ MethodSource ("com.mongodb.internal.connection.ByteBufferBsonOutputTest#bufferProviders" )
809812 void shouldWriteCStringWithMalformedSurrogates (final BufferProvider bufferProvider ) throws IOException {
810- Stream <Integer > surrogates = Stream .concat (
811- range (MIN_LOW_SURROGATE , Character .MAX_LOW_SURROGATE ).boxed (),
812- range (Character .MIN_HIGH_SURROGATE , MAX_HIGH_SURROGATE ).boxed ());
813-
814- for (Integer surrogateCodePoint : surrogates .collect (toList ())) {
813+ for (Integer surrogateCodePoint : ALL_SURROGATE_CODE_POINTS ) {
815814 byte [] expectedEncoding = new byte []{
816815 (byte ) (0xE0 | ((surrogateCodePoint >> 12 ) & 0x0F )),
817816 (byte ) (0x80 | ((surrogateCodePoint >> 6 ) & 0x3F )),
@@ -838,11 +837,7 @@ void shouldWriteCStringWithMalformedSurrogates(final BufferProvider bufferProvid
838837 @ ParameterizedTest
839838 @ MethodSource ("com.mongodb.internal.connection.ByteBufferBsonOutputTest#bufferProviders" )
840839 void shouldWriteCStringWithMalformedSurrogatesWithBranch (final BufferProvider bufferProvider ) throws IOException {
841- Stream <Integer > surrogates = Stream .concat (
842- range (MIN_LOW_SURROGATE , Character .MAX_LOW_SURROGATE ).boxed (),
843- range (Character .MIN_HIGH_SURROGATE , MAX_HIGH_SURROGATE ).boxed ());
844-
845- for (Integer surrogateCodePoint : surrogates .collect (toList ())) {
840+ for (Integer surrogateCodePoint : ALL_SURROGATE_CODE_POINTS ) {
846841 byte [] expectedEncoding = new byte []{
847842 (byte ) (0xE0 | ((surrogateCodePoint >> 12 ) & 0x0F )),
848843 (byte ) (0x80 | ((surrogateCodePoint >> 6 ) & 0x3F )),
@@ -869,11 +864,7 @@ void shouldWriteCStringWithMalformedSurrogatesWithBranch(final BufferProvider bu
869864 @ ParameterizedTest
870865 @ MethodSource ("com.mongodb.internal.connection.ByteBufferBsonOutputTest#bufferProviders" )
871866 void shouldWriteStringWithMalformedSurrogates (final BufferProvider bufferProvider ) throws IOException {
872- Stream <Integer > surrogates = Stream .concat (
873- range (MIN_LOW_SURROGATE , Character .MAX_LOW_SURROGATE ).boxed (),
874- range (Character .MIN_HIGH_SURROGATE , MAX_HIGH_SURROGATE ).boxed ());
875-
876- for (Integer surrogateCodePoint : surrogates .collect (toList ())) {
867+ for (Integer surrogateCodePoint : ALL_SURROGATE_CODE_POINTS ) {
877868 byte [] expectedEncoding = new byte []{
878869 (byte ) (0xE0 | ((surrogateCodePoint >> 12 ) & 0x0F )),
879870 (byte ) (0x80 | ((surrogateCodePoint >> 6 ) & 0x3F )),
@@ -900,11 +891,7 @@ void shouldWriteStringWithMalformedSurrogates(final BufferProvider bufferProvide
900891 @ ParameterizedTest
901892 @ MethodSource ("com.mongodb.internal.connection.ByteBufferBsonOutputTest#bufferProviders" )
902893 void shouldWriteStringWithMalformedSurrogatesWithBranch (final BufferProvider bufferProvider ) throws IOException {
903- Stream <Integer > surrogates = Stream .concat (
904- range (MIN_LOW_SURROGATE , Character .MAX_LOW_SURROGATE ).boxed (),
905- range (Character .MIN_HIGH_SURROGATE , MAX_HIGH_SURROGATE ).boxed ());
906-
907- for (Integer surrogateCodePoint : surrogates .collect (toList ())) {
894+ for (Integer surrogateCodePoint : ALL_SURROGATE_CODE_POINTS ) {
908895 byte [] expectedEncoding = new byte []{
909896 (byte ) (0xE0 | ((surrogateCodePoint >> 12 ) & 0x0F )),
910897 (byte ) (0x80 | ((surrogateCodePoint >> 6 ) & 0x3F )),
0 commit comments