Nullability fine-tuning based on IntelliJ IDEA 2018.3 inspection
Issue: SPR-15540
This commit is contained in:
parent
b1b28d4641
commit
bf272b0b21
|
@ -314,6 +314,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nullable
|
||||||
public Class<?> getPropertyType() {
|
public Class<?> getPropertyType() {
|
||||||
if (this.propertyType == null) {
|
if (this.propertyType == null) {
|
||||||
try {
|
try {
|
||||||
|
@ -425,6 +426,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nullable
|
||||||
public Class<?> getPropertyType() {
|
public Class<?> getPropertyType() {
|
||||||
if (this.propertyType == null) {
|
if (this.propertyType == null) {
|
||||||
try {
|
try {
|
||||||
|
@ -460,6 +462,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nullable
|
||||||
public Class<?> getIndexedPropertyType() {
|
public Class<?> getIndexedPropertyType() {
|
||||||
if (this.indexedPropertyType == null) {
|
if (this.indexedPropertyType == null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -196,7 +196,7 @@ class ConstructorResolver {
|
||||||
for (Constructor<?> candidate : candidates) {
|
for (Constructor<?> candidate : candidates) {
|
||||||
Class<?>[] paramTypes = candidate.getParameterTypes();
|
Class<?>[] paramTypes = candidate.getParameterTypes();
|
||||||
|
|
||||||
if (constructorToUse != null && argsToUse.length > paramTypes.length) {
|
if (constructorToUse != null && argsToUse != null && argsToUse.length > paramTypes.length) {
|
||||||
// Already found greedy constructor that can be satisfied ->
|
// Already found greedy constructor that can be satisfied ->
|
||||||
// do not look any further, there are only less greedy constructors left.
|
// do not look any further, there are only less greedy constructors left.
|
||||||
break;
|
break;
|
||||||
|
@ -276,11 +276,12 @@ class ConstructorResolver {
|
||||||
ambiguousConstructors);
|
ambiguousConstructors);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (explicitArgs == null) {
|
if (explicitArgs == null && argsHolderToUse != null) {
|
||||||
argsHolderToUse.storeCache(mbd, constructorToUse);
|
argsHolderToUse.storeCache(mbd, constructorToUse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Assert.state(argsToUse != null, "Unresolved constructor arguments");
|
||||||
bw.setBeanInstance(instantiate(beanName, mbd, constructorToUse, argsToUse));
|
bw.setBeanInstance(instantiate(beanName, mbd, constructorToUse, argsToUse));
|
||||||
return bw;
|
return bw;
|
||||||
}
|
}
|
||||||
|
@ -602,12 +603,13 @@ class ConstructorResolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Assert.state(argsToUse != null, "Unresolved factory method arguments");
|
||||||
bw.setBeanInstance(instantiate(beanName, mbd, factoryBean, factoryMethodToUse, argsToUse));
|
bw.setBeanInstance(instantiate(beanName, mbd, factoryBean, factoryMethodToUse, argsToUse));
|
||||||
return bw;
|
return bw;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object instantiate(
|
private Object instantiate(String beanName, RootBeanDefinition mbd,
|
||||||
String beanName, RootBeanDefinition mbd, Object factoryBean, Method factoryMethod, Object[] args) {
|
@Nullable Object factoryBean, Method factoryMethod, Object[] args) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (System.getSecurityManager() != null) {
|
if (System.getSecurityManager() != null) {
|
||||||
|
|
|
@ -393,6 +393,7 @@ class ConfigurationClassEnhancer {
|
||||||
Object beanInstance = (useArgs ? beanFactory.getBean(beanName, beanMethodArgs) :
|
Object beanInstance = (useArgs ? beanFactory.getBean(beanName, beanMethodArgs) :
|
||||||
beanFactory.getBean(beanName));
|
beanFactory.getBean(beanName));
|
||||||
if (!ClassUtils.isAssignableValue(beanMethod.getReturnType(), beanInstance)) {
|
if (!ClassUtils.isAssignableValue(beanMethod.getReturnType(), beanInstance)) {
|
||||||
|
// Detect package-protected NullBean instance through equals(null) check
|
||||||
if (beanInstance.equals(null)) {
|
if (beanInstance.equals(null)) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(String.format("@Bean method %s.%s called as bean reference " +
|
logger.debug(String.format("@Bean method %s.%s called as bean reference " +
|
||||||
|
|
|
@ -170,11 +170,12 @@ public class ConnectorServerFactoryBean extends MBeanRegistrationSupport
|
||||||
try {
|
try {
|
||||||
if (this.threaded) {
|
if (this.threaded) {
|
||||||
// Start the connector server asynchronously (in a separate thread).
|
// Start the connector server asynchronously (in a separate thread).
|
||||||
|
final JMXConnectorServer serverToStart = this.connectorServer;
|
||||||
Thread connectorThread = new Thread() {
|
Thread connectorThread = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
connectorServer.start();
|
serverToStart.start();
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
throw new JmxException("Could not start JMX connector server after delay", ex);
|
throw new JmxException("Could not start JMX connector server after delay", ex);
|
||||||
|
|
|
@ -111,25 +111,25 @@ public abstract class NamedParameterUtils {
|
||||||
char c = statement[i];
|
char c = statement[i];
|
||||||
if (c == ':' || c == '&') {
|
if (c == ':' || c == '&') {
|
||||||
int j = i + 1;
|
int j = i + 1;
|
||||||
if (j < statement.length && statement[j] == ':' && c == ':') {
|
if (c == ':' && j < statement.length && statement[j] == ':') {
|
||||||
// Postgres-style "::" casting operator should be skipped
|
// Postgres-style "::" casting operator should be skipped
|
||||||
i = i + 2;
|
i = i + 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String parameter = null;
|
String parameter = null;
|
||||||
if (j < statement.length && c == ':' && statement[j] == '{') {
|
if (c == ':' && j < statement.length && statement[j] == '{') {
|
||||||
// :{x} style parameter
|
// :{x} style parameter
|
||||||
while (j < statement.length && statement[j] != '}') {
|
while (statement[j] != '}') {
|
||||||
j++;
|
j++;
|
||||||
|
if (j >= statement.length) {
|
||||||
|
throw new InvalidDataAccessApiUsageException("Non-terminated named parameter declaration " +
|
||||||
|
"at position " + i + " in statement: " + sql);
|
||||||
|
}
|
||||||
if (statement[j] == ':' || statement[j] == '{') {
|
if (statement[j] == ':' || statement[j] == '{') {
|
||||||
throw new InvalidDataAccessApiUsageException("Parameter name contains invalid character '" +
|
throw new InvalidDataAccessApiUsageException("Parameter name contains invalid character '" +
|
||||||
statement[j] + "' at position " + i + " in statement: " + sql);
|
statement[j] + "' at position " + i + " in statement: " + sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (j >= statement.length) {
|
|
||||||
throw new InvalidDataAccessApiUsageException(
|
|
||||||
"Non-terminated named parameter declaration at position " + i + " in statement: " + sql);
|
|
||||||
}
|
|
||||||
if (j - i > 2) {
|
if (j - i > 2) {
|
||||||
parameter = sql.substring(i + 2, j);
|
parameter = sql.substring(i + 2, j);
|
||||||
namedParameterCount = addNewNamedParameter(namedParameters, namedParameterCount, parameter);
|
namedParameterCount = addNewNamedParameter(namedParameters, namedParameterCount, parameter);
|
||||||
|
|
|
@ -211,7 +211,7 @@ public abstract class RdbmsOperation implements InitializingBean {
|
||||||
* Set the column names of the auto-generated keys.
|
* Set the column names of the auto-generated keys.
|
||||||
* @see java.sql.Connection#prepareStatement(String, String[])
|
* @see java.sql.Connection#prepareStatement(String, String[])
|
||||||
*/
|
*/
|
||||||
public void setGeneratedKeysColumnNames(String... names) {
|
public void setGeneratedKeysColumnNames(@Nullable String... names) {
|
||||||
if (isCompiled()) {
|
if (isCompiled()) {
|
||||||
throw new InvalidDataAccessApiUsageException(
|
throw new InvalidDataAccessApiUsageException(
|
||||||
"The column names for the generated keys must be set before the operation is compiled");
|
"The column names for the generated keys must be set before the operation is compiled");
|
||||||
|
@ -230,7 +230,7 @@ public abstract class RdbmsOperation implements InitializingBean {
|
||||||
/**
|
/**
|
||||||
* Set the SQL executed by this operation.
|
* Set the SQL executed by this operation.
|
||||||
*/
|
*/
|
||||||
public void setSql(String sql) {
|
public void setSql(@Nullable String sql) {
|
||||||
this.sql = sql;
|
this.sql = sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,13 +40,6 @@ import org.springframework.util.Assert;
|
||||||
*/
|
*/
|
||||||
public abstract class SqlCall extends RdbmsOperation {
|
public abstract class SqlCall extends RdbmsOperation {
|
||||||
|
|
||||||
/**
|
|
||||||
* Object enabling us to create CallableStatementCreators
|
|
||||||
* efficiently, based on this class's declared parameters.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
private CallableStatementCreatorFactory callableStatementFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag used to indicate that this call is for a function and to
|
* Flag used to indicate that this call is for a function and to
|
||||||
* use the {? = call get_invoice_count(?)} syntax.
|
* use the {? = call get_invoice_count(?)} syntax.
|
||||||
|
@ -54,20 +47,26 @@ public abstract class SqlCall extends RdbmsOperation {
|
||||||
private boolean function = false;
|
private boolean function = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag used to indicate that the sql for this call should be used exactly as it is
|
* Flag used to indicate that the sql for this call should be used exactly as
|
||||||
* defined. No need to add the escape syntax and parameter place holders.
|
* it is defined. No need to add the escape syntax and parameter place holders.
|
||||||
*/
|
*/
|
||||||
private boolean sqlReadyForUse = false;
|
private boolean sqlReadyForUse = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call string as defined in java.sql.CallableStatement.
|
* Call string as defined in java.sql.CallableStatement.
|
||||||
* String of form {call add_invoice(?, ?, ?)}
|
* String of form {call add_invoice(?, ?, ?)} or {? = call get_invoice_count(?)}
|
||||||
* or {? = call get_invoice_count(?)} if isFunction is set to true
|
* if isFunction is set to true. Updated after each parameter is added.
|
||||||
* Updated after each parameter is added.
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
private String callString;
|
private String callString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object enabling us to create CallableStatementCreators
|
||||||
|
* efficiently, based on this class's declared parameters.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
private CallableStatementCreatorFactory callableStatementFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor to allow use as a JavaBean.
|
* Constructor to allow use as a JavaBean.
|
||||||
|
@ -129,30 +128,32 @@ public abstract class SqlCall extends RdbmsOperation {
|
||||||
@Override
|
@Override
|
||||||
protected final void compileInternal() {
|
protected final void compileInternal() {
|
||||||
if (isSqlReadyForUse()) {
|
if (isSqlReadyForUse()) {
|
||||||
this.callString = getSql();
|
this.callString = resolveSql();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
StringBuilder callString = new StringBuilder(32);
|
||||||
List<SqlParameter> parameters = getDeclaredParameters();
|
List<SqlParameter> parameters = getDeclaredParameters();
|
||||||
int parameterCount = 0;
|
int parameterCount = 0;
|
||||||
if (isFunction()) {
|
if (isFunction()) {
|
||||||
this.callString = "{? = call " + getSql() + "(";
|
callString.append("{? = call ").append(resolveSql()).append('(');
|
||||||
parameterCount = -1;
|
parameterCount = -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.callString = "{call " + getSql() + "(";
|
callString.append("{call ").append(resolveSql()).append('(');
|
||||||
}
|
}
|
||||||
for (SqlParameter parameter : parameters) {
|
for (SqlParameter parameter : parameters) {
|
||||||
if (!(parameter.isResultsParameter())) {
|
if (!parameter.isResultsParameter()) {
|
||||||
if (parameterCount > 0) {
|
if (parameterCount > 0) {
|
||||||
this.callString += ", ";
|
callString.append(", ");
|
||||||
}
|
}
|
||||||
if (parameterCount >= 0) {
|
if (parameterCount >= 0) {
|
||||||
this.callString += "?";
|
callString.append('?');
|
||||||
}
|
}
|
||||||
parameterCount++;
|
parameterCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.callString += ")}";
|
callString.append(")}");
|
||||||
|
this.callString = callString.toString();
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Compiled stored procedure. Call string is [" + this.callString + "]");
|
logger.debug("Compiled stored procedure. Call string is [" + this.callString + "]");
|
||||||
|
|
|
@ -117,13 +117,13 @@ public class NamedParameterUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = InvalidDataAccessApiUsageException.class)
|
@Test(expected = InvalidDataAccessApiUsageException.class)
|
||||||
public void buildValueArrayWithMissingParameterValue() throws Exception {
|
public void buildValueArrayWithMissingParameterValue() {
|
||||||
String sql = "select count(0) from foo where id = :id";
|
String sql = "select count(0) from foo where id = :id";
|
||||||
NamedParameterUtils.buildValueArray(sql, Collections.<String, Object>emptyMap());
|
NamedParameterUtils.buildValueArray(sql, Collections.<String, Object>emptyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void substituteNamedParametersWithStringContainingQuotes() throws Exception {
|
public void substituteNamedParametersWithStringContainingQuotes() {
|
||||||
String expectedSql = "select 'first name' from artists where id = ? and quote = 'exsqueeze me?'";
|
String expectedSql = "select 'first name' from artists where id = ? and quote = 'exsqueeze me?'";
|
||||||
String sql = "select 'first name' from artists where id = :id and quote = 'exsqueeze me?'";
|
String sql = "select 'first name' from artists where id = :id and quote = 'exsqueeze me?'";
|
||||||
String newSql = NamedParameterUtils.substituteNamedParameters(sql, new MapSqlParameterSource());
|
String newSql = NamedParameterUtils.substituteNamedParameters(sql, new MapSqlParameterSource());
|
||||||
|
@ -131,7 +131,7 @@ public class NamedParameterUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseSqlStatementWithStringContainingQuotes() throws Exception {
|
public void testParseSqlStatementWithStringContainingQuotes() {
|
||||||
String expectedSql = "select 'first name' from artists where id = ? and quote = 'exsqueeze me?'";
|
String expectedSql = "select 'first name' from artists where id = ? and quote = 'exsqueeze me?'";
|
||||||
String sql = "select 'first name' from artists where id = :id and quote = 'exsqueeze me?'";
|
String sql = "select 'first name' from artists where id = :id and quote = 'exsqueeze me?'";
|
||||||
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
|
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
|
||||||
|
@ -173,7 +173,7 @@ public class NamedParameterUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-4612
|
@Test // SPR-4612
|
||||||
public void parseSqlStatementWithPostgresCasting() throws Exception {
|
public void parseSqlStatementWithPostgresCasting() {
|
||||||
String expectedSql = "select 'first name' from artists where id = ? and birth_date=?::timestamp";
|
String expectedSql = "select 'first name' from artists where id = ? and birth_date=?::timestamp";
|
||||||
String sql = "select 'first name' from artists where id = :id and birth_date=:birthDate::timestamp";
|
String sql = "select 'first name' from artists where id = :id and birth_date=:birthDate::timestamp";
|
||||||
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
|
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
|
||||||
|
@ -181,7 +181,7 @@ public class NamedParameterUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-13582
|
@Test // SPR-13582
|
||||||
public void parseSqlStatementWithPostgresContainedOperator() throws Exception {
|
public void parseSqlStatementWithPostgresContainedOperator() {
|
||||||
String expectedSql = "select 'first name' from artists where info->'stat'->'albums' = ?? ? and '[\"1\",\"2\",\"3\"]'::jsonb ?? '4'";
|
String expectedSql = "select 'first name' from artists where info->'stat'->'albums' = ?? ? and '[\"1\",\"2\",\"3\"]'::jsonb ?? '4'";
|
||||||
String sql = "select 'first name' from artists where info->'stat'->'albums' = ?? :album and '[\"1\",\"2\",\"3\"]'::jsonb ?? '4'";
|
String sql = "select 'first name' from artists where info->'stat'->'albums' = ?? :album and '[\"1\",\"2\",\"3\"]'::jsonb ?? '4'";
|
||||||
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
|
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
|
||||||
|
@ -190,7 +190,7 @@ public class NamedParameterUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-15382
|
@Test // SPR-15382
|
||||||
public void parseSqlStatementWithPostgresAnyArrayStringsExistsOperator() throws Exception {
|
public void parseSqlStatementWithPostgresAnyArrayStringsExistsOperator() {
|
||||||
String expectedSql = "select '[\"3\", \"11\"]'::jsonb ?| '{1,3,11,12,17}'::text[]";
|
String expectedSql = "select '[\"3\", \"11\"]'::jsonb ?| '{1,3,11,12,17}'::text[]";
|
||||||
String sql = "select '[\"3\", \"11\"]'::jsonb ?| '{1,3,11,12,17}'::text[]";
|
String sql = "select '[\"3\", \"11\"]'::jsonb ?| '{1,3,11,12,17}'::text[]";
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ public class NamedParameterUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-15382
|
@Test // SPR-15382
|
||||||
public void parseSqlStatementWithPostgresAllArrayStringsExistsOperator() throws Exception {
|
public void parseSqlStatementWithPostgresAllArrayStringsExistsOperator() {
|
||||||
String expectedSql = "select '[\"3\", \"11\"]'::jsonb ?& '{1,3,11,12,17}'::text[] AND ? = 'Back in Black'";
|
String expectedSql = "select '[\"3\", \"11\"]'::jsonb ?& '{1,3,11,12,17}'::text[] AND ? = 'Back in Black'";
|
||||||
String sql = "select '[\"3\", \"11\"]'::jsonb ?& '{1,3,11,12,17}'::text[] AND :album = 'Back in Black'";
|
String sql = "select '[\"3\", \"11\"]'::jsonb ?& '{1,3,11,12,17}'::text[] AND :album = 'Back in Black'";
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ public class NamedParameterUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-7476
|
@Test // SPR-7476
|
||||||
public void parseSqlStatementWithEscapedColon() throws Exception {
|
public void parseSqlStatementWithEscapedColon() {
|
||||||
String expectedSql = "select '0\\:0' as a, foo from bar where baz < DATE(? 23:59:59) and baz = ?";
|
String expectedSql = "select '0\\:0' as a, foo from bar where baz < DATE(? 23:59:59) and baz = ?";
|
||||||
String sql = "select '0\\:0' as a, foo from bar where baz < DATE(:p1 23\\:59\\:59) and baz = :p2";
|
String sql = "select '0\\:0' as a, foo from bar where baz < DATE(:p1 23\\:59\\:59) and baz = :p2";
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ public class NamedParameterUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-7476
|
@Test // SPR-7476
|
||||||
public void parseSqlStatementWithBracketDelimitedParameterNames() throws Exception {
|
public void parseSqlStatementWithBracketDelimitedParameterNames() {
|
||||||
String expectedSql = "select foo from bar where baz = b??z";
|
String expectedSql = "select foo from bar where baz = b??z";
|
||||||
String sql = "select foo from bar where baz = b:{p1}:{p2}z";
|
String sql = "select foo from bar where baz = b:{p1}:{p2}z";
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ public class NamedParameterUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-7476
|
@Test // SPR-7476
|
||||||
public void parseSqlStatementWithEmptyBracketsOrBracketsInQuotes() throws Exception {
|
public void parseSqlStatementWithEmptyBracketsOrBracketsInQuotes() {
|
||||||
String expectedSql = "select foo from bar where baz = b:{}z";
|
String expectedSql = "select foo from bar where baz = b:{}z";
|
||||||
String sql = "select foo from bar where baz = b:{}z";
|
String sql = "select foo from bar where baz = b:{}z";
|
||||||
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
|
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
|
||||||
|
@ -273,14 +273,14 @@ public class NamedParameterUtilsTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-2544
|
@Test // SPR-2544
|
||||||
public void substituteNamedParametersWithLogicalAnd() throws Exception {
|
public void substituteNamedParametersWithLogicalAnd() {
|
||||||
String expectedSql = "xxx & yyyy";
|
String expectedSql = "xxx & yyyy";
|
||||||
String newSql = NamedParameterUtils.substituteNamedParameters(expectedSql, new MapSqlParameterSource());
|
String newSql = NamedParameterUtils.substituteNamedParameters(expectedSql, new MapSqlParameterSource());
|
||||||
assertEquals(expectedSql, newSql);
|
assertEquals(expectedSql, newSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-3173
|
@Test // SPR-3173
|
||||||
public void variableAssignmentOperator() throws Exception {
|
public void variableAssignmentOperator() {
|
||||||
String expectedSql = "x := 1";
|
String expectedSql = "x := 1";
|
||||||
String newSql = NamedParameterUtils.substituteNamedParameters(expectedSql, new MapSqlParameterSource());
|
String newSql = NamedParameterUtils.substituteNamedParameters(expectedSql, new MapSqlParameterSource());
|
||||||
assertEquals(expectedSql, newSql);
|
assertEquals(expectedSql, newSql);
|
||||||
|
|
|
@ -50,6 +50,7 @@ public class SessionHolder extends EntityManagerHolder {
|
||||||
|
|
||||||
|
|
||||||
public SessionHolder(Session session) {
|
public SessionHolder(Session session) {
|
||||||
|
// Check below is always true against Hibernate >= 5.2 but not against 5.0/5.1 at runtime
|
||||||
super(EntityManager.class.isInstance(session) ? session : null);
|
super(EntityManager.class.isInstance(session) ? session : null);
|
||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
|
@ -709,7 +709,7 @@ public class JtaTransactionManager extends AbstractPlatformTransactionManager
|
||||||
* @see #FALLBACK_TRANSACTION_MANAGER_NAMES
|
* @see #FALLBACK_TRANSACTION_MANAGER_NAMES
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
protected TransactionManager findTransactionManager(UserTransaction ut) {
|
protected TransactionManager findTransactionManager(@Nullable UserTransaction ut) {
|
||||||
if (ut instanceof TransactionManager) {
|
if (ut instanceof TransactionManager) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("JTA UserTransaction object [" + ut + "] implements TransactionManager");
|
logger.debug("JTA UserTransaction object [" + ut + "] implements TransactionManager");
|
||||||
|
|
|
@ -113,11 +113,8 @@ class PathResourceLookupFunction implements Function<ServerRequest, Mono<Resourc
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (path.contains("")) {
|
if (path.contains("..") && StringUtils.cleanPath(path).contains("../")) {
|
||||||
path = StringUtils.cleanPath(path);
|
return true;
|
||||||
if (path.contains("../")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -494,22 +494,19 @@ public class ResourceWebHandler implements WebHandler, InitializingBean {
|
||||||
*/
|
*/
|
||||||
protected boolean isInvalidPath(String path) {
|
protected boolean isInvalidPath(String path) {
|
||||||
if (path.contains("WEB-INF") || path.contains("META-INF")) {
|
if (path.contains("WEB-INF") || path.contains("META-INF")) {
|
||||||
logger.warn("Path contains \"WEB-INF\" or \"META-INF\".");
|
logger.warn("Path with \"WEB-INF\" or \"META-INF\": [" + path + "]");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (path.contains(":/")) {
|
if (path.contains(":/")) {
|
||||||
String relativePath = (path.charAt(0) == '/' ? path.substring(1) : path);
|
String relativePath = (path.charAt(0) == '/' ? path.substring(1) : path);
|
||||||
if (ResourceUtils.isUrl(relativePath) || relativePath.startsWith("url:")) {
|
if (ResourceUtils.isUrl(relativePath) || relativePath.startsWith("url:")) {
|
||||||
logger.warn("Path represents URL or has \"url:\" prefix.");
|
logger.warn("Path represents URL or has \"url:\" prefix: [" + path + "]");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (path.contains("..")) {
|
if (path.contains("..") && StringUtils.cleanPath(path).contains("../")) {
|
||||||
path = StringUtils.cleanPath(path);
|
logger.warn("Path contains \"../\" after call to StringUtils#cleanPath: [" + path + "]");
|
||||||
if (path.contains("../")) {
|
return true;
|
||||||
logger.warn("Path contains \"../\" after call to StringUtils#cleanPath.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -640,12 +640,9 @@ public class ResourceHttpRequestHandler extends WebContentGenerator
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (path.contains("..")) {
|
if (path.contains("..") && StringUtils.cleanPath(path).contains("../")) {
|
||||||
path = StringUtils.cleanPath(path);
|
logger.warn("Invalid Path contains \"../\" after call to StringUtils#cleanPath: [" + path + "]");
|
||||||
if (path.contains("../")) {
|
return true;
|
||||||
logger.warn("Invalid Path contains \"../\" after call to StringUtils#cleanPath.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,7 +417,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
||||||
else if (StompCommand.CONNECTED.equals(command)) {
|
else if (StompCommand.CONNECTED.equals(command)) {
|
||||||
this.stats.incrementConnectedCount();
|
this.stats.incrementConnectedCount();
|
||||||
accessor = afterStompSessionConnected(message, accessor, session);
|
accessor = afterStompSessionConnected(message, accessor, session);
|
||||||
if (this.eventPublisher != null && StompCommand.CONNECTED.equals(command)) {
|
if (this.eventPublisher != null) {
|
||||||
try {
|
try {
|
||||||
SimpAttributes simpAttributes = new SimpAttributes(session.getId(), session.getAttributes());
|
SimpAttributes simpAttributes = new SimpAttributes(session.getId(), session.getAttributes());
|
||||||
SimpAttributesContextHolder.setAttributes(simpAttributes);
|
SimpAttributesContextHolder.setAttributes(simpAttributes);
|
||||||
|
|
Loading…
Reference in New Issue