As discussed in https://github.com/spring-projects/spring-framework/issues/28928#issuecomment-1209411867, we should change the semantics of GenerationContext.withName(String) so that an existing "feature name prefix" is not lost.

Specifically, we should prepend any existing prefix to a new provided prefix to ensure that there are no clashes with generated names.

This change may also be helpful in implementing #28204.

As mentioned by @snicoll, "the counter in DefaultGenerationContext [may no longer] need to be transmitted from one context to another."

Comment From: snicoll

I don't know if we should reuse this issue and migrate it to a bug or if we should create a separate issue, but, withName cannot be used with the TCF. It works fine when processing an application but fails if more than one context needs the feature that withName triggers.

A reproducer is available in the linked Spring Boot issue. I think it would be better that the TCF provides a context that deals with the name clashing automatically, so that withName works transparently in both cases.

Comment From: sbrannen

  • superseded by #30861