From 35ae90778df64284c1472fda8b52ce560e5ef7af Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Sun, 15 Nov 2020 14:01:04 +0100 Subject: [PATCH] Fix some raw types --- ...ackson2ExecutionContextStringSerializer.java | 5 +++-- .../step/builder/FaultTolerantStepBuilder.java | 4 ++-- .../support/DefaultJobLoaderTests.java | 10 +++++----- ...olerantStepFactoryBeanNonBufferingTests.java | 3 +-- .../repository/MySQLJdbcJobRepositoryTests.java | 4 ++-- .../ExtendedConnectionDataSourceProxy.java | 3 +-- .../item/database/JdbcBatchItemWriter.java | 4 ++-- .../builder/AvroItemWriterBuilderTests.java | 2 +- .../batch/item/data/MongoItemWriterTests.java | 7 ++++--- .../builder/MongoItemWriterBuilderTests.java | 6 ++++-- .../JdbcBatchItemWriterNamedParameterTests.java | 4 ++-- .../batch/item/kafka/KafkaItemReaderTests.java | 6 +++--- .../MessageChannelPartitionHandlerTests.java | 17 ++++++++++++++++- 13 files changed, 46 insertions(+), 29 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializer.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializer.java index 6fb8a8005e..273a5b2f65 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializer.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/Jackson2ExecutionContextStringSerializer.java @@ -48,6 +48,7 @@ import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator; import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; import com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder; +import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder; import com.fasterxml.jackson.databind.module.SimpleModule; import org.springframework.batch.core.JobParameter; @@ -209,7 +210,7 @@ public JobParameter deserialize(JsonParser parser, DeserializationContext contex * @param trustedClassNames array of fully qualified trusted class names */ private static TypeResolverBuilder createTrustedDefaultTyping(String[] trustedClassNames) { - TypeResolverBuilder result = new TrustedTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL, trustedClassNames); + TypeResolverBuilder result = new TrustedTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL, trustedClassNames); result = result.init(JsonTypeInfo.Id.CLASS, null); result = result.inclusion(JsonTypeInfo.As.PROPERTY); return result; @@ -253,7 +254,7 @@ protected TypeIdResolver idResolver(MapperConfig config, * mappings. */ static class TrustedTypeIdResolver implements TypeIdResolver { - private static final Set TRUSTED_CLASS_NAMES = Collections.unmodifiableSet(new HashSet(Arrays.asList( + private static final Set TRUSTED_CLASS_NAMES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList( "java.util.ArrayList", "java.util.Arrays$ArrayList", "java.util.LinkedList", diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java index be7fad7388..c7bc000025 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/builder/FaultTolerantStepBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -195,7 +195,7 @@ protected Tasklet createTasklet() { * @return this for fluent chaining */ @Override - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) public SimpleStepBuilder listener(Object listener) { super.listener(listener); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultJobLoaderTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultJobLoaderTests.java index 04b6126e76..45eea2529d 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultJobLoaderTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/configuration/support/DefaultJobLoaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,11 +66,11 @@ public void testClear() throws Exception { GenericApplicationContextFactory factory = new GenericApplicationContextFactory(new ByteArrayResource( JOB_XML.getBytes())); jobLoader.load(factory); - assertEquals(1, ((Map) ReflectionTestUtils.getField(jobLoader, "contexts")).size()); - assertEquals(1, ((Map) ReflectionTestUtils.getField(jobLoader, "contextToJobNames")).size()); + assertEquals(1, ((Map) ReflectionTestUtils.getField(jobLoader, "contexts")).size()); + assertEquals(1, ((Map) ReflectionTestUtils.getField(jobLoader, "contextToJobNames")).size()); jobLoader.clear(); - assertEquals(0, ((Map) ReflectionTestUtils.getField(jobLoader, "contexts")).size()); - assertEquals(0, ((Map) ReflectionTestUtils.getField(jobLoader, "contextToJobNames")).size()); + assertEquals(0, ((Map) ReflectionTestUtils.getField(jobLoader, "contexts")).size()); + assertEquals(0, ((Map) ReflectionTestUtils.getField(jobLoader, "contextToJobNames")).size()); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java index d0eade3308..b7485aeaf7 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/FaultTolerantStepFactoryBeanNonBufferingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,6 @@ public void setUp() throws Exception { * Check items causing errors are skipped as expected. */ @Test - @SuppressWarnings("rawtypes") public void testSkip() throws Exception { @SuppressWarnings("unchecked") SkipListener skipListener = mock(SkipListener.class); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/test/repository/MySQLJdbcJobRepositoryTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/test/repository/MySQLJdbcJobRepositoryTests.java index de0b45372c..cb02bb869c 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/test/repository/MySQLJdbcJobRepositoryTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/test/repository/MySQLJdbcJobRepositoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 the original author or authors. + * Copyright 2020-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ public class MySQLJdbcJobRepositoryTests { @ClassRule - public static MySQLContainer mysql = new MySQLContainer<>(); + public static MySQLContainer mysql = new MySQLContainer<>(); @Autowired private DataSource dataSource; diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java index 8e97b8ef66..8ad3fbf5be 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/ExtendedConnectionDataSourceProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -237,7 +237,6 @@ public void setLoginTimeout(int seconds) throws SQLException { * @param target the original Connection to wrap * @return the wrapped Connection */ - @SuppressWarnings("rawtypes") protected Connection getCloseSuppressingConnectionProxy(Connection target) { return (Connection) Proxy.newProxyInstance(ConnectionProxy.class.getClassLoader(), new Class[] { ConnectionProxy.class }, new CloseSuppressingInvocationHandler(target, this)); diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java index 0d70214c19..7ca7e1730b 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/JdbcBatchItemWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2019 the original author or authors. + * Copyright 2006-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -158,7 +158,7 @@ public void afterPropertiesSet() { /* (non-Javadoc) * @see org.springframework.batch.item.ItemWriter#write(java.util.List) */ - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings("unchecked") @Override public void write(final List items) throws Exception { diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemWriterBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemWriterBuilderTests.java index f158a2b433..bd30682fcc 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemWriterBuilderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/avro/builder/AvroItemWriterBuilderTests.java @@ -114,7 +114,7 @@ public void shouldFailWitNoOutput() { @Test(expected = IllegalArgumentException.class) public void shouldFailWitNoType() { - new AvroItemWriterBuilder() + new AvroItemWriterBuilder<>() .resource(output) .schema(schemaResource) .build(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemWriterTests.java index d2565ea214..4cbb0e9e39 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemWriterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/MongoItemWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2020 the original author or authors. + * Copyright 2013-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,9 @@ import org.springframework.data.mongodb.core.convert.DbRefResolver; import org.springframework.data.mongodb.core.convert.MappingMongoConverter; import org.springframework.data.mongodb.core.convert.MongoConverter; +import org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity; import org.springframework.data.mongodb.core.mapping.MongoMappingContext; +import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty; import org.springframework.data.mongodb.core.query.Query; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.support.TransactionCallback; @@ -76,7 +78,7 @@ public void setUp() throws Exception { when(this.template.bulkOps(any(), anyString())).thenReturn(this.bulkOperations); when(this.template.bulkOps(any(), any(Class.class))).thenReturn(this.bulkOperations); - MappingContext mappingContext = new MongoMappingContext(); + MappingContext, MongoPersistentProperty> mappingContext = new MongoMappingContext(); MappingMongoConverter mongoConverter = spy(new MappingMongoConverter(this.dbRefResolver, mappingContext)); when(this.template.getConverter()).thenReturn(mongoConverter); @@ -302,7 +304,6 @@ public void testRemoveNoTransactionWithCollection() throws Exception { @Test public void testResourceKeyCollision() throws Exception { final int limit = 5000; - @SuppressWarnings("unchecked") List> writers = new ArrayList<>(limit); final String[] documents = new String[limit]; final String[] results = new String[limit]; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/builder/MongoItemWriterBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/builder/MongoItemWriterBuilderTests.java index 534090c7d6..c676ef8e5d 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/builder/MongoItemWriterBuilderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/builder/MongoItemWriterBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 the original author or authors. + * Copyright 2017-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,9 @@ import org.springframework.data.mongodb.core.convert.DbRefResolver; import org.springframework.data.mongodb.core.convert.MappingMongoConverter; import org.springframework.data.mongodb.core.convert.MongoConverter; +import org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity; import org.springframework.data.mongodb.core.mapping.MongoMappingContext; +import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty; import org.springframework.data.mongodb.core.query.Query; import static org.junit.Assert.assertEquals; @@ -69,7 +71,7 @@ public void setUp() throws Exception { when(this.template.bulkOps(any(), anyString())).thenReturn(this.bulkOperations); when(this.template.bulkOps(any(), any(Class.class))).thenReturn(this.bulkOperations); - MappingContext mappingContext = new MongoMappingContext(); + MappingContext, MongoPersistentProperty> mappingContext = new MongoMappingContext(); mongoConverter = spy(new MappingMongoConverter(this.dbRefResolver, mappingContext)); when(this.template.getConverter()).thenReturn(mongoConverter); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterNamedParameterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterNamedParameterTests.java index 7e14337c3e..4f7cdfd099 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterNamedParameterTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcBatchItemWriterNamedParameterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2008 the original author or authors. + * Copyright 2006-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -152,7 +152,7 @@ public void testWriteAndFlushMap() throws Exception { assertEquals("bar", results.get("foo")); } - @SuppressWarnings({ "rawtypes", "serial", "unchecked" }) + @SuppressWarnings( "serial" ) @Test public void testWriteAndFlushMapWithItemSqlParameterSourceProvider() throws Exception { JdbcBatchItemWriter> mapWriter = new JdbcBatchItemWriter<>(); diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/kafka/KafkaItemReaderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/kafka/KafkaItemReaderTests.java index b232b617ae..78f3026c2a 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/kafka/KafkaItemReaderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/kafka/KafkaItemReaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2020 the original author or authors. + * Copyright 2019-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -377,7 +377,7 @@ public void testReadFromSinglePartitionAfterRestart() throws ExecutionException, @Test public void testReadFromMultiplePartitionsAfterRestart() throws ExecutionException, InterruptedException { - List futures = new ArrayList<>(); + List>> futures = new ArrayList<>(); futures.add(this.template.send("topic4", 0, null, "val0")); futures.add(this.template.send("topic4", 0, null, "val2")); futures.add(this.template.send("topic4", 0, null, "val4")); @@ -387,7 +387,7 @@ public void testReadFromMultiplePartitionsAfterRestart() throws ExecutionExcepti futures.add(this.template.send("topic4", 1, null, "val5")); futures.add(this.template.send("topic4", 1, null, "val7")); - for (ListenableFuture future : futures) { + for (ListenableFuture future : futures) { future.get(); } diff --git a/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/MessageChannelPartitionHandlerTests.java b/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/MessageChannelPartitionHandlerTests.java index fd9170412f..ba147720a0 100644 --- a/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/MessageChannelPartitionHandlerTests.java +++ b/spring-batch-integration/src/test/java/org/springframework/batch/integration/partition/MessageChannelPartitionHandlerTests.java @@ -1,3 +1,19 @@ +/* + * Copyright 2020-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.batch.integration.partition; import java.util.Collection; @@ -34,7 +50,6 @@ * @author Michael Minella * */ -@SuppressWarnings("raw") public class MessageChannelPartitionHandlerTests { private MessageChannelPartitionHandler messageChannelPartitionHandler;