Browse Source

Polishing

(cherry picked from commit 95a56cd28d)
pull/1998/head
Juergen Hoeller 7 years ago
parent
commit
04814e604e
  1. 8
      spring-context/src/main/java/org/springframework/context/support/DefaultMessageSourceResolvable.java
  2. 14
      spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java
  3. 2
      spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java
  4. 5
      spring-expression/src/main/java/org/springframework/expression/spel/ast/OpEQ.java
  5. 30
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java
  6. 8
      spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaDialect.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -24,7 +24,7 @@ import org.springframework.util.ObjectUtils; @@ -24,7 +24,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
* Default implementation of the {@link MessageSourceResolvable} interface.
* Spring's default implementation of the {@link MessageSourceResolvable} interface.
* Offers an easy way to store all the necessary values needed to resolve
* a message via a {@link org.springframework.context.MessageSource}.
*
@ -143,8 +143,8 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable, @@ -143,8 +143,8 @@ public class DefaultMessageSourceResolvable implements MessageSourceResolvable,
}
/**
* Default implementation exposes the attributes of this MessageSourceResolvable.
* To be overridden in more specific subclasses, potentially including the
* The default implementation exposes the attributes of this MessageSourceResolvable.
* <p>To be overridden in more specific subclasses, potentially including the
* resolvable content through {@code resolvableToString()}.
* @see #resolvableToString()
*/

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

@ -72,7 +72,7 @@ public class SpringValidatorAdapterTests { @@ -72,7 +72,7 @@ public class SpringValidatorAdapterTests {
@Before
public void setupSpringValidatorAdapter() {
messageSource.addMessage("Size", Locale.ENGLISH, "Size of {0} is must be between {2} and {1}");
messageSource.addMessage("Same", Locale.ENGLISH, "{2} must be same value with {1}");
messageSource.addMessage("Same", Locale.ENGLISH, "{2} must be same value as {1}");
messageSource.addMessage("password", Locale.ENGLISH, "Password");
messageSource.addMessage("confirmPassword", Locale.ENGLISH, "Password(Confirm)");
}
@ -115,7 +115,7 @@ public class SpringValidatorAdapterTests { @@ -115,7 +115,7 @@ public class SpringValidatorAdapterTests {
assertThat(errors.getFieldValue("password"), is("password"));
FieldError error = errors.getFieldError("password");
assertNotNull(error);
assertThat(messageSource.getMessage(error, Locale.ENGLISH), is("Password must be same value with Password(Confirm)"));
assertThat(messageSource.getMessage(error, Locale.ENGLISH), is("Password must be same value as Password(Confirm)"));
assertTrue(error.contains(ConstraintViolation.class));
assertThat(error.unwrap(ConstraintViolation.class).getPropertyPath().toString(), is("password"));
}
@ -136,7 +136,7 @@ public class SpringValidatorAdapterTests { @@ -136,7 +136,7 @@ public class SpringValidatorAdapterTests {
FieldError error2 = errors.getFieldError("confirmEmail");
assertNotNull(error1);
assertNotNull(error2);
assertThat(messageSource.getMessage(error1, Locale.ENGLISH), is("email must be same value with confirmEmail"));
assertThat(messageSource.getMessage(error1, Locale.ENGLISH), is("email must be same value as confirmEmail"));
assertThat(messageSource.getMessage(error2, Locale.ENGLISH), is("Email required"));
assertTrue(error1.contains(ConstraintViolation.class));
assertThat(error1.unwrap(ConstraintViolation.class).getPropertyPath().toString(), is("email"));
@ -162,7 +162,7 @@ public class SpringValidatorAdapterTests { @@ -162,7 +162,7 @@ public class SpringValidatorAdapterTests {
FieldError error2 = errors.getFieldError("confirmEmail");
assertNotNull(error1);
assertNotNull(error2);
assertThat(messageSource.getMessage(error1, Locale.ENGLISH), is("email must be same value with confirmEmail"));
assertThat(messageSource.getMessage(error1, Locale.ENGLISH), is("email must be same value as confirmEmail"));
assertThat(messageSource.getMessage(error2, Locale.ENGLISH), is("Email required"));
assertTrue(error1.contains(ConstraintViolation.class));
assertThat(error1.unwrap(ConstraintViolation.class).getPropertyPath().toString(), is("email"));
@ -378,13 +378,13 @@ public class SpringValidatorAdapterTests { @@ -378,13 +378,13 @@ public class SpringValidatorAdapterTests {
private Integer id;
@javax.validation.constraints.NotNull
@NotNull
private String name;
@javax.validation.constraints.NotNull
@NotNull
private Integer age;
@javax.validation.constraints.NotNull
@NotNull
private Parent parent;
public Integer getId() {

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

@ -429,7 +429,7 @@ public class ValidatorFactoryTests { @@ -429,7 +429,7 @@ public class ValidatorFactoryTests {
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Constraint(validatedBy=InnerValidator.class)
public static @interface InnerValid {
public @interface InnerValid {
String message() default "NOT VALID";

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@ -43,8 +43,7 @@ public class OpEQ extends Operator { @@ -43,8 +43,7 @@ public class OpEQ extends Operator {
Object right = getRightOperand().getValueInternal(state).getValue();
this.leftActualDescriptor = CodeFlow.toDescriptorFromObject(left);
this.rightActualDescriptor = CodeFlow.toDescriptorFromObject(right);
return BooleanTypedValue.forValue(
equalityCheck(state.getEvaluationContext(), left, right));
return BooleanTypedValue.forValue(equalityCheck(state.getEvaluationContext(), left, right));
}
// This check is different to the one in the other numeric operators (OpLt/etc)

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -256,14 +256,14 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource { @@ -256,14 +256,14 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
@Nullable
private String password;
private Boolean readOnly = Boolean.FALSE;
@Nullable
private Boolean autoCommit;
@Nullable
private Integer transactionIsolation;
private boolean readOnly = false;
private boolean closed = false;
@Nullable
@ -319,11 +319,15 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource { @@ -319,11 +319,15 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
if (method.getName().equals("toString")) {
return "Lazy Connection proxy for target DataSource [" + getTargetDataSource() + "]";
}
else if (method.getName().equals("isReadOnly")) {
return this.readOnly;
else if (method.getName().equals("getAutoCommit")) {
if (this.autoCommit != null) {
return this.autoCommit;
}
// Else fetch actual Connection and check there,
// because we didn't have a default specified.
}
else if (method.getName().equals("setReadOnly")) {
this.readOnly = (Boolean) args[0];
else if (method.getName().equals("setAutoCommit")) {
this.autoCommit = (Boolean) args[0];
return null;
}
else if (method.getName().equals("getTransactionIsolation")) {
@ -337,15 +341,11 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource { @@ -337,15 +341,11 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
this.transactionIsolation = (Integer) args[0];
return null;
}
else if (method.getName().equals("getAutoCommit")) {
if (this.autoCommit != null) {
return this.autoCommit;
}
// Else fetch actual Connection and check there,
// because we didn't have a default specified.
else if (method.getName().equals("isReadOnly")) {
return this.readOnly;
}
else if (method.getName().equals("setAutoCommit")) {
this.autoCommit = (Boolean) args[0];
else if (method.getName().equals("setReadOnly")) {
this.readOnly = (Boolean) args[0];
return null;
}
else if (method.getName().equals("commit")) {

8
spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaDialect.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -113,10 +113,8 @@ public class HibernateJpaDialect extends DefaultJpaDialect { @@ -113,10 +113,8 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
* Hibernate Session, that is, whether to apply a transaction-specific
* isolation level and/or the transaction's read-only flag to the underlying
* JDBC Connection.
* <p>Default is "true" on Hibernate EntityManager 4.x (with its 'on-close'
* connection release mode.
* <p>If you turn this flag off, JPA transaction management will not support
* per-transaction isolation levels anymore. It will not call
* <p>Default is "true". If you turn this flag off, JPA transaction management
* will not support per-transaction isolation levels anymore. It will not call
* {@code Connection.setReadOnly(true)} for read-only transactions anymore either.
* If this flag is turned off, no cleanup of a JDBC Connection is required after
* a transaction, since no Connection settings will get modified.

Loading…
Cancel
Save