Commit Graph

27955 Commits

Author SHA1 Message Date
christophejan
8d4ea72e4e Skip release connection after nested with existing transaction 2023-09-11 14:20:37 +02:00
Sam Brannen
5c7bf0c2fe Add tests for MethodInvoker behavior in the TestContext framework
See gh-31199
2023-09-11 13:15:21 +02:00
Sam Brannen
4aeeacb4c2 Simplify and rename TestContextManager[ListenerExecutionOrder]Tests 2023-09-11 13:11:16 +02:00
rstoyanchev
38a9c2ceeb Polishing contribution
See gh-31164
2023-09-11 11:27:25 +01:00
Dmitrii Bocharov
fe8e6d3d5a Merge MultipartFileArgumentResolver into RequestPartArgumentResolver
Also add test with Optional parameter for a RequestPart argument.

See gh-31164

Signed-off-by: Dmitrii Bocharov <bdshadow@gmail.com>
2023-09-11 11:27:25 +01:00
Brian Clozel
f83c609436 Polish
This commit replaces the initial allocation size for the content caching
buffer by a `FastByteArrayOutputStream`. With this variant, allocations
are cheap and we don't need to apply heuristics anymore to guess the
best initial buffer size.

See gh-29775
2023-09-11 10:58:01 +02:00
Ryan Rupp
6de0be16c2 Optimize initial buffer size in ContentCachingRequestWrapper
Prior to this commit, the initial buffer size for content caching
allocated in `ContentCachingRequestWrapper` would be:

* the request content length, if available in request headers
* the cache limit size as configured on the wrapper

The latter is really an upper bound and should not be considered as a
good default in most cases. This commit ensures that the request content
length is still used if available, but uses a default 1024 size if it's
not.

While this change will probably cause more reallocations as the buffer
grows, this will avoid large allocations in many cases and should
overall help with GC.

Closes gh-29775
2023-09-11 10:36:40 +02:00
Sam Brannen
ed83461021 Support parameter injection in @[Before|After]Transaction methods
Prior to this commit, @​BeforeTransaction and @​AfterTransaction
methods could not accept any arguments. This is acceptable with testing
frameworks such as JUnit 4 and TestNG that do not provide support for
parameter injection. However, users of JUnit Jupiter have become
accustomed to being able to accept arguments in lifecycle methods
annotated with JUnit's @​BeforeEach, @​AfterEach, etc.

As a follow up to the previous commit (see gh-31199), this commit
introduces first-class support for parameter injection in
@​BeforeTransaction and @​AfterTransaction methods, as demonstrated in
the following example.

@​BeforeTransaction
void verifyInitialDatabaseState(@Autowired DataSource dataSource) {
	// Use the DataSource to verify the initial DB state
}

Closes gh-30736
2023-09-10 20:15:26 +02:00
Sam Brannen
41904d46ad Introduce MethodInvoker API for TestExecutionListeners
In order to be able to support parameter injection in
@​BeforeTransaction and @​AfterTransaction methods (see gh-30736), this
commit introduces a MethodInvoker API for TestExecutionListeners as a
generic mechanism for delegating to the underlying testing framework to
invoke methods.

The default implementation simply invokes the method without arguments,
which allows TestExecutionListeners using this mechanism to operate
correctly when the underlying testing framework is JUnit 4, TestNG, etc.

A JUnit Jupiter specific implementation is registered in the
SpringExtension which delegates to the
ExtensionContext.getExecutableInvoker() mechanism introduced in JUnit
Jupiter 5.9. This allows a TestExecutionListener to transparently
benefit from registered ParameterResolvers in JUnit Jupiter (including
the SpringExtension) when invoking user methods, effectively providing
support for parameter injection for arbitrary methods.

Closes gh-31199
2023-09-10 20:15:12 +02:00
Sam Brannen
0ebdd8cb98 Polishing 2023-09-10 20:15:04 +02:00
Sam Brannen
b082f546ec Polishing 2023-09-10 14:59:21 +02:00
liaozan
9728b8cefd Use Method#isDefault to find default methods in interfaces
Closes gh-31197
2023-09-10 14:53:05 +02:00
Sam Brannen
6ca01e15cf Polishing 2023-09-10 14:50:47 +02:00
Toshiaki Maki
588b5a45f8 Pass correct SqlParameterSource to NamedParameterJdbcTemplate in DefaultJdbcClient
Prior to this commit, when using RowCallbackHandler or ResultSetExtractor in JdbcClient
and passing a parameter to paramSource(), an exception was thrown stating "No value
supplied for the SQL parameter 'xxxxxx'" because the SqlParameterSource used internally
was the wrong one.

Closes gh-31195
2023-09-10 14:42:54 +02:00
Sam Brannen
436c7136e9 Polish TransactionAssert 2023-09-10 14:37:28 +02:00
Sam Brannen
7305692005 Merge branch '6.0.x' 2023-09-10 14:37:01 +02:00
Zakaria Shahen
11dc11e989 Fix typo in comment in XML configuration example
Closes gh-31194
2023-09-10 14:36:17 +02:00
Sam Brannen
0f36c5fd6a Polishing 2023-09-08 20:12:44 +02:00
Sam Brannen
60d05d4204 Polishing 2023-09-08 19:29:28 +02:00
Sam Brannen
dfea3d05aa Revise support for JSR-330 and Jakarta @Inject for autowiring test constructors
Closes gh-29851
2023-09-08 19:29:28 +02:00
Florian Lehmann
8dd857a84d Support @Inject from JSR-330 & Jakarta for autowiring test constructors
See gh-29851
2023-09-08 19:26:39 +02:00
Brian Clozel
0f945873a3 Only reset response buffer for error handling
Prior to this commit, `DispatcherServlet` would completely reset the
response (status, headers and body) before handling errors within Spring
MVC. This can cause unintended consequences when Servlet Filters added
response headers before the error happened. Such response headers might
be still required in case of error handling.

This commit changes the complete reset of the response to only resetting
the response buffer, if possible.

Closes gh-31154
See gh-31104
2023-09-08 18:47:21 +02:00
Sébastien Deleuze
88ee8fc92f Upgrade to CRaC 1.4.0
Closes gh-31190
2023-09-08 17:53:08 +02:00
Sam Brannen
154aec7d75 Merge branch '6.0.x' 2023-09-08 17:22:16 +02:00
Sam Brannen
10de295a72 Document StandardTypeLocator configuration to support user types
Prior to this commit, it was unclear to users and third parties that it
is necessary to manually configure a StandardTypeLocator with a
specific ClassLoader to ensure that the SpEL expression parser is able
to reliably locate user types.

For example, the StandardBeanExpressionResolver in the spring-context
module configures a StandardTypeLocator using the bean ClassLoader of
the corresponding BeanFactory.

This commit improves the documentation to raise awareness of this fact.

Closes gh-26253
2023-09-08 17:19:51 +02:00
Sam Brannen
a11b8039c5 Merge branch '6.0.x' 2023-09-08 16:31:11 +02:00
Sam Brannen
1227fe5774 Polishing 2023-09-08 16:30:53 +02:00
Sam Brannen
f0b1133b12 Merge branch '6.0.x' 2023-09-08 16:12:29 +02:00
Sam Brannen
ea41051651 Do not invoke [Map|Collection].isEmpty() in nullSafeConciseToString()
gh-30810 introduced explicit support for collections and maps in
ObjectUtils.nullSafeConciseToString() by invoking isEmpty() on a Map or
Collection to determine which concise string representation should be
used. However, this caused a regression in which an exception was
thrown if the Map or Collection was a proxy generated by
AbstractFactoryBean to support <util:set />, <util:list />, and
<util:map /> in XML configuration.

This commit addresses this set of regressions by always returning
"[...]" or "{...}" for a Collection or Map, respectively, disregarding
whether the map is empty or not.

Closes gh-31138
2023-09-08 16:03:00 +02:00
Stephane Nicoll
91f65e63b4 Merge pull request #30068 from enimiste
* pr/30068:
  Polish "Add return type check on GetterPointcut"
  Add return type check on GetterPointcut

Closes gh-30068
2023-09-08 15:37:07 +02:00
Stephane Nicoll
3e424e3ce7 Polish "Add return type check on GetterPointcut"
See gh-30068
2023-09-08 15:30:52 +02:00
Sam Brannen
311c58ea2d Polish [Standard]TypeLocator 2023-09-08 15:21:48 +02:00
Sam Brannen
40f1cf67bd Polish DefaultClientResponseTests and suppress "unchecked" warnings 2023-09-08 15:21:48 +02:00
Sam Brannen
6da9aed055 Update copyright header 2023-09-08 15:21:48 +02:00
Enimiste
d1dfac4e5d Add return type check on GetterPointcut
See gh-30068
2023-09-08 15:20:53 +02:00
Sam Brannen
c9e13575ca Use switch expression and constants in CallMetaDataProviderFactory 2023-09-08 14:05:03 +02:00
Sam Brannen
762d903aad Convert TableMetaData to a record
This simplifies the code and also improves diagnostics while debugging.
2023-09-08 14:04:47 +02:00
Sam Brannen
47d760845b Add missing @Nullable declaration 2023-09-08 14:00:52 +02:00
Sam Brannen
ab5d46411a Introduce identifierNameToUse() in GenericCallMetaDataProvider 2023-09-08 13:59:46 +02:00
Sam Brannen
4df3eb4670 Polish Javadoc 2023-09-08 13:59:10 +02:00
Sam Brannen
5a87f555f8 Update copyright headers 2023-09-08 13:57:41 +02:00
Sébastien Deleuze
5fd356e44f Remove outdated @Suppress("DEPRECATION") annotations
See gh-31127
2023-09-08 13:18:16 +02:00
Sébastien Deleuze
6f38e90048 Merge branch '6.0.x' 2023-09-08 13:08:14 +02:00
Sébastien Deleuze
12a01a680b Document some non-nullable Kotlin extensions can throw NoSuchElementException
Closes gh-31189
2023-09-08 13:07:58 +02:00
rstoyanchev
b0d4931d5d Merge branch '6.0.x' 2023-09-08 10:07:35 +01:00
rstoyanchev
740f3b797f Polishing
See gh-31185
2023-09-08 10:07:21 +01:00
Sébastien Deleuze
4c621826bd Merge branch '6.0.x' 2023-09-08 10:51:36 +02:00
Sébastien Deleuze
ab48b88f91 Refine BeanValidationBeanRegistrationAotProcessor logging
This commit prints a log message at debug level without
a stacktrace for TypeNotPresentException and uses
warn level instead of error level for other exceptions
since the processing of such bean will just be skipped.

Closes gh-31147
2023-09-08 10:50:57 +02:00
rstoyanchev
e0c4347cc6 Merge branch '6.0.x' 2023-09-08 09:18:24 +01:00
rstoyanchev
eda35e8074 Add note to the interceptor section of the MVC config
Closes gh-31185
2023-09-08 09:17:59 +01:00