Yanming Zhou opened SPR-17190 and commented

Those legacy adapter class should be marked as @Deprecated and removed in the future, such as TransactionSynchronizationAdapter and HandlerInterceptorAdapter.


No further details from SPR-17190

Comment From: spring-projects-issues

Juergen Hoeller commented

Indeed, those adapter classes are effectively on their way out...

We just didn't feel it was necessary to deprecate them and force people to avoid them or put @SuppressWarnings on their subclasses quite yet. Also, we have a few subclasses ourselves there that we'll have to refactor to straight implementations of the corresponding interface. For the time being, it doesn't hurt to retain assignability to the adapter classes there, just in case somebody makes a corresponding assumption in custom inspection code.

We'll probably do that round of cleanup for 5.2 and remove them altogether in 6.0.

Comment From: rstoyanchev

We missed 5.2 but seems straight-forward enough so let's do it for 5.3.

Comment From: sbrannen

Removal of TransactionSynchronizationAdapter would require people to provide a concrete implementation of getOrder() since Ordered does not provide a default implementation of that method. So, we'd need to document that with the deprecation message.

Comment From: sbrannen

Partially superseded by #25147 regarding HandlerInterceptorAdapter.

Comment From: jhoeller

I've reduced the scope of this ticket for the remaining TransactionSynchronizationAdapter part, potentially making the TransactionSynchronization interface itself extend Ordered (to sort out the migration problem discussed above).

Comment From: nickcaballero

Adding Ordered to the TransactionSynchronization has caused @Order annotations to be ignored in favor of the getOrder result, which by default has been set to LOWEST_PRECEDENCE.

From AnnotationAwareOrderComparator:

    protected Integer findOrder(Object obj) {
        Integer order = super.findOrder(obj); // This uses getOrder()
        if (order != null) {
            return order;
        }
        return findOrderFromAnnotation(obj);
    }

From TransactionSynchronizationManager#getSynchronizations:

    List<TransactionSynchronization> sortedSynchs = new ArrayList<>(synchs);
    AnnotationAwareOrderComparator.sort(sortedSynchs);
    return Collections.unmodifiableList(sortedSynchs);

Comment From: jhoeller

Indeed, @Order annotations do not work for transaction synchronizations anymore. Since we rather accidentally introduced this in a larger refactoring in 4.2 and never had tests for it, I'm inclined to simply consider it not supported at this point.

As a side note, the annotation-based ordering introduces considerable overhead, and synchronization instances get freshly ordered every time. As a consequence, I'll change that code back to plain OrderComparator sorting for efficiency.