Commit Graph

772 Commits

Author SHA1 Message Date
Stéphane Nicoll 68931a2091 Upgrade copyright year of changed file
See gh-31847
2023-12-15 07:36:50 +01:00
achhibi 7f79ccbec0 Combine conditions for better readability and simplicity 2023-12-14 20:29:09 +01:00
Sam Brannen c0683cd30b Update copyright headers 2023-12-12 14:51:03 +01:00
Sam Brannen 1c58511cb2 Polishing 2023-12-12 14:51:03 +01:00
Juergen Hoeller 6bb9775309 Declare isStatic and releaseTarget as default methods on TargetSource
Closes gh-31820
2023-12-12 12:39:52 +01:00
Sébastien Deleuze 9aded3fcad Fix a NPE in proxied suspending functions
Closes gh-31809
2023-12-11 21:21:34 +01:00
Yanming Zhou 7b16ef90f1 Replace assertThat(x.equals(y)) with assertThat(x).isEqualTo(y)
Search for   : assertThat\((.+)\.equals\((\w+)\)\)\.isTrue\(\)
Replace with : assertThat($1).isEqualTo($2)

Search for   : assertThat\((.+)\.equals\((\w+)\)\)\.isFalse\(\)
Replace with : assertThat($1).isNotEqualTo($2)

Closes gh-31763
2023-12-06 09:50:15 +01:00
Yanming Zhou e2852e7355 Replace assertThat(x.contains(y)).isTrue() with assertThat(x).contains(y)
Search for   : assertThat\((.+)\.contains\((.+)\)\)\.isTrue\(\)
Replace with : assertThat($1).contains($2)

Search for   : assertThat\((.+)\.contains\((.+)\)\)\.isFalse\(\)
Replace with : assertThat($1).doesNotContain($2)

Closes gh-31762
2023-12-06 09:48:49 +01:00
Yanming Zhou 59815cefce Replace assertThat(x.get(i)). with assertThat(x).element(i).
Search for   : assertThat\((.+)\.get\((\d+)\)\)\.
Replace with : assertThat($1).element($2).

Closes gh-31759
2023-12-06 09:43:59 +01:00
Juergen Hoeller 121e3540cc Clear cached executors in setBeanFactory (for reused AspectJ aspect)
Closes gh-28201
2023-11-23 16:15:01 +01:00
Juergen Hoeller 0d8dee2878 Apply fallback for proxy with negative match or annotation pointcut
See gh-30534
2023-11-23 16:14:33 +01:00
Yanming Zhou 3a6d0c1d5b Always fall back to original method if annotation pointcut used
Prior to this commit, AspectJExpressionPointcut doesn't fall back to original method if `!@annotation()` is used, it can cause false positive result.

Fix GH-27119
2023-11-23 16:01:18 +01:00
Juergen Hoeller 99378fe947 Polishing 2023-11-16 11:22:09 +01:00
Brian Clozel 8eebb5e27b Polish
See gh-31575
2023-11-15 15:26:49 +01:00
Sébastien Deleuze 92c3843dae Add required AspectJ field hints
This commit adds reflection hints on fields for
classes compiled by AspectJ.

Closes gh-31575
2023-11-15 10:30:02 +01:00
Sam Brannen c7bb981db1 Ensure it's possible to extend ControlFlowPointcut with RegEx support
Commit d3fba6d49b introduced built-in pattern matching support for
method names in ControlFlowPointcut; however, it was still cumbersome
to extend ControlFlowPointcut with support for regular expressions
instead of simple pattern matching.

To address that, this commit introduces a variant of isMatch() that
accepts the pattern index instead of the pre-resolved method name
pattern. The default implementation retrieves the method name pattern
from the methodNamePatterns field and delegates to isMatch(String, String).

Subclasses can override the new isMatch(String, int) method to support
regular expressions, as can be seen in the example
RegExControlFlowPointcut class in ControlFlowPointcutTests.

See gh-31435
2023-10-28 16:30:02 +02:00
Sam Brannen 7f1beb0140 Polishing 2023-10-28 16:24:59 +02:00
Sam Brannen d3fba6d49b Support pattern matching for method names in ControlFlowPointcut
Prior to this commit, ControlFlowPointcut supported a single method
name which was matched exactly. Although it was possible to extend
ControlFlowPointcut to add support for pattern matching, it was a bit
cumbersome.

To address that, this commit introduces built-in pattern matching
support for method names in ControlFlowPointcut, analogous to the
pattern matching support in NameMatchMethodPointcut.

Specifically, a user can provide one or more method name patterns, and
the patterns will be matched against candidate method names using OR
semantics.

By default, the matching algorithm delegates to
PatternMatchUtils.simpleMatch(), but this can be overridden in
subclasses by overriding the new protected isMatch() method.

Closes gh-31435
2023-10-27 18:01:36 +02:00
Sam Brannen c5333a0a68 Polishing 2023-10-27 17:44:53 +02:00
Sam Brannen c5def4c97a Document pattern matching support in NameMatchMethodPointcut
Closes gh-31500
2023-10-25 16:55:21 +02:00
Sam Brannen 5c1cdcb245 Improve ControlFlowPointcut extensibility
This commit makes ControlFlowPointcut more open to subclasses by:

1. Making the ControlFlowPointcut#clazz field protected.
2. Making the ControlFlowPointcut#methodName field protected.
3. Introducing a protected incrementEvaluationCount() method.

Closes gh-27187
2023-10-25 15:21:14 +02:00
Sam Brannen c0f79ca3bf Polish ControlFlowPointcut[Tests] 2023-10-25 15:21:14 +02:00
Juergen Hoeller 8712fdcd3b Polishing 2023-10-23 17:36:06 +02:00
Juergen Hoeller cf3a25bfac Merge branch '6.0.x' 2023-10-23 17:34:45 +02:00
Juergen Hoeller 6bdf7ad36a Polishing 2023-10-23 17:32:45 +02:00
Juergen Hoeller f9be717602 Avoid getObjectType exception for uninitialized ProxyFactoryBean
Closes gh-31473
2023-10-23 17:32:25 +02:00
Sam Brannen 2d792f000a Polish "Apply SingleSpaceSeparator Checkstyle module"
See gh-31469
2023-10-22 14:18:18 +02:00
Johnny Lim 64e9fcad53 Apply SingleSpaceSeparator Checkstyle module
This commit also fixes its violations.

Closes gh-31469
2023-10-22 14:09:57 +02:00
Johnny Lim 919faa2ce2 Order modifiers to align with JLS
This commit also applies Checkstyle ModifierOrder to enforce it.

See gh-31368
2023-10-17 16:13:56 +02:00
Sébastien Deleuze 466c8d8f23 Add Coroutines support for `@Cacheable`
This commit adds Coroutines support for `@Cacheable`.

It also refines SimpleKeyGenerator to ignore Continuation
parameters (Kotlin does not allow to have the same method
signature with both suspending and non-suspending variants)
and refines
org.springframework.aop.framework.CoroutinesUtils.awaitSingleOrNull
in order to wrap plain value to Mono.

Closes gh-31412
2023-10-15 19:25:59 +02:00
Stéphane Nicoll ce9ca700f3 Enable test in AbstractAspectJAdvisorFactoryTests
See gh-24190
2023-09-28 15:46:47 +02:00
Sam Brannen ebd4f1b45b Merge branch '6.0.x' 2023-09-23 12:41:19 +02:00
Sam Brannen 08237da4b4 Simplify equals() implementation in PerTargetInstantiationModelPointcut
For equivalence, we only need to compare the preInstantiationPointcut
fields since they include the declaredPointcut fields. In addition, we
should not compare the aspectInstanceFactory fields since
LazySingletonAspectInstanceFactoryDecorator does not implement equals().

See gh-31238
2023-09-23 12:40:28 +02:00
Sam Brannen bc03088f69 Merge branch '6.0.x' 2023-09-22 18:18:11 +02:00
Sam Brannen f7496a393d Expand scope of equals() in PerTargetInstantiationModelPointcut
This commit expands the scope of equality checks in the implementation
of equals() for PerTargetInstantiationModelPointcut to include all
fields instead of just the pointcut expression for the declared
pointcut.

See gh-31238
2023-09-22 18:17:07 +02:00
Sam Brannen 9350091163 Merge branch '6.0.x'
# Conflicts:
#	spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJPointcutAdvisor.java
#	spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java
2023-09-20 17:06:35 +02:00
Sam Brannen 865fa33927 Cache CGLIB proxy classes properly again
The introduction of AdvisedSupport.AdvisorKeyEntry in Spring Framework
6.0.10 resulted in a regression regarding caching of CGLIB generated
proxy classes. Specifically, equality checks for the proxy class cache
became based partially on identity rather than equivalence. For
example, if an ApplicationContext was configured to create a
class-based @Transactional proxy, a second attempt to create the
ApplicationContext resulted in a duplicate proxy class for the same
@Transactional component.

On the JVM this went unnoticed; however, when running Spring
integration tests within a native image, if a test made use of
@⁠DirtiesContext, a second attempt to create the test
ApplicationContext resulted in an exception stating, "CGLIB runtime
enhancement not supported on native image." This is because Test AOT
processing only refreshes a test ApplicationContext once, and the
duplicate CGLIB proxy classes are only requested in subsequent
refreshes of the same ApplicationContext which means that duplicate
proxy classes are not tracked during AOT processing and consequently
not included in a native image.

This commit addresses this regression as follows.

- AdvisedSupport.AdvisorKeyEntry is now based on the toString()
  representations of the ClassFilter and MethodMatcher in the
  corresponding Pointcut instead of the filter's and matcher's
  identities.

- Due to the above changes to AdvisorKeyEntry, ClassFilter and
  MethodMatcher implementations are now required to implement equals(),
  hashCode(), AND toString().

- Consequently, the following now include proper equals(), hashCode(),
  and toString() implementations.

  - CacheOperationSourcePointcut
  - TransactionAttributeSourcePointcut
  - PerTargetInstantiationModelPointcut

Closes gh-31238
2023-09-20 16:56:09 +02:00
Sam Brannen 9120f87897 Consolidate AspectJ test fixtures 2023-09-20 16:47:05 +02:00
Sam Brannen edd1e9134f Polishing 2023-09-20 16:47:05 +02:00
Stéphane Nicoll 57a4628934 Polish log message
See gh-29773
2023-09-18 08:28:10 +02:00
Sangwon Hong fcbe5fa73f Log attempt at proxying final methods to WARN instead of INFO
See gh-29773
2023-09-18 08:25:37 +02:00
Stephane Nicoll 01f717375b Introduce ObjectUtils#nullSafeHash(Object... element)
This commit deprecates the various nullSafeHashCode methods taking array
types as they are superseded by Arrays.hashCode now. This means that
the now only remaining nullSafeHashCode method does not trigger a
warning only if the target type is not an array. At the same time, there
are multiple use of this method on several elements, handling the
accumulation of hash codes.

For that reason, this commit also introduces a nullSafeHash that takes
an array of elements. The only difference between Objects.hash is that
this method handles arrays.

The codebase has been reviewed to use any of those two methods when it
is possible.

Closes gh-29051
2023-09-13 15:14:34 +02:00
Stephane Nicoll 66a571fe27 Make constructorOrFactory method resolution optional
This commit allows a custom code fragment to provide the code to
create a bean without relying on ConstructorResolver. This is especially
important for use cases that derive from the default behaviour and
provide an instance supplier with the regular runtime scenario.

This is a breaking change for code fragments providing a custom
implementation of the related methods. As it turns out, almost all of
them did not need the Executable argument. Configuration class parsing
is the exception, where it needs to provide a different constructor in
the case of the proxy. To make this use case possible,
InstanceSupplierCodeGenerator has been made public.

Closes gh-31117
2023-09-11 15:55:22 +02:00
Stephane Nicoll 3e424e3ce7 Polish "Add return type check on GetterPointcut"
See gh-30068
2023-09-08 15:30:52 +02:00
Enimiste d1dfac4e5d Add return type check on GetterPointcut
See gh-30068
2023-09-08 15:20:53 +02:00
Sébastien Deleuze ada76bd7bf Add an assertion to AopUtils.KotlinDelegate#invokeSuspendingFunction
See gh-22462
2023-09-07 12:30:47 +02:00
Sébastien Deleuze 81607238ce Use consistently `@since 6.1` 2023-09-01 12:33:21 +02:00
Stephane Nicoll 1f6fd16dae Polish "Introduce reverse on ClassFilter and MethodFilter"
See gh-26725
2023-08-28 15:05:27 +02:00
Jinhui-Z 13e62d0b8e Introduce reverse on ClassFilter and MethodFilter
See gh-26725
2023-08-28 15:05:27 +02:00
hzmpay cde476f90e Use computeIfAbsent in SpelCompiler and AdvisedSupport
See gh-26028
2023-08-25 16:12:08 +02:00