Skip to content

Commit 049eb98

Browse files
committed
Merge branch '5.3.x'
2 parents e0b4058 + 3ff3084 commit 049eb98

File tree

6 files changed

+133
-98
lines changed

6 files changed

+133
-98
lines changed

framework-docs/src/docs/asciidoc/integration.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4414,7 +4414,7 @@ asterisk.
44144414
* Two numbers separated with a hyphen (`-`) express a range of numbers.
44154415
The specified range is inclusive.
44164416
* Following a range (or `*`) with `/` specifies the interval of the number's value through the range.
4417-
* English names can also be used for the day-of-month and day-of-week fields.
4417+
* English names can also be used for the month and day-of-week fields.
44184418
Use the first three letters of the particular day or month (case does not matter).
44194419
* The day-of-month and day-of-week fields can contain a `L` character, which has a different meaning
44204420
** In the day-of-month field, `L` stands for _the last day of the month_.

framework-docs/src/docs/asciidoc/web/webflux.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ extracts the name, version, and file extension:
15631563

15641564
URI path patterns can also have embedded `${...}` placeholders that are resolved on startup
15651565
through `PropertySourcesPlaceholderConfigurer` against local, system, environment, and
1566-
other property sources. You ca use this to, for example, parameterize a base URL based on
1566+
other property sources. You can use this to, for example, parameterize a base URL based on
15671567
some external configuration.
15681568

15691569
NOTE: Spring WebFlux uses `PathPattern` and the `PathPatternParser` for URI path matching support.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -32,6 +32,7 @@
3232
*
3333
* @author Andy Clement
3434
* @author Juergen Hoeller
35+
* @author Sam Brannen
3536
* @since 3.0
3637
*/
3738
public class Elvis extends SpelNodeImpl {
@@ -64,7 +65,7 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep
6465

6566
@Override
6667
public String toStringAST() {
67-
return getChild(0).toStringAST() + " ?: " + getChild(1).toStringAST();
68+
return "(" + getChild(0).toStringAST() + " ?: " + getChild(1).toStringAST() + ")";
6869
}
6970

7071
@Override

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2022 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.
@@ -32,6 +32,7 @@
3232
*
3333
* @author Andy Clement
3434
* @author Juergen Hoeller
35+
* @author Sam Brannen
3536
* @since 3.0
3637
*/
3738
public class Ternary extends SpelNodeImpl {
@@ -62,7 +63,7 @@ public TypedValue getValueInternal(ExpressionState state) throws EvaluationExcep
6263

6364
@Override
6465
public String toStringAST() {
65-
return getChild(0).toStringAST() + " ? " + getChild(1).toStringAST() + " : " + getChild(2).toStringAST();
66+
return "(" + getChild(0).toStringAST() + " ? " + getChild(1).toStringAST() + " : " + getChild(2).toStringAST() + ")";
6667
}
6768

6869
private void computeExitTypeDescriptor() {

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ void createObjectsOnAttemptToReferenceNull() {
116116
void elvisOperator() {
117117
evaluate("'Andy'?:'Dave'", "Andy", String.class);
118118
evaluate("null?:'Dave'", "Dave", String.class);
119+
evaluate("3?:1", 3, Integer.class);
120+
evaluate("(2*3)?:1*10", 6, Integer.class);
121+
evaluate("null?:2*10", 20, Integer.class);
122+
evaluate("(null?:1)*10", 10, Integer.class);
119123
}
120124

121125
@Test
@@ -624,6 +628,24 @@ void ternaryOperator05() {
624628
evaluate("2>4?(3>2?true:false):(5<3?true:false)", false, Boolean.class);
625629
}
626630

631+
@Test
632+
void ternaryOperator06() {
633+
evaluate("3?:#var=5", 3, Integer.class);
634+
evaluate("null?:#var=5", 5, Integer.class);
635+
evaluate("2>4?(3>2?true:false):(5<3?true:false)", false, Boolean.class);
636+
}
637+
638+
@Test
639+
void ternaryExpressionWithImplicitGrouping() {
640+
evaluate("4 % 2 == 0 ? 2 : 3 * 10", 2, Integer.class);
641+
evaluate("4 % 2 == 1 ? 2 : 3 * 10", 30, Integer.class);
642+
}
643+
644+
@Test
645+
void ternaryExpressionWithExplicitGrouping() {
646+
evaluate("((4 % 2 == 0) ? 2 : 1) * 10", 20, Integer.class);
647+
}
648+
627649
@Test
628650
void ternaryOperatorWithNullValue() {
629651
assertThatExceptionOfType(EvaluationException.class).isThrownBy(

0 commit comments

Comments
 (0)