Skip to content

Conversation

@kamilkrzywanski
Copy link
Contributor

Optimize repeated annotation stream processing in cache annotation parsing
Closes: #35598

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 10, 2025
…rsing

Closes: spring-projects#35598

Signed-off-by: Kamil Krzywański <[email protected]>
Signed-off-by: Kamil Krzywanski <[email protected]>
@jhoeller jhoeller self-assigned this Oct 10, 2025
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 10, 2025
@jhoeller jhoeller added this to the 6.2.12 milestone Oct 10, 2025
@jhoeller
Copy link
Contributor

jhoeller commented Oct 10, 2025

After seeing the PR build failure (see AnnotationCacheOperationSourceTests.multipleAnnotation), this reminded me why we do those individual streams: Those annotations need to be processed in a specific order of annotation types for the resulting operations to semantically align, not in the order of annotation declaration.

A simple loop over the declared annotations would have to collect the annotations into different categories first (probably one collection per category to hold), and then once again iterate over each category to actually process those annotations (resulting in a sequence of operations). Not sure whether we can make the resulting code look nicer than the current stream-based code...

@kamilkrzywanski
Copy link
Contributor Author

@jhoeller
You’re absolutely right — in this case, any attempt to “optimize” the iteration isn’t meaningful.
Since the operations must be processed in a strict order by annotation type, we’d either have to sort the collected results afterward or buffer them into four separate lists before processing. Both approaches would introduce extra overhead and likely make the code less readable than the current stream-based implementation.

So I agree — it’s best to keep the existing approach as-is.

@jhoeller jhoeller removed this from the 6.2.12 milestone Oct 11, 2025
@jhoeller jhoeller added status: invalid An issue that we don't feel is valid and removed type: enhancement A general enhancement labels Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: core Issues in core modules (aop, beans, core, context, expression) status: invalid An issue that we don't feel is valid

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize repeated annotation stream processing in SpringCacheAnnotationParser

3 participants