diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java index 0d51c2af18df4f0f7d9d84159c50415f14e5c2e2..425c11576c8c8da06e523b43f557fb732d8e284f 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/StreamConverter.java @@ -29,7 +29,7 @@ import org.springframework.core.convert.converter.ConditionalGenericConverter; import org.springframework.lang.UsesJava8; /** - * Convert a {@link Stream} to an from a collection or array, converting the + * Converts a {@link Stream} to and from a collection or array, converting the * element type if necessary. * * @author Stephane Nicoll @@ -77,7 +77,7 @@ public class StreamConverter implements ConditionalGenericConverter { /** * Validate that the specified {@code sourceType} can be converted to a {@link Collection} of - * type type of the stream elements + * the type of the stream elements. * @param elementType the type of the stream elements * @param sourceType the type to convert from */ diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java index bb1c205cd555e58c228fb761146b562840f0905a..6b09204e84119e28cc4e2bca924f3a4d6bb357c0 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java @@ -34,20 +34,23 @@ import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.core.Is.is; import static org.junit.Assert.*; +/** + * Tests for {@link StreamConverter}. + * + * @author Stephane Nicoll + * @since 4.2 + */ public class StreamConverterTests { @Rule public final ExpectedException thrown = ExpectedException.none(); - private GenericConversionService conversionService; + private final GenericConversionService conversionService = new GenericConversionService(); - private StreamConverter streamConverter; + private final StreamConverter streamConverter = new StreamConverter(this.conversionService); @Before public void setup() { - this.conversionService = new GenericConversionService(); - this.streamConverter = new StreamConverter(this.conversionService); - this.conversionService.addConverter(new CollectionToCollectionConverter(this.conversionService)); this.conversionService.addConverter(new ArrayToCollectionConverter(this.conversionService)); this.conversionService.addConverter(new CollectionToArrayConverter(this.conversionService)); @@ -111,6 +114,7 @@ public class StreamConverterTests { } @Test + @SuppressWarnings("resource") public void convertFromListToStream() throws NoSuchFieldException { this.conversionService.addConverterFactory(new StringToNumberConverterFactory()); List stream = Arrays.asList("1", "2", "3"); @@ -124,6 +128,7 @@ public class StreamConverterTests { } @Test + @SuppressWarnings("resource") public void convertFromArrayToStream() throws NoSuchFieldException { Integer[] stream = new Integer[] {1, 0, 1}; this.conversionService.addConverter(new Converter() { @@ -142,6 +147,7 @@ public class StreamConverterTests { } @Test + @SuppressWarnings("resource") public void convertFromListToRawStream() throws NoSuchFieldException { List stream = Arrays.asList("1", "2", "3"); TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("rawStream")); ; @@ -169,7 +175,7 @@ public class StreamConverterTests { new TypeDescriptor(Types.class.getField("arrayOfLongs"))); } - @SuppressWarnings("unused") + @SuppressWarnings({ "rawtypes" }) static class Types { public List listOfStrings;