Commit Graph

402 Commits

Author SHA1 Message Date
Sam Brannen
90cfde985e 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-28257
2022-03-31 10:25:27 +02:00
Sam Brannen
e03e62c76a Test status quo for null in varargs in SpEL expressions
This commit also points out that `null` supplied as a single value for
a varargs array of type Optional will be kept as `null` instead of being
converted to Optional.empty(); whereas, if more than one value is passed
to such a varargs array a null value will be properly converted to
Optional.empty().

See gh-27719
2021-12-10 11:18:10 +01:00
Juergen Hoeller
b01a3aeb6b Fix invalid characters in source files
Closes gh-27475
2021-09-27 17:42:27 +02:00
Juergen Hoeller
fb97a126a5 Defensive handling of dimensions nullability 2021-09-14 21:54:42 +02:00
Juergen Hoeller
396fdf125f Remove duplicate "property" in PropertyCacheKey.toString()
Closes gh-26237
2020-12-08 15:03:33 +01:00
Juergen Hoeller
240cfb1224 Polishing 2020-11-16 17:50:15 +01:00
Juergen Hoeller
5b06c23a1b Consistent javadoc within SpelCompiler 2020-11-05 18:33:12 +01:00
Juergen Hoeller
7881329cf7 Polishing 2020-11-05 18:18:38 +01:00
Sam Brannen
449377908f Fix JUnit 4 to AssertJ migration bugs
The migration from JUnit 4 assertions to AssertJ assertions resulted in
several unnecessary casts from int to long that actually cause
assertions to pass when they should otherwise fail.

This commit fixes all such bugs for the pattern `.isNotEqualTo((long)`.
2020-10-26 14:53:09 +01:00
Juergen Hoeller
c368ce8223 Fix SpEL generated code for default method invocation
Closes gh-25706
2020-09-05 12:59:12 +02:00
陈其苗
13970ae528 Use autoboxing instead of explicit wrapping in tests
Closes gh-24801
2020-04-01 14:34:20 +02:00
Sam Brannen
e26764d249 Remove duplicate words in documentation and polish Javadoc 2020-03-31 12:17:58 +02:00
Sam Brannen
c3bc28762e Delete unused import in ExpressionLanguageScenarioTests
See gh-24586
2020-02-26 14:09:01 +01:00
ZhangT
c5fb7b9fb7 Simplify some redundant code
Closes gh-24586

Co-authored-by: Sam Brannen <sbrannen@pivotal.io>
2020-02-26 12:29:09 +01:00
Sam Brannen
a9d9b76d09 Support SpEL compilation of interface methods again
Spring Framework 5.1.8 introduced a regression for the compilation of
SpEL expressions referencing a method declared in an interface. An
attempt to compile such an expression resulted in a
SpelEvaluationException caused by an IncompatibleClassChangeError.

This commit fixes this regression by adding explicit support in
ReflectivePropertyAccessor.OptimalPropertyAccessor.generateCode() for
methods declared in interfaces.

Closes gh-24357
2020-02-12 15:33:01 +01:00
Juergen Hoeller
259ffe9b3b Thread-safe compiled expression evaluation in SpelExpression
Closes gh-24265
2020-01-08 18:37:07 +01:00
Sam Brannen
4260c34b47 Rename test fixture package in spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Sam Brannen
5718bf424b Use Gradle test fixture support for spring-core
See gh-23550
2020-01-02 16:01:34 +01:00
Sébastien Deleuze
7646895fd4 Support Kotlin synthetic classes in MethodParameter and SpEL
Closes gh-23812
2019-11-13 14:22:53 +01:00
stsypanov
f5ae3c77c6 Use Method::getParameterCount where possible 2019-11-07 18:00:15 +01:00
Sam Brannen
734ceed301 Polish contribution
See gh-23658
2019-09-19 22:02:19 +02:00
i321222
fde7b1e545 Avoid ArrayIndexOutOfBoundsException in SpEL's Indexer
When index == arrayLength, the array index is also out of bounds.

For this scenario, a SpelEvaluationException should be thrown instead
of ArrayIndexOutOfBoundsException.

Closes gh-23658
2019-09-19 22:01:10 +02:00
Sam Brannen
2b460854ce Polishing 2019-09-12 13:16:48 +02:00
Sam Brannen
e124cbb310 Fix Checkstyle violation 2019-09-12 13:15:58 +02:00
OLPMO
40fcf876ce Optimize test code with lambdas where feasible
This commit optimizes test code with lambda expressions
and method references where feasible.

Closes gh-23626
2019-09-12 13:09:31 +02:00
Sam Brannen
30cff46e7f Prevent improper use of testing framework APIs
Prior to this commit, a lot of work had been done to prevent improper
use of testing Framework APIs throughout the codebase; however, there
were still some loopholes.

This commit addresses these loopholes by introducing additional
Checkstyle rules (and modifying existing rules) to prevent improper use
of testing framework APIs in production code as well as in test code.

- Checkstyle rules for banned imports have been refactored into
  multiple rules specific to JUnit 3, JUnit 4, JUnit Jupiter, and
  TestNG.
- Accidental usage of org.junit.Assume has been switched to
  org.junit.jupiter.api.Assumptions.
- All test classes now reside under org.springframework packages.
- All test classes (including abstract test classes) now conform to the
  `*Tests` naming convention.
  - As an added bonus, tests in the renamed
    ScenariosForSpringSecurityExpressionTests are now included in the
    build.
- Dead JUnit 4 parameterized code has been removed from
  DefaultServerWebExchangeCheckNotModifiedTests.

Closes gh-22962
2019-09-12 11:20:56 +02:00
Sebastien Deleuze
72e92da2ad Make SpEL rootObject parameter nullable
Closes gh-23442
2019-08-29 11:02:31 +02:00
Sam Brannen
46a37b447c Fix copyright dates
See gh-23393
2019-08-27 19:30:05 +02:00
stsypanov
78d56dc61b Use Arrays.copyOf and Arrays.copyOfRange where possible
Closes gh-23393
2019-08-27 19:18:39 +02:00
Sam Brannen
ad6231ad29 Add missing @Override annotations 2019-08-23 13:50:58 +02:00
Sam Brannen
288461a541 Introduce @EnabledForTestGroups in Spring's test suite
Closes gh-23476
2019-08-17 14:47:24 +02:00
Sam Brannen
3f3e41923f Migrate rest of test suite from JUnit 4 to JUnit Jupiter
This commit migrates the rest of Spring's test suite to JUnit Jupiter,
except spring-test which will be migrated in a separate commit.

See gh-23451
2019-08-17 11:36:58 +02:00
Juergen Hoeller
a5cb8799fa Merge branch '5.1.x' 2019-07-05 18:22:02 +02:00
Juergen Hoeller
a1eae42fd0 Expose implementation method for annotation introspection purposes
Closes gh-23210
2019-07-05 17:07:44 +02:00
Juergen Hoeller
0a77477d32 Merge branch '5.1.x' 2019-06-12 18:16:30 +02:00
Juergen Hoeller
fc46abf0b7 Polishing 2019-06-12 18:04:06 +02:00
Juergen Hoeller
7e02358166 Merge branch '5.1.x' 2019-06-12 00:05:01 +02:00
Juergen Hoeller
33b5bc2aae Polishing 2019-06-11 23:50:29 +02:00
Juergen Hoeller
a89bfffd8c Merge branch '5.1.x' 2019-06-11 23:16:03 +02:00
Juergen Hoeller
7dc92aa05d Polishing 2019-06-11 20:57:27 +02:00
Juergen Hoeller
dec6d69819 ReflectivePropertyAccessor uses interface methods if possible
Closes gh-22242
2019-06-11 20:54:29 +02:00
Sam Brannen
08afe5d22b Polishing 2019-06-07 19:45:51 +03:00
Сергей Цыпанов
e352e9ddaa Simplify comparison of primitives
Closes gh-23098
2019-06-07 18:14:04 +02:00
Sebastien Deleuze
098ac0bbb8 Annotate Object#equals parameter with @Nullable
Closes gh-23093
2019-06-06 14:18:30 +02:00
Сергей Цыпанов
7ef8cc9faf Tiny improvements regarding ArrayList creation
Closes gh-23047
2019-05-28 16:08:58 +02:00
Sam Brannen
bdf3960283 Suppress warnings in Gradle build 2019-05-27 12:15:50 +02:00
Phillip Webb
9d74da006c Migrate JUnit 4 assertions to AssertJ
Migrate all existing JUnit 4 `assert...` based assertions to AssertJ
and add a checkstyle rule to ensure they don't return.

See gh-23022
2019-05-23 15:52:49 -07:00
Phillip Webb
95a9d46a87 Migrate Hamcrest assertions to AssertJ
Migrate all existing `assertThat(..., Matcher)` assertions to AssertJ
and add checkstyle rules to ensure they don't return.

See gh-23022
2019-05-23 15:49:59 -07:00
stsypanov
6f07a504b8 A couple of trivial simplifications 2019-05-20 21:41:15 +02:00
Phillip Webb
02850f357f Migrate exception checking tests to use AssertJ
Migrate tests that use `@Test(expectedException=...)` or
`try...fail...catch` to use AssertJ's `assertThatException`
instead.
2019-05-20 10:47:53 -07:00