Skip to content

Commit d78a0ea

Browse files
garyrussellartembilan
authored andcommitted
Fix deprecations and warnings
1 parent 2ace8bf commit d78a0ea

File tree

8 files changed

+50
-49
lines changed

8 files changed

+50
-49
lines changed

spring-kafka/src/main/java/org/springframework/kafka/annotation/KafkaListenerAnnotationBeanPostProcessor.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
import org.springframework.messaging.handler.annotation.support.HeadersMethodArgumentResolver;
8383
import org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory;
8484
import org.springframework.messaging.handler.annotation.support.MessageMethodArgumentResolver;
85-
import org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver;
85+
import org.springframework.messaging.handler.annotation.support.PayloadMethodArgumentResolver;
8686
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver;
8787
import org.springframework.messaging.handler.invocation.InvocableHandlerMethod;
8888
import org.springframework.util.Assert;
@@ -194,7 +194,7 @@ public void setDefaultContainerFactoryBeanName(String containerFactoryBeanName)
194194
* @param messageHandlerMethodFactory the {@link MessageHandlerMethodFactory} instance.
195195
*/
196196
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory messageHandlerMethodFactory) {
197-
this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(messageHandlerMethodFactory);
197+
this.messageHandlerMethodFactory.setHandlerMethodFactory(messageHandlerMethodFactory);
198198
}
199199

200200
/**
@@ -254,7 +254,7 @@ public void afterSingletonsInstantiated() {
254254
// Set the custom handler method factory once resolved by the configurer
255255
MessageHandlerMethodFactory handlerMethodFactory = this.registrar.getMessageHandlerMethodFactory();
256256
if (handlerMethodFactory != null) {
257-
this.messageHandlerMethodFactory.setMessageHandlerMethodFactory(handlerMethodFactory);
257+
this.messageHandlerMethodFactory.setHandlerMethodFactory(handlerMethodFactory);
258258
}
259259
else {
260260
addFormatters(this.messageHandlerMethodFactory.defaultFormattingConversionService);
@@ -385,7 +385,8 @@ private Method checkProxy(Method methodArg, Object bean) {
385385
method = iface.getMethod(method.getName(), method.getParameterTypes());
386386
break;
387387
}
388-
catch (NoSuchMethodException noMethod) {
388+
catch (@SuppressWarnings("unused") NoSuchMethodException noMethod) {
389+
// NOSONAR
389390
}
390391
}
391392
}
@@ -779,22 +780,22 @@ private class KafkaHandlerMethodFactoryAdapter implements MessageHandlerMethodFa
779780
private final DefaultFormattingConversionService defaultFormattingConversionService =
780781
new DefaultFormattingConversionService();
781782

782-
private MessageHandlerMethodFactory messageHandlerMethodFactory;
783+
private MessageHandlerMethodFactory handlerMethodFactory;
783784

784-
public void setMessageHandlerMethodFactory(MessageHandlerMethodFactory kafkaHandlerMethodFactory1) {
785-
this.messageHandlerMethodFactory = kafkaHandlerMethodFactory1;
785+
public void setHandlerMethodFactory(MessageHandlerMethodFactory kafkaHandlerMethodFactory1) {
786+
this.handlerMethodFactory = kafkaHandlerMethodFactory1;
786787
}
787788

788789
@Override
789790
public InvocableHandlerMethod createInvocableHandlerMethod(Object bean, Method method) {
790-
return getMessageHandlerMethodFactory().createInvocableHandlerMethod(bean, method);
791+
return getHandlerMethodFactory().createInvocableHandlerMethod(bean, method);
791792
}
792793

793-
private MessageHandlerMethodFactory getMessageHandlerMethodFactory() {
794-
if (this.messageHandlerMethodFactory == null) {
795-
this.messageHandlerMethodFactory = createDefaultMessageHandlerMethodFactory();
794+
private MessageHandlerMethodFactory getHandlerMethodFactory() {
795+
if (this.handlerMethodFactory == null) {
796+
this.handlerMethodFactory = createDefaultMessageHandlerMethodFactory();
796797
}
797-
return this.messageHandlerMethodFactory;
798+
return this.handlerMethodFactory;
798799
}
799800

800801
private MessageHandlerMethodFactory createDefaultMessageHandlerMethodFactory() {
@@ -893,7 +894,7 @@ public String getConversationId() {
893894

894895
}
895896

896-
private static class KafkaNullAwarePayloadArgumentResolver extends PayloadArgumentResolver {
897+
private static class KafkaNullAwarePayloadArgumentResolver extends PayloadMethodArgumentResolver {
897898

898899
KafkaNullAwarePayloadArgumentResolver(MessageConverter messageConverter, Validator validator) {
899900
super(messageConverter, validator);

spring-kafka/src/main/java/org/springframework/kafka/config/CompositeKafkaStreamsCustomizer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public void customize(KafkaStreams kafkaStreams) {
4646
this.kafkaStreamsCustomizers.forEach(kafkaStreamsCustomizer -> kafkaStreamsCustomizer.customize(kafkaStreams));
4747
}
4848

49-
public void addKafkaStreamsCustomizers(List<KafkaStreamsCustomizer> kafkaStreamsCustomizers) {
50-
this.kafkaStreamsCustomizers.addAll(kafkaStreamsCustomizers);
49+
public void addKafkaStreamsCustomizers(List<KafkaStreamsCustomizer> customizers) {
50+
this.kafkaStreamsCustomizers.addAll(customizers);
5151
}
5252

5353
}

spring-kafka/src/main/java/org/springframework/kafka/config/TopicBuilder.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,43 +48,43 @@ private TopicBuilder(String name) {
4848

4949
/**
5050
* Set the number of partitions (default 1).
51-
* @param partitions the partitions.
51+
* @param partitionCount the partitions.
5252
* @return the builder.
5353
*/
54-
public TopicBuilder partitions(int partitions) {
55-
this.partitions = partitions;
54+
public TopicBuilder partitions(int partitionCount) {
55+
this.partitions = partitionCount;
5656
return this;
5757
}
5858

5959
/**
6060
* Set the number of replicas (default 1).
61-
* @param replicas the replicas (which will be cast to short).
61+
* @param replicaCount the replicas (which will be cast to short).
6262
* @return the builder.
6363
*/
64-
public TopicBuilder replicas(int replicas) {
65-
this.replicas = (short) replicas;
64+
public TopicBuilder replicas(int replicaCount) {
65+
this.replicas = (short) replicaCount;
6666
return this;
6767
}
6868

6969
/**
7070
* Set the replica assignments.
71-
* @param replicasAssignments the assignments.
71+
* @param replicaAssignments the assignments.
7272
* @return the builder.
7373
* @see NewTopic#replicasAssignments()
7474
*/
75-
public TopicBuilder replicasAssignments(Map<Integer, List<Integer>> replicasAssignments) {
76-
this.replicasAssignments = replicasAssignments;
75+
public TopicBuilder replicasAssignments(Map<Integer, List<Integer>> replicaAssignments) {
76+
this.replicasAssignments = replicaAssignments;
7777
return this;
7878
}
7979

8080
/**
8181
* Set the configs.
82-
* @param configs the configs.
82+
* @param configProps the configs.
8383
* @return the builder.
8484
* @see NewTopic#configs()
8585
*/
86-
public TopicBuilder configs(Map<String, String> configs) {
87-
this.configs.putAll(configs);
86+
public TopicBuilder configs(Map<String, String> configProps) {
87+
this.configs.putAll(configProps);
8888
return this;
8989
}
9090

spring-kafka/src/main/java/org/springframework/kafka/core/DefaultKafkaConsumerFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ private KafkaConsumer<K, V> createConsumerWithAdjustedProperties(String groupId,
160160
return createKafkaConsumer(modifiedConfigs);
161161
}
162162

163-
protected KafkaConsumer<K, V> createKafkaConsumer(Map<String, Object> configs) {
164-
return new KafkaConsumer<>(configs, this.keyDeserializer, this.valueDeserializer);
163+
protected KafkaConsumer<K, V> createKafkaConsumer(Map<String, Object> configProps) {
164+
return new KafkaConsumer<>(configProps, this.keyDeserializer, this.valueDeserializer);
165165
}
166166

167167
@Override

spring-kafka/src/main/java/org/springframework/kafka/support/converter/DefaultJackson2JavaTypeMapper.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* @since 2.1
4343
*/
4444
public class DefaultJackson2JavaTypeMapper extends AbstractJavaTypeMapper
45-
implements Jackson2JavaTypeMapper, ClassMapper {
45+
implements Jackson2JavaTypeMapper {
4646

4747
private static final List<String> TRUSTED_PACKAGES =
4848
Arrays.asList(
@@ -73,12 +73,12 @@ public void setTypePrecedence(TypePrecedence typePrecedence) {
7373
/**
7474
* Specify a set of packages to trust during deserialization.
7575
* The asterisk ({@code *}) means trust all.
76-
* @param trustedPackages the trusted Java packages for deserialization
76+
* @param packagesToTrust the trusted Java packages for deserialization
7777
*/
7878
@Override
79-
public void addTrustedPackages(String... trustedPackages) {
80-
if (trustedPackages != null) {
81-
for (String whiteListClass : trustedPackages) {
79+
public void addTrustedPackages(String... packagesToTrust) {
80+
if (packagesToTrust != null) {
81+
for (String whiteListClass : packagesToTrust) {
8282
if ("*".equals(whiteListClass)) {
8383
this.trustedPackages.clear();
8484
break;

spring-kafka/src/main/java/org/springframework/kafka/support/serializer/ErrorHandlingDeserializer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class ErrorHandlingDeserializer<T> implements Deserializer<T> {
5353

5454
private Deserializer<T> delegate;
5555

56-
private boolean isKey;
56+
private boolean isForKey;
5757

5858
public ErrorHandlingDeserializer() {
5959
}
@@ -86,7 +86,7 @@ else if (!isKey && configs.containsKey(VALUE_DESERIALIZER_CLASS)) {
8686
}
8787
Assert.state(this.delegate != null, "No delegate deserializer configured");
8888
this.delegate.configure(configs, isKey);
89-
this.isKey = isKey;
89+
this.isForKey = isKey;
9090
}
9191

9292
@SuppressWarnings("unchecked")
@@ -125,7 +125,7 @@ private T deserializationException(Headers headers, byte[] data, Exception e) {
125125
// We need this container to trick a generic type. It doesn't matter at runtime anyway.
126126
AtomicReference<T> reference =
127127
(AtomicReference<T>) new AtomicReference<>(
128-
new DeserializationException("Failed to deserialize", headers, data, this.isKey, e));
128+
new DeserializationException("Failed to deserialize", headers, data, this.isForKey, e));
129129
return reference.get();
130130
}
131131

spring-kafka/src/main/java/org/springframework/kafka/support/serializer/ErrorHandlingDeserializer2.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public class ErrorHandlingDeserializer2<T> implements Deserializer<T> {
8080

8181
private Deserializer<T> delegate;
8282

83-
private boolean isKey;
83+
private boolean isForKey;
8484

8585
private BiFunction<byte[], Headers, T> failedDeserializationFunction;
8686

@@ -96,8 +96,8 @@ public void setFailedDeserializationFunction(BiFunction<byte[], Headers, T> fail
9696
this.failedDeserializationFunction = failedDeserializationFunction;
9797
}
9898

99-
public boolean isKey() {
100-
return this.isKey;
99+
public boolean isForKey() {
100+
return this.isForKey;
101101
}
102102

103103
/**
@@ -106,8 +106,8 @@ public boolean isKey() {
106106
* @param isKey true for a key deserializer, false otherwise.
107107
* @since 2.2.3
108108
*/
109-
public void setKey(boolean isKey) {
110-
this.isKey = isKey;
109+
public void setForKey(boolean isKey) {
110+
this.isForKey = isKey;
111111
}
112112

113113
/**
@@ -118,7 +118,7 @@ public void setKey(boolean isKey) {
118118
* @since 2.2.3
119119
*/
120120
public ErrorHandlingDeserializer2<T> keyDeserializer(boolean isKey) {
121-
this.isKey = isKey;
121+
this.isForKey = isKey;
122122
return this;
123123
}
124124

@@ -127,7 +127,7 @@ public void configure(Map<String, ?> configs, boolean isKey) {
127127
setupDelegate(configs, isKey ? KEY_DESERIALIZER_CLASS : VALUE_DESERIALIZER_CLASS);
128128
Assert.state(this.delegate != null, "No delegate deserializer configured");
129129
this.delegate.configure(configs, isKey);
130-
this.isKey = isKey;
130+
this.isForKey = isKey;
131131
setupFunction(configs, isKey ? KEY_FUNCTION : VALUE_FUNCTION);
132132
}
133133

@@ -200,15 +200,15 @@ public void close() {
200200

201201
private void deserializationException(Headers headers, byte[] data, Exception e) {
202202
ByteArrayOutputStream stream = new ByteArrayOutputStream();
203-
DeserializationException exception = new DeserializationException("failed to deserialize", data, this.isKey, e);
203+
DeserializationException exception = new DeserializationException("failed to deserialize", data, this.isForKey, e);
204204
try (ObjectOutputStream oos = new ObjectOutputStream(stream)) {
205205
oos.writeObject(exception);
206206
}
207207
catch (IOException ex) {
208208
stream = new ByteArrayOutputStream();
209209
try (ObjectOutputStream oos = new ObjectOutputStream(stream)) {
210210
exception = new DeserializationException("failed to deserialize",
211-
data, this.isKey, new RuntimeException("Could not deserialize type "
211+
data, this.isForKey, new RuntimeException("Could not deserialize type "
212212
+ e.getClass().getName() + " with message " + e.getMessage()
213213
+ " failure: " + ex.getMessage()));
214214
oos.writeObject(exception);
@@ -218,7 +218,7 @@ data, this.isKey, new RuntimeException("Could not deserialize type "
218218
}
219219
}
220220
headers.add(
221-
new RecordHeader(this.isKey ? KEY_DESERIALIZER_EXCEPTION_HEADER : VALUE_DESERIALIZER_EXCEPTION_HEADER,
221+
new RecordHeader(this.isForKey ? KEY_DESERIALIZER_EXCEPTION_HEADER : VALUE_DESERIALIZER_EXCEPTION_HEADER,
222222
stream.toByteArray()));
223223
}
224224

spring-kafka/src/main/java/org/springframework/kafka/support/serializer/JsonDeserializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ public JsonDeserializer(@Nullable JavaType targetType, ObjectMapper objectMapper
255255
initialize(targetType, useHeadersIfPresent);
256256
}
257257

258-
private void initialize(@Nullable JavaType targetType, boolean useHeadersIfPresent) {
259-
this.targetType = targetType;
258+
private void initialize(@Nullable JavaType type, boolean useHeadersIfPresent) {
259+
this.targetType = type;
260260
Assert.isTrue(this.targetType != null || useHeadersIfPresent,
261261
"'targetType' cannot be null if 'useHeadersIfPresent' is false");
262262

0 commit comments

Comments
 (0)