Skip to content

Commit 3baa44c

Browse files
committed
Polishing
1 parent 4b86a1a commit 3baa44c

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-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.
@@ -292,6 +292,7 @@ public void afterPropertiesSet() {
292292
if (this.parameterNameDiscoverer != null) {
293293
configureParameterNameProvider(this.parameterNameDiscoverer, configuration);
294294
}
295+
295296
List<InputStream> mappingStreams = null;
296297
if (this.mappingLocations != null) {
297298
mappingStreams = new ArrayList<>(this.mappingLocations.length);
@@ -322,18 +323,6 @@ public void afterPropertiesSet() {
322323
}
323324
}
324325

325-
private void closeMappingStreams(@Nullable List<InputStream> mappingStreams){
326-
if (!CollectionUtils.isEmpty(mappingStreams)) {
327-
for (InputStream stream : mappingStreams) {
328-
try {
329-
stream.close();
330-
}
331-
catch (IOException ignored) {
332-
}
333-
}
334-
}
335-
}
336-
337326
private void configureParameterNameProvider(ParameterNameDiscoverer discoverer, Configuration<?> configuration) {
338327
final ParameterNameProvider defaultProvider = configuration.getDefaultParameterNameProvider();
339328
configuration.parameterNameProvider(new ParameterNameProvider() {
@@ -352,6 +341,18 @@ public List<String> getParameterNames(Method method) {
352341
});
353342
}
354343

344+
private void closeMappingStreams(@Nullable List<InputStream> mappingStreams){
345+
if (!CollectionUtils.isEmpty(mappingStreams)) {
346+
for (InputStream stream : mappingStreams) {
347+
try {
348+
stream.close();
349+
}
350+
catch (IOException ignored) {
351+
}
352+
}
353+
}
354+
}
355+
355356
/**
356357
* Post-process the given Bean Validation configuration,
357358
* adding to or overriding any of its settings.
@@ -420,15 +421,15 @@ public <T> T unwrap(@Nullable Class<T> type) {
420421
return super.unwrap(type);
421422
}
422423
catch (ValidationException ex) {
423-
// ignore - we'll try ValidatorFactory unwrapping next
424+
// Ignore - we'll try ValidatorFactory unwrapping next
424425
}
425426
}
426427
if (this.validatorFactory != null) {
427428
try {
428429
return this.validatorFactory.unwrap(type);
429430
}
430431
catch (ValidationException ex) {
431-
// ignore if just being asked for ValidatorFactory
432+
// Ignore if just being asked for ValidatorFactory
432433
if (ValidatorFactory.class == type) {
433434
return (T) this.validatorFactory;
434435
}

spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-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.
@@ -179,7 +179,7 @@ protected void processConstraintViolations(Set<ConstraintViolation<Object>> viol
179179
}
180180
}
181181
else {
182-
// got no BindingResult - can only do standard rejectValue call
182+
// Got no BindingResult - can only do standard rejectValue call
183183
// with automatic extraction of the current field value
184184
errors.rejectValue(field, errorCode, errorArgs, violation.getMessage());
185185
}
@@ -386,7 +386,7 @@ public <T> T unwrap(@Nullable Class<T> type) {
386386
return (type != null ? this.targetValidator.unwrap(type) : (T) this.targetValidator);
387387
}
388388
catch (ValidationException ex) {
389-
// ignore if just being asked for plain Validator
389+
// Ignore if just being asked for plain JSR-303 Validator
390390
if (javax.validation.Validator.class == type) {
391391
return (T) this.targetValidator;
392392
}

0 commit comments

Comments
 (0)