Skip to content

Commit ce91620

Browse files
committed
Merge branch '5.1.x'
2 parents 8a57997 + f359c11 commit ce91620

File tree

6 files changed

+104
-99
lines changed

6 files changed

+104
-99
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/InstantiationAwareBeanPostProcessor.java

Lines changed: 6 additions & 4 deletions
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-2019 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,8 +54,9 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor {
5454
* will be short-circuited. The only further processing applied is the
5555
* {@link #postProcessAfterInitialization} callback from the configured
5656
* {@link BeanPostProcessor BeanPostProcessors}.
57-
* <p>This callback will only be applied to bean definitions with a bean class.
58-
* In particular, it will not be applied to beans with a factory method.
57+
* <p>This callback will be applied to bean definitions with their bean class,
58+
* as well as to factory-method definitions in which case the returned bean type
59+
* will be passed in here.
5960
* <p>Post-processors may implement the extended
6061
* {@link SmartInstantiationAwareBeanPostProcessor} interface in order
6162
* to predict the type of the bean object that they are going to return here.
@@ -66,7 +67,8 @@ public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor {
6667
* or {@code null} to proceed with default instantiation
6768
* @throws org.springframework.beans.BeansException in case of errors
6869
* @see #postProcessAfterInstantiation
69-
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#hasBeanClass
70+
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#getBeanClass()
71+
* @see org.springframework.beans.factory.support.AbstractBeanDefinition#getFactoryMethodName()
7072
*/
7173
@Nullable
7274
default Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -140,68 +140,68 @@ protected void generateComparisonCode(MethodVisitor mv, CodeFlow cf, int compIns
140140
// This code block checks whether the left or right operand is null and handles
141141
// those cases before letting the original code (that only handled actual numbers) run
142142
Label rightIsNonNull = new Label();
143-
mv.visitInsn(DUP); // stack: left/right/right
144-
mv.visitJumpInsn(IFNONNULL, rightIsNonNull); // stack: left/right
143+
mv.visitInsn(DUP); // stack: left/right/right
144+
mv.visitJumpInsn(IFNONNULL, rightIsNonNull); // stack: left/right
145145
// here: RIGHT==null LEFT==unknown
146-
mv.visitInsn(SWAP); // right/left
146+
mv.visitInsn(SWAP); // right/left
147147
Label leftNotNullRightIsNull = new Label();
148-
mv.visitJumpInsn(IFNONNULL, leftNotNullRightIsNull); // stack: right
148+
mv.visitJumpInsn(IFNONNULL, leftNotNullRightIsNull); // stack: right
149149
// here: RIGHT==null LEFT==null
150-
mv.visitInsn(POP); // stack: <nothing>
150+
mv.visitInsn(POP); // stack: <nothing>
151151
// load 0 or 1 depending on comparison instruction
152152
switch (compInstruction1) {
153153
case IFGE: // OpLT
154154
case IFLE: // OpGT
155-
mv.visitInsn(ICONST_0); // false - null is not < or > null
155+
mv.visitInsn(ICONST_0); // false - null is not < or > null
156156
break;
157157
case IFGT: // OpLE
158158
case IFLT: // OpGE
159-
mv.visitInsn(ICONST_1); // true - null is <= or >= null
159+
mv.visitInsn(ICONST_1); // true - null is <= or >= null
160160
break;
161161
default:
162-
throw new IllegalStateException("Unsupported: "+compInstruction1);
162+
throw new IllegalStateException("Unsupported: " + compInstruction1);
163163
}
164164
mv.visitJumpInsn(GOTO, endOfIf);
165-
mv.visitLabel(leftNotNullRightIsNull); // stack: right
165+
mv.visitLabel(leftNotNullRightIsNull); // stack: right
166166
// RIGHT==null LEFT!=null
167-
mv.visitInsn(POP); // stack: <nothing>
167+
mv.visitInsn(POP); // stack: <nothing>
168168
// load 0 or 1 depending on comparison instruction
169169
switch (compInstruction1) {
170170
case IFGE: // OpLT
171171
case IFGT: // OpLE
172-
mv.visitInsn(ICONST_0); // false - something is not < or <= null
172+
mv.visitInsn(ICONST_0); // false - something is not < or <= null
173173
break;
174174
case IFLE: // OpGT
175175
case IFLT: // OpGE
176-
mv.visitInsn(ICONST_1); // true - something is > or >= null
176+
mv.visitInsn(ICONST_1); // true - something is > or >= null
177177
break;
178178
default:
179-
throw new IllegalStateException("Unsupported: "+compInstruction1);
179+
throw new IllegalStateException("Unsupported: " + compInstruction1);
180180
}
181181
mv.visitJumpInsn(GOTO, endOfIf);
182182

183-
mv.visitLabel(rightIsNonNull); // stack: left/right
183+
mv.visitLabel(rightIsNonNull); // stack: left/right
184184
// here: RIGHT!=null LEFT==unknown
185-
mv.visitInsn(SWAP); // stack: right/left
186-
mv.visitInsn(DUP); // stack: right/left/left
185+
mv.visitInsn(SWAP); // stack: right/left
186+
mv.visitInsn(DUP); // stack: right/left/left
187187
Label neitherRightNorLeftAreNull = new Label();
188-
mv.visitJumpInsn(IFNONNULL, neitherRightNorLeftAreNull); // stack: right/left
188+
mv.visitJumpInsn(IFNONNULL, neitherRightNorLeftAreNull); // stack: right/left
189189
// here: RIGHT!=null LEFT==null
190-
mv.visitInsn(POP2); // stack: <nothing>
190+
mv.visitInsn(POP2); // stack: <nothing>
191191
switch (compInstruction1) {
192192
case IFGE: // OpLT
193193
case IFGT: // OpLE
194-
mv.visitInsn(ICONST_1); // true - null is < or <= something
194+
mv.visitInsn(ICONST_1); // true - null is < or <= something
195195
break;
196196
case IFLE: // OpGT
197197
case IFLT: // OpGE
198-
mv.visitInsn(ICONST_0); // false - null is not > or >= something
198+
mv.visitInsn(ICONST_0); // false - null is not > or >= something
199199
break;
200200
default:
201-
throw new IllegalStateException("Unsupported: "+compInstruction1);
201+
throw new IllegalStateException("Unsupported: " + compInstruction1);
202202
}
203203
mv.visitJumpInsn(GOTO, endOfIf);
204-
mv.visitLabel(neitherRightNorLeftAreNull); // stack: right/left
204+
mv.visitLabel(neitherRightNorLeftAreNull); // stack: right/left
205205
// neither were null so unbox and proceed with numeric comparison
206206
if (unboxLeft) {
207207
CodeFlow.insertUnboxInsns(mv, targetType, leftDesc);

spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4994,7 +4994,7 @@ public void testNullComparison_SPR22358() {
49944994

49954995
private void verifyCompilationAndBehaviourWithNull(String expressionText, SpelExpressionParser parser, StandardEvaluationContext ctx) {
49964996
Reg r = (Reg)ctx.getRootObject().getValue();
4997-
r.setValue2(1); // having a value in value2 fields will enable compilation to succeed, then can switch it to null
4997+
r.setValue2(1); // having a value in value2 fields will enable compilation to succeed, then can switch it to null
49984998
SpelExpression fast = (SpelExpression) parser.parseExpression(expressionText);
49994999
SpelExpression slow = (SpelExpression) parser.parseExpression(expressionText);
50005000
fast.getValue(ctx);
@@ -5124,7 +5124,7 @@ public void repeatedCompilation() throws Exception {
51245124
}
51255125

51265126

5127-
// helper methods
5127+
// Helper methods
51285128

51295129
private SpelNodeImpl getAst() {
51305130
SpelExpression spelExpression = (SpelExpression) expression;
@@ -5196,69 +5196,7 @@ private void assertIsCompiled(Expression expression) {
51965196
}
51975197

51985198

5199-
// nested types
5200-
5201-
public class Reg {
5202-
private Integer _value,_value2;
5203-
private Long _valueL,_valueL2;
5204-
private Double _valueD,_valueD2;
5205-
private Float _valueF,_valueF2;
5206-
5207-
5208-
public Reg(int v) {
5209-
this._value = v;
5210-
this._valueL = new Long(v);
5211-
this._valueD = new Double(v);
5212-
this._valueF = new Float(v);
5213-
}
5214-
5215-
public Integer getValue() {
5216-
return _value;
5217-
}
5218-
5219-
public Long getValueL() {
5220-
return _valueL;
5221-
}
5222-
5223-
public Double getValueD() {
5224-
return _valueD;
5225-
}
5226-
5227-
public Float getValueF() {
5228-
return _valueF;
5229-
}
5230-
5231-
public Integer getValue2() {
5232-
return _value2;
5233-
}
5234-
5235-
public Long getValueL2() {
5236-
return _valueL2;
5237-
}
5238-
5239-
public Double getValueD2() {
5240-
return _valueD2;
5241-
}
5242-
5243-
public Float getValueF2() {
5244-
return _valueF2;
5245-
}
5246-
5247-
public void setValue(Integer value) {
5248-
_value = value;
5249-
_valueL = value==null?null:new Long(value);
5250-
_valueD = value==null?null:new Double(value);
5251-
_valueF = value==null?null:new Float(value);
5252-
}
5253-
5254-
public void setValue2(Integer value) {
5255-
_value2 = value;
5256-
_valueL2 = value==null?null:new Long(value);
5257-
_valueD2 = value==null?null:new Double(value);
5258-
_valueF2 = value==null?null:new Float(value);
5259-
}
5260-
}
5261-
5199+
// Nested types
52625200

52635201
public interface Message<T> {
52645202

@@ -6276,4 +6214,66 @@ public static class LongHolder {
62766214
public Long someLong = 3L;
62776215
}
62786216

6217+
6218+
public class Reg {
6219+
6220+
private Integer _value,_value2;
6221+
private Long _valueL,_valueL2;
6222+
private Double _valueD,_valueD2;
6223+
private Float _valueF,_valueF2;
6224+
6225+
public Reg(int v) {
6226+
this._value = v;
6227+
this._valueL = new Long(v);
6228+
this._valueD = new Double(v);
6229+
this._valueF = new Float(v);
6230+
}
6231+
6232+
public Integer getValue() {
6233+
return _value;
6234+
}
6235+
6236+
public Long getValueL() {
6237+
return _valueL;
6238+
}
6239+
6240+
public Double getValueD() {
6241+
return _valueD;
6242+
}
6243+
6244+
public Float getValueF() {
6245+
return _valueF;
6246+
}
6247+
6248+
public Integer getValue2() {
6249+
return _value2;
6250+
}
6251+
6252+
public Long getValueL2() {
6253+
return _valueL2;
6254+
}
6255+
6256+
public Double getValueD2() {
6257+
return _valueD2;
6258+
}
6259+
6260+
public Float getValueF2() {
6261+
return _valueF2;
6262+
}
6263+
6264+
public void setValue(Integer value) {
6265+
_value = value;
6266+
_valueL = value==null?null:new Long(value);
6267+
_valueD = value==null?null:new Double(value);
6268+
_valueF = value==null?null:new Float(value);
6269+
}
6270+
6271+
public void setValue2(Integer value) {
6272+
_value2 = value;
6273+
_valueL2 = value==null?null:new Long(value);
6274+
_valueD2 = value==null?null:new Double(value);
6275+
_valueF2 = value==null?null:new Float(value);
6276+
}
6277+
}
6278+
62796279
}

spring-tx/src/main/java/org/springframework/transaction/annotation/Propagation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ public enum Propagation {
8787

8888
/**
8989
* Execute within a nested transaction if a current transaction exists,
90-
* behave like {@code REQUIRED} else. There is no analogous feature in EJB.
90+
* behave like {@code REQUIRED} otherwise. There is no analogous feature in EJB.
9191
* <p>Note: Actual creation of a nested transaction will only work on specific
9292
* transaction managers. Out of the box, this only applies to the JDBC
93-
* DataSourceTransactionManager when working on a JDBC 3.0 driver.
94-
* Some JTA providers might support nested transactions as well.
93+
* DataSourceTransactionManager. Some JTA providers might support nested
94+
* transactions as well.
9595
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager
9696
*/
9797
NESTED(TransactionDefinition.PROPAGATION_NESTED);

spring-tx/src/main/java/org/springframework/transaction/support/AbstractPlatformTransactionManager.java

Lines changed: 4 additions & 2 deletions
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-2019 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.
@@ -553,7 +553,7 @@ protected int determineTimeout(TransactionDefinition definition) {
553553
if (definition.getTimeout() != TransactionDefinition.TIMEOUT_DEFAULT) {
554554
return definition.getTimeout();
555555
}
556-
return this.defaultTimeout;
556+
return getDefaultTimeout();
557557
}
558558

559559

@@ -1099,6 +1099,8 @@ protected boolean useSavepointForNestedTransaction() {
10991099
* @param definition a TransactionDefinition instance, describing propagation
11001100
* behavior, isolation level, read-only flag, timeout, and transaction name
11011101
* @throws TransactionException in case of creation or system errors
1102+
* @throws org.springframework.transaction.NestedTransactionNotSupportedException
1103+
* if the underlying transaction does not support nesting
11021104
*/
11031105
protected abstract void doBegin(Object transaction, TransactionDefinition definition)
11041106
throws TransactionException;

spring-tx/src/main/java/org/springframework/transaction/support/TransactionSynchronizationManager.java

Lines changed: 4 additions & 3 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-2019 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,10 +292,11 @@ public static void registerSynchronization(TransactionSynchronization synchroniz
292292
throws IllegalStateException {
293293

294294
Assert.notNull(synchronization, "TransactionSynchronization must not be null");
295-
if (!isSynchronizationActive()) {
295+
Set<TransactionSynchronization> synchs = synchronizations.get();
296+
if (synchs == null) {
296297
throw new IllegalStateException("Transaction synchronization is not active");
297298
}
298-
synchronizations.get().add(synchronization);
299+
synchs.add(synchronization);
299300
}
300301

301302
/**

0 commit comments

Comments
 (0)