Skip to content

Commit

Permalink
Fix some raw types
Browse files Browse the repository at this point in the history
  • Loading branch information
marschall committed Mar 13, 2021
1 parent 3fbfbb9 commit 35ae907
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 29 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -209,7 +210,7 @@ public JobParameter deserialize(JsonParser parser, DeserializationContext contex
* @param trustedClassNames array of fully qualified trusted class names
*/
private static TypeResolverBuilder<? extends TypeResolverBuilder> createTrustedDefaultTyping(String[] trustedClassNames) {
TypeResolverBuilder<? extends TypeResolverBuilder> result = new TrustedTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL, trustedClassNames);
TypeResolverBuilder<StdTypeResolverBuilder> result = new TrustedTypeResolverBuilder(ObjectMapper.DefaultTyping.NON_FINAL, trustedClassNames);
result = result.init(JsonTypeInfo.Id.CLASS, null);
result = result.inclusion(JsonTypeInfo.As.PROPERTY);
return result;
Expand Down Expand Up @@ -253,7 +254,7 @@ protected TypeIdResolver idResolver(MapperConfig<?> config,
* mappings.
*/
static class TrustedTypeIdResolver implements TypeIdResolver {
private static final Set<String> TRUSTED_CLASS_NAMES = Collections.unmodifiableSet(new HashSet(Arrays.asList(
private static final Set<String> TRUSTED_CLASS_NAMES = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"java.util.ArrayList",
"java.util.Arrays$ArrayList",
"java.util.LinkedList",
Expand Down
@@ -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.
Expand Down Expand Up @@ -195,7 +195,7 @@ protected Tasklet createTasklet() {
* @return this for fluent chaining
*/
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "rawtypes" })
public SimpleStepBuilder<I, O> listener(Object listener) {
super.listener(listener);

Expand Down
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
@@ -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.
Expand Down Expand Up @@ -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<Integer, String> skipListener = mock(SkipListener.class);
Expand Down
@@ -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.
Expand Down Expand Up @@ -60,7 +60,7 @@
public class MySQLJdbcJobRepositoryTests {

@ClassRule
public static MySQLContainer mysql = new MySQLContainer<>();
public static MySQLContainer<?> mysql = new MySQLContainer<>();

@Autowired
private DataSource dataSource;
Expand Down
@@ -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.
Expand Down Expand Up @@ -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));
Expand Down
@@ -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.
Expand Down Expand Up @@ -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<? extends T> items) throws Exception {

Expand Down
Expand Up @@ -114,7 +114,7 @@ public void shouldFailWitNoOutput() {
@Test(expected = IllegalArgumentException.class)
public void shouldFailWitNoType() {

new AvroItemWriterBuilder()
new AvroItemWriterBuilder<>()
.resource(output)
.schema(schemaResource)
.build();
Expand Down
@@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<BasicMongoPersistentEntity<?>, MongoPersistentProperty> mappingContext = new MongoMappingContext();
MappingMongoConverter mongoConverter = spy(new MappingMongoConverter(this.dbRefResolver, mappingContext));
when(this.template.getConverter()).thenReturn(mongoConverter);

Expand Down Expand Up @@ -302,7 +304,6 @@ public void testRemoveNoTransactionWithCollection() throws Exception {
@Test
public void testResourceKeyCollision() throws Exception {
final int limit = 5000;
@SuppressWarnings("unchecked")
List<MongoItemWriter<String>> writers = new ArrayList<>(limit);
final String[] documents = new String[limit];
final String[] results = new String[limit];
Expand Down
@@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<BasicMongoPersistentEntity<?>, MongoPersistentProperty> mappingContext = new MongoMappingContext();
mongoConverter = spy(new MappingMongoConverter(this.dbRefResolver, mappingContext));
when(this.template.getConverter()).thenReturn(mongoConverter);

Expand Down
@@ -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.
Expand Down Expand Up @@ -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<Map<String, Object>> mapWriter = new JdbcBatchItemWriter<>();
Expand Down
@@ -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.
Expand Down Expand Up @@ -377,7 +377,7 @@ public void testReadFromSinglePartitionAfterRestart() throws ExecutionException,

@Test
public void testReadFromMultiplePartitionsAfterRestart() throws ExecutionException, InterruptedException {
List<ListenableFuture> futures = new ArrayList<>();
List<ListenableFuture<SendResult<String, String>>> 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"));
Expand All @@ -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();
}

Expand Down
@@ -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;
Expand Down Expand Up @@ -34,7 +50,6 @@
* @author Michael Minella
*
*/
@SuppressWarnings("raw")
public class MessageChannelPartitionHandlerTests {

private MessageChannelPartitionHandler messageChannelPartitionHandler;
Expand Down

0 comments on commit 35ae907

Please sign in to comment.