Commit Graph

472 Commits

Author SHA1 Message Date
Sam Brannen
0882ca57d4 Polishing 2023-03-20 00:06:32 +01:00
Sam Brannen
94bbf85c0e Stop printing to System.out in SpEL tests 2023-03-20 00:06:24 +01:00
Sam Brannen
41d71e9a7f Revise contribution
See gh-25316
2023-03-15 14:30:53 +01:00
mrcoffee77
36682b7ad2 Ensure methods declared in Object can be invoked on a JDK proxy in SpEL
This commit ensures that methods declared in java.lang.Object (such as
toString() can be invoked on a JDK proxy instance in a SpEL expression.

Closes gh-25316
2023-03-15 14:30:53 +01:00
Sam Brannen
30601a5014 Polishing 2023-03-15 14:30:53 +01:00
Juergen Hoeller
6a81ed3a50 Polishing 2023-03-08 17:43:35 +01:00
Juergen Hoeller
42e7318cbb Polishing 2023-01-31 16:48:36 +01:00
Sam Brannen
72285034ba Support arrays in AST string representations of SpEL expressions
Prior to this commit, SpEL's ConstructorReference did not provide
support for arrays when generating a string representation of the
internal AST. For example, 'new String[3]' was represented as 'new
String()' instead of 'new String[3]'.

This commit introduces support for standard array construction and array
construction with initializers in ConstructorReference's toStringAST()
implementation.

Closes gh-29666
2022-12-08 23:23:01 -05:00
Sam Brannen
4e8aebcde7 Fix SpEL support for quotes within String literals
Prior to this commit, there were two bugs in the support for quotes
within String literals in SpEL expressions.

- Two double quotes ("") or two single quotes ('') were always replaced
  with one double quote or one single quote, respectively, regardless
  of which quote character was used to enclose the original String
  literal. This resulted in the loss of one of the double quotes when
  the String literal was enclosed in single quotes, and vice versa. For
  example, 'x "" y' became 'x " y'.

- A single quote which was properly escaped in a String literal
  enclosed within single quotes was not escaped in the AST string
  representation of the expression. For example, 'x '' y' became 'x ' y'.

This commit fixes both of these related issues in StringLiteral and
overhauls the structure of ParsingTests.

Closes gh-29604
Closes gh-28356
2022-12-07 16:03:49 -05:00
Sam Brannen
dff5b1ff8e Polishing 2022-12-07 15:59:08 -05:00
Sam Brannen
41a6b7ec20 Update copyright headers for source code changed since August 2022
The changes in this commit were performed using the newly introduced
update_copyright_headers.sh script.
2022-12-03 17:23:21 -05:00
Sam Brannen
b6abf45a56 Introduce @Suite classes for individual modules 2022-12-03 16:32:27 -05:00
Sam Brannen
27f3feea1a Ensure SpEL ternary and Elvis expressions are enclosed in parentheses in toStringAST()
Prior to this commit, ternary and Elvis expressions enclosed in
parentheses (to account for operator precedence) were properly parsed
and evaluated; however, the corresponding toStringAST() implementations
did not enclose the results in parentheses. Consequently, the string
representation of the ASTs did not reflect the original semantics of
such expressions.

For example, given "(4 % 2 == 0 ? 1 : 0) * 10" as the expression to
parse and evaluate, the result of toStringAST() was previously
"(((4 % 2) == 0) ? 1 : 0 * 10)" instead of
"((((4 % 2) == 0) ? 1 : 0) * 10)", implying that 0 should be multiplied
by 10 instead of multiplying the result of the ternary expression by 10.

This commit addresses this by ensuring that SpEL ternary and Elvis
expressions are enclosed in parentheses in toStringAST().

Closes gh-29463
2022-11-11 17:11:07 +01:00
Sam Brannen
b42b785cd1 Polish ParsingTests 2022-11-11 17:10:57 +01:00
Marc Wrobel
ce49068ff9 Fix links in Javadoc and reference docs
- Fix broken links (by using a new URL, an alternative URL, or a
  Wayback Machine link)

- Use HTTPS where possible

- Remove https://issuetracker.springsource.com/browse/EBR-349: this
  link is dead and is also mentioned in
  https://jira.spring.io/browse/SPR-8093

- Clean up nohttp allowlist.lines

Closes gh-28876
2022-09-14 17:00:11 +02:00
Marc Wrobel
92a231cf91 Fix typos in Javadoc, reference docs, and code
Closes gh-28822
2022-09-14 16:45:34 +02:00
Marc Wrobel
bd3499671c Fix typos in test code
This commit fixes typos in test class names, test method names, and
test variable names.

Closes gh-28807
2022-07-13 16:24:11 +02:00
Marc Wrobel
91258271e4 Fix and improve Javadoc in spring-expression
Closes gh-28800
2022-07-13 14:01:41 +02:00
Sam Brannen
1beb7068f6 Use new AssertJ exception assertions 2022-05-31 14:08:28 +02:00
Sam Brannen
4fcfa5b991 Update and simplify ArrayConstructorTests 2022-05-03 14:27:48 +02:00
Juergen Hoeller
4143b445d6 Polishing 2022-04-08 13:04:14 +02:00
izeye
135506f672 Update copyright year of EvaluationTests
See gh-28238
2022-03-27 09:55:58 +02:00
Sam Brannen
83ac659158 Improve diagnostics in SpEL for large array creation
Attempting to create a large array in a SpEL expression can result in
an OutOfMemoryError. Although the JVM recovers from that, the error
message is not very helpful to the user.

This commit improves the diagnostics in SpEL for large array creation
by throwing a SpelEvaluationException with a meaningful error message
in order to improve diagnostics for the user.

Closes gh-28145
2022-03-09 11:07:45 +01:00
Sam Brannen
84de100fc6 Polishing 2022-02-28 17:15:43 +01:00
Sam Brannen
beab8ab4e7 Test claims regarding SpEL support for T(Character)
See gh-28112
2022-02-28 17:15:43 +01:00
Sam Brannen
84b4cebb39 Fix (@)since tag in SpelMessage
See gh-28043
2022-02-19 16:54:16 +01:00
Sam Brannen
94af2ca06b Recover from error during SpEL MIXED mode compilation
Prior to this commit, SpEL was able to recover from an error that
occurred while running a CompiledExpression; however, SpEL was not able
to recover from an error that occurred while compiling the expression
(such as a java.lang.VerifyError). The latter can occur when multiple
threads concurrently change types involved in the expression, such as
the concrete type of a custom variable registered via
EvaluationContext.setVariable(...), which can result in SpEL generating
invalid bytecode.

This commit addresses this issue by catching exceptions thrown while
compiling an expression and updating the `failedAttempts` and
`interpretedCount` counters accordingly. If an exception is caught
while operating in SpelCompilerMode.IMMEDIATE mode, the exception will
be propagated via a SpelEvaluationException with a new
SpelMessage.EXCEPTION_COMPILING_EXPRESSION error category.

Closes gh-28043
2022-02-18 15:31:59 +01:00
Juergen Hoeller
bc9cd9a687 Find interface method even for late-bound interface declaration in subclass
Closes gh-27995
2022-02-04 23:21:27 +01:00
Sam Brannen
df263d01b9 Use idiomatic AssertJ assertions for true, false, and null 2022-01-10 14:15:55 +01:00
Sam Brannen
518dc6df65 Polishing 2022-01-08 17:06:25 +01:00
Sam Brannen
59c6b7e445 Fix SpEL withTypedRootObject() test 2022-01-08 17:06:25 +01:00
justlikeliuen
3e75ec73ab Fix SpEL withRootObject test
The test case is intended to be for the method 'withRootObject()', but
actually it's copied from the previous test method that does not use
'withRootObject()'.

This commit fixes the propertyReadWriteWithRootObject() test method in
PropertyAccessTests.

Closes gh-27905
2022-01-08 17:06:25 +01:00
Sam Brannen
b2e94f611f Convert single null argument to Optional.empty() in SpEL varargs expression
Prior to this commit, if a single null value was passed to a method with
a varargs array of type java.util.Optional, that null value was passed
unmodified. On the contrary, a null passed with additional values to
such a method resulted in the null being converted to Optional.empty().

This commit ensures that a single null value is also converted to
Optional.empty() for such SpEL expressions.

Closes gh-27795
2021-12-10 13:53:28 +01:00
Sam Brannen
ad7cdc5ce9 Fix regression for null varargs in SpEL expressions
A regression was introduced in gh-27582. Specifically, when null is
supplied as the single argument for a varargs parameter in a method or
function in a SpEL expression, ReflectionHelper currently throws a
NullPointerException instead of leaving the null value unchanged.

This commit fixes this regression.

Closes gh-27719
2021-12-10 13:12:44 +01:00
Sam Brannen
b728b4640b Add explicit tests for SpEL functions for fix for gh-27582 2021-10-22 13:46:11 +02:00
Sam Brannen
bc657eb4d5 Fix SpEL vararg method invocation for strings containing commas
Prior to this commit, if a SpEL expression invoked a method or
registered function that declares a String varargs argument, there were
sometimes issues with converting the input arguments into the varargs
array argument. Specifically, if the expression supplied a single
String argument containing a comma for the varargs (such as "a,b"),
SpEL's ReflectionHelper.convertArguments() method incorrectly converted
that single String to an array via the ConversionService, which
indirectly converted that String using the StringToArrayConverter,
which converts a comma-delimited String to an array. Thus, "a,b"
effectively got converted to a two-dimensional array ["a", "b"] instead
of simply ["a,b"].

This commit fixes this bug by avoiding use of the TypeConverter and
ConversionService for single arguments supplied as varargs when the
single argument's type matches the varargs array component type.

Closes gh-27582
2021-10-22 13:13:13 +02:00
Sam Brannen
9b967775ed Polish Spel's ReflectionHelper.setupArgumentsForVarargsInvocation() 2021-10-22 11:08:45 +02:00
Sam Brannen
9af11ad5ce Fix Javadoc formatting issues 2021-10-22 11:08:45 +02:00
Sam Brannen
2567b20949 Upgrade to spring-javaformat 0.0.28 and downgrade to Checkstyle 8.41
In order to be able to use text blocks and other new Java language
features, we are upgrading to a recent version of Checkstyle.

The latest version of spring-javaformat-checkstyle (0.0.28) is built
against Checkstyle 8.32 which does not include support for language
features such as text blocks. Support for text blocks was added in
Checkstyle 8.36.

In addition, there is a binary compatibility issue between
spring-javaformat-checkstyle 0.0.28 and Checkstyle 8.42. Thus we cannot
use Checkstyle 8.42 or higher.

In this commit, we therefore upgrade to spring-javaformat-checkstyle
0.0.28 and downgrade to Checkstyle 8.41.

This change is being applied to `5.3.x` as well as `main` in order to
benefit from the enhanced checking provided in more recent versions of
Checkstyle.

Closes gh-27481
2021-09-28 10:29:31 +02:00
Juergen Hoeller
211f0bbf88 Fix invalid characters in source files
Closes gh-27475
2021-09-27 16:57:54 +02:00
Juergen Hoeller
0dc5d2794f Avoid early ConversionService determination in StandardBeanExpressionResolver
Closes gh-27446
2021-09-21 17:42:50 +02:00
Juergen Hoeller
b8b85a6a59 Defensive handling of dimensions nullability 2021-09-14 21:49:23 +02:00
Brian Clozel
cecc0849a8 Upgrade to Gradle 7.2
This commit upgrades Gradle to 7.2.
Gradle configuration names are updated accordingly.
This also upgrades Gradle build plugins.

See gh-26870
2021-09-13 09:37:35 +02:00
Syuziko
eaf9deedfd Polish tests
See gh-27248
2021-08-07 18:53:47 +02:00
Stephane Nicoll
403e1f2505 Update copyright year of changed file
See gh-27102
2021-07-02 08:11:41 +02:00
diguage
f39c6d36c7 Simplify Comparator using method references
See gh-27102
2021-07-02 08:10:22 +02:00
Sam Brannen
a2ef6badc4 Use StringBuilder.append(char) where possible
To slightly improve performance, this commit switches to
StringBuilder.append(char) instead of StringBuilder.append(String)
whenever we append a single character to a StringBuilder.

Closes gh-27098
2021-06-25 10:44:28 +02:00
Sam Brannen
7c3a18490b Polish SpEL SelectionAndProjectionTests 2021-04-26 16:23:21 +02:00
Sam Brannen
6c3a0a9026 Polishing 2021-04-22 18:53:31 +02:00
Brandon Fergerson
432c720dd0 Allow spring-expression to be more easily repackaged
This commit allows the spring-expression module to be more easily repackaged
for embedding in third-party JARs -- for example, via the Shadow Gradle plugin.

Closes gh-26779
2021-04-09 17:29:29 +02:00