Skip to content

Commit 8ce9236

Browse files
committed
Polishing
(cherry picked from commit 95a56cd)
1 parent 1a626ab commit 8ce9236

File tree

5 files changed

+41
-43
lines changed

5 files changed

+41
-43
lines changed

spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -23,7 +23,7 @@
2323
import org.springframework.util.StringUtils;
2424

2525
/**
26-
* Default implementation of the {@link MessageSourceResolvable} interface.
26+
* Spring's default implementation of the {@link MessageSourceResolvable} interface.
2727
* Offers an easy way to store all the necessary values needed to resolve
2828
* a message via a {@link org.springframework.context.MessageSource}.
2929
*
@@ -133,8 +133,8 @@ protected final String resolvableToString() {
133133
}
134134

135135
/**
136-
* Default implementation exposes the attributes of this MessageSourceResolvable.
137-
* To be overridden in more specific subclasses, potentially including the
136+
* The default implementation exposes the attributes of this MessageSourceResolvable.
137+
* <p>To be overridden in more specific subclasses, potentially including the
138138
* resolvable content through {@code resolvableToString()}.
139139
* @see #resolvableToString()
140140
*/

spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class SpringValidatorAdapterTests {
7070
@Before
7171
public void setupSpringValidatorAdapter() {
7272
messageSource.addMessage("Size", Locale.ENGLISH, "Size of {0} is must be between {2} and {1}");
73-
messageSource.addMessage("Same", Locale.ENGLISH, "{2} must be same value with {1}");
73+
messageSource.addMessage("Same", Locale.ENGLISH, "{2} must be same value as {1}");
7474
messageSource.addMessage("password", Locale.ENGLISH, "Password");
7575
messageSource.addMessage("confirmPassword", Locale.ENGLISH, "Password(Confirm)");
7676
}
@@ -107,7 +107,7 @@ public void testApplyMessageSourceResolvableToStringArgumentValueWithResolvedLog
107107

108108
assertThat(errors.getFieldErrorCount("password"), is(1));
109109
assertThat(messageSource.getMessage(errors.getFieldError("password"), Locale.ENGLISH),
110-
is("Password must be same value with Password(Confirm)"));
110+
is("Password must be same value as Password(Confirm)"));
111111
}
112112

113113
@Test // SPR-13406
@@ -122,7 +122,7 @@ public void testApplyMessageSourceResolvableToStringArgumentValueWithUnresolvedL
122122
assertThat(errors.getFieldErrorCount("email"), is(1));
123123
assertThat(errors.getFieldErrorCount("confirmEmail"), is(1));
124124
assertThat(messageSource.getMessage(errors.getFieldError("email"), Locale.ENGLISH),
125-
is("email must be same value with confirmEmail"));
125+
is("email must be same value as confirmEmail"));
126126
assertThat(messageSource.getMessage(errors.getFieldError("confirmEmail"), Locale.ENGLISH),
127127
is("Email required"));
128128
}
@@ -141,7 +141,7 @@ public void testApplyMessageSourceResolvableToStringArgumentValueWithAlwaysUseMe
141141
assertThat(errors.getFieldErrorCount("email"), is(1));
142142
assertThat(errors.getFieldErrorCount("confirmEmail"), is(1));
143143
assertThat(messageSource.getMessage(errors.getFieldError("email"), Locale.ENGLISH),
144-
is("email must be same value with confirmEmail"));
144+
is("email must be same value as confirmEmail"));
145145
assertThat(messageSource.getMessage(errors.getFieldError("confirmEmail"), Locale.ENGLISH),
146146
is("Email required"));
147147
}
@@ -354,13 +354,13 @@ public static class Child {
354354

355355
private Integer id;
356356

357-
@javax.validation.constraints.NotNull
357+
@NotNull
358358
private String name;
359359

360-
@javax.validation.constraints.NotNull
360+
@NotNull
361361
private Integer age;
362362

363-
@javax.validation.constraints.NotNull
363+
@NotNull
364364
private Parent parent;
365365

366366
public Integer getId() {

spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -54,14 +54,12 @@
5454
import static org.junit.Assert.*;
5555

5656
/**
57-
* Tests against Hibernate Validator 5.x.
58-
*
5957
* @author Juergen Hoeller
6058
*/
6159
public class ValidatorFactoryTests {
6260

6361
@Test
64-
public void testSimpleValidation() throws Exception {
62+
public void testSimpleValidation() {
6563
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
6664
validator.afterPropertiesSet();
6765

@@ -114,9 +112,10 @@ public void testSimpleValidationWithCustomProvider() throws Exception {
114112
}
115113

116114
@Test
117-
public void testSimpleValidationWithClassLevel() throws Exception {
115+
public void testSimpleValidationWithClassLevel() {
118116
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
119117
validator.afterPropertiesSet();
118+
120119
ValidPerson person = new ValidPerson();
121120
person.setName("Juergen");
122121
person.getAddress().setStreet("Juergen's Street");
@@ -129,7 +128,7 @@ public void testSimpleValidationWithClassLevel() throws Exception {
129128
}
130129

131130
@Test
132-
public void testSpringValidationFieldType() throws Exception {
131+
public void testSpringValidationFieldType() {
133132
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
134133
validator.afterPropertiesSet();
135134

@@ -144,7 +143,7 @@ public void testSpringValidationFieldType() throws Exception {
144143
}
145144

146145
@Test
147-
public void testSpringValidation() throws Exception {
146+
public void testSpringValidation() {
148147
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
149148
validator.afterPropertiesSet();
150149

@@ -172,7 +171,7 @@ public void testSpringValidation() throws Exception {
172171
}
173172

174173
@Test
175-
public void testSpringValidationWithClassLevel() throws Exception {
174+
public void testSpringValidationWithClassLevel() {
176175
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
177176
validator.afterPropertiesSet();
178177

@@ -190,7 +189,7 @@ public void testSpringValidationWithClassLevel() throws Exception {
190189
}
191190

192191
@Test
193-
public void testSpringValidationWithAutowiredValidator() throws Exception {
192+
public void testSpringValidationWithAutowiredValidator() {
194193
ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(
195194
LocalValidatorFactoryBean.class);
196195
LocalValidatorFactoryBean validator = ctx.getBean(LocalValidatorFactoryBean.class);
@@ -211,7 +210,7 @@ public void testSpringValidationWithAutowiredValidator() throws Exception {
211210
}
212211

213212
@Test
214-
public void testSpringValidationWithErrorInListElement() throws Exception {
213+
public void testSpringValidationWithErrorInListElement() {
215214
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
216215
validator.afterPropertiesSet();
217216

@@ -229,7 +228,7 @@ public void testSpringValidationWithErrorInListElement() throws Exception {
229228
}
230229

231230
@Test
232-
public void testSpringValidationWithErrorInSetElement() throws Exception {
231+
public void testSpringValidationWithErrorInSetElement() {
233232
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
234233
validator.afterPropertiesSet();
235234

@@ -247,7 +246,7 @@ public void testSpringValidationWithErrorInSetElement() throws Exception {
247246
}
248247

249248
@Test
250-
public void testInnerBeanValidation() throws Exception {
249+
public void testInnerBeanValidation() {
251250
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
252251
validator.afterPropertiesSet();
253252

@@ -259,7 +258,7 @@ public void testInnerBeanValidation() throws Exception {
259258
}
260259

261260
@Test
262-
public void testValidationWithOptionalField() throws Exception {
261+
public void testValidationWithOptionalField() {
263262
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
264263
validator.afterPropertiesSet();
265264

@@ -412,7 +411,7 @@ public void setValue(String value) {
412411
@Retention(RetentionPolicy.RUNTIME)
413412
@Target(ElementType.FIELD)
414413
@Constraint(validatedBy=InnerValidator.class)
415-
public static @interface InnerValid {
414+
public @interface InnerValid {
416415

417416
String message() default "NOT VALID";
418417

spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -43,8 +43,7 @@ public BooleanTypedValue getValueInternal(ExpressionState state) throws Evaluati
4343
Object right = getRightOperand().getValueInternal(state).getValue();
4444
this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left);
4545
this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right);
46-
return BooleanTypedValue.forValue(
47-
equalityCheck(state.getEvaluationContext(), left, right));
46+
return BooleanTypedValue.forValue(equalityCheck(state.getEvaluationContext(), left, right));
4847
}
4948

5049
// This check is different to the one in the other numeric operators (OpLt/etc)

spring-jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -252,12 +252,12 @@ private class LazyConnectionInvocationHandler implements InvocationHandler {
252252

253253
private String password;
254254

255-
private Boolean readOnly = Boolean.FALSE;
256-
257255
private Integer transactionIsolation;
258256

259257
private Boolean autoCommit;
260258

259+
private boolean readOnly = false;
260+
261261
private boolean closed = false;
262262

263263
private Connection target;
@@ -311,11 +311,15 @@ else if (method.getName().equals("getTargetConnection")) {
311311
if (method.getName().equals("toString")) {
312312
return "Lazy Connection proxy for target DataSource [" + getTargetDataSource() + "]";
313313
}
314-
else if (method.getName().equals("isReadOnly")) {
315-
return this.readOnly;
314+
else if (method.getName().equals("getAutoCommit")) {
315+
if (this.autoCommit != null) {
316+
return this.autoCommit;
317+
}
318+
// Else fetch actual Connection and check there,
319+
// because we didn't have a default specified.
316320
}
317-
else if (method.getName().equals("setReadOnly")) {
318-
this.readOnly = (Boolean) args[0];
321+
else if (method.getName().equals("setAutoCommit")) {
322+
this.autoCommit = (Boolean) args[0];
319323
return null;
320324
}
321325
else if (method.getName().equals("getTransactionIsolation")) {
@@ -329,15 +333,11 @@ else if (method.getName().equals("setTransactionIsolation")) {
329333
this.transactionIsolation = (Integer) args[0];
330334
return null;
331335
}
332-
else if (method.getName().equals("getAutoCommit")) {
333-
if (this.autoCommit != null) {
334-
return this.autoCommit;
335-
}
336-
// Else fetch actual Connection and check there,
337-
// because we didn't have a default specified.
336+
else if (method.getName().equals("isReadOnly")) {
337+
return this.readOnly;
338338
}
339-
else if (method.getName().equals("setAutoCommit")) {
340-
this.autoCommit = (Boolean) args[0];
339+
else if (method.getName().equals("setReadOnly")) {
340+
this.readOnly = (Boolean) args[0];
341341
return null;
342342
}
343343
else if (method.getName().equals("commit")) {

0 commit comments

Comments
 (0)