Skip to content

Commit 64c09c5

Browse files
hpoettkerfmbenhassine
authored andcommitted
Replaces deprecated interfaces
Replaces the deprecated - type InstantiationAwareBeanPostProcessorAdapter - type GenericTypeResolver - method StringUtils::isEmpty - field BigDecimal::ROUND_HALF_UP Issue #3838
1 parent b9790d1 commit 64c09c5

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/jsr/configuration/support/SpringAutowiredAnnotationBeanPostProcessor.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2018 the original author or authors.
2+
* Copyright 2013-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,12 +46,11 @@
4646
import org.springframework.beans.factory.annotation.Value;
4747
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
4848
import org.springframework.beans.factory.config.DependencyDescriptor;
49-
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
5049
import org.springframework.beans.factory.config.RuntimeBeanReference;
50+
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
5151
import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
5252
import org.springframework.beans.factory.support.RootBeanDefinition;
5353
import org.springframework.core.BridgeMethodResolver;
54-
import org.springframework.core.GenericTypeResolver;
5554
import org.springframework.core.MethodParameter;
5655
import org.springframework.core.Ordered;
5756
import org.springframework.core.PriorityOrdered;
@@ -73,8 +72,8 @@
7372
* <li>findAutowiredAnnotation(AccessibleObject ao)</li>
7473
* </ul>
7574
*/
76-
class SpringAutowiredAnnotationBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter
77-
implements MergedBeanDefinitionPostProcessor, PriorityOrdered, BeanFactoryAware {
75+
class SpringAutowiredAnnotationBeanPostProcessor implements SmartInstantiationAwareBeanPostProcessor,
76+
MergedBeanDefinitionPostProcessor, PriorityOrdered, BeanFactoryAware {
7877

7978
protected final Log logger = LogFactory.getLog(getClass());
8079

@@ -539,8 +538,7 @@ protected void inject(Object bean, String beanName, PropertyValues pvs) throws T
539538
Set<String> autowiredBeanNames = new LinkedHashSet<>(paramTypes.length);
540539
TypeConverter typeConverter = beanFactory.getTypeConverter();
541540
for (int i = 0; i < arguments.length; i++) {
542-
MethodParameter methodParam = new MethodParameter(method, i);
543-
GenericTypeResolver.resolveParameterType(methodParam, bean.getClass());
541+
MethodParameter methodParam = new MethodParameter(method, i).withContainingClass(bean.getClass());
544542
descriptors[i] = new DependencyDescriptor(methodParam, this.required);
545543
arguments[i] = beanFactory.resolveDependency(
546544
descriptors[i], beanName, autowiredBeanNames, typeConverter);

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/support/ScriptItemProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -134,7 +134,7 @@ public void afterPropertiesSet() throws Exception {
134134
"Either a script source or script file must be provided, not both");
135135

136136
if (scriptSource != null && scriptEvaluator instanceof StandardScriptEvaluator) {
137-
Assert.isTrue(!StringUtils.isEmpty(language),
137+
Assert.isTrue(StringUtils.hasLength(language),
138138
"Language must be provided when using the default ScriptEvaluator and raw source code");
139139

140140
((StandardScriptEvaluator) scriptEvaluator).setLanguage(language);

spring-batch-samples/src/main/java/org/springframework/batch/sample/domain/order/internal/validator/OrderValidator.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014 the original author or authors.
2+
* Copyright 2014-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616
package org.springframework.batch.sample.domain.order.internal.validator;
1717

1818
import java.math.BigDecimal;
19+
import java.math.RoundingMode;
1920
import java.util.ArrayList;
2021
import java.util.Date;
2122
import java.util.List;
@@ -140,7 +141,7 @@ protected void validateLineItems(List<LineItem> lineItems, Errors errors) {
140141

141142
//discount coefficient = (100.00 - discountPerc) / 100.00
142143
BigDecimal coef = BD_100.subtract(lineItem.getDiscountPerc())
143-
.divide(BD_100, 4, BigDecimal.ROUND_HALF_UP);
144+
.divide(BD_100, 4, RoundingMode.HALF_UP);
144145

145146
//discountedPrice = (price * coefficient) - discountAmount
146147
//at least one of discountPerc and discountAmount is 0 - this is validated by ValidateDiscountsFunction
@@ -154,7 +155,7 @@ protected void validateLineItems(List<LineItem> lineItems, Errors errors) {
154155
//total price = singleItemPrice * quantity
155156
BigDecimal quantity = new BigDecimal(lineItem.getQuantity());
156157
BigDecimal totalPrice = singleItemPrice.multiply(quantity)
157-
.setScale(2, BigDecimal.ROUND_HALF_UP);
158+
.setScale(2, RoundingMode.HALF_UP);
158159

159160
//calculatedPrice should equal to item.totalPrice
160161
if (totalPrice.compareTo(lineItem.getTotalPrice()) != 0) {

0 commit comments

Comments
 (0)