optimized OrderComparator usage

This commit is contained in:
Juergen Hoeller
2009-02-17 18:19:57 +00:00
parent 9871e94cad
commit 43caa57296
10 changed files with 29 additions and 41 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.springframework.transaction.support;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -77,8 +76,6 @@ public abstract class TransactionSynchronizationManager {
private static final Log logger = LogFactory.getLog(TransactionSynchronizationManager.class);
private static final Comparator<Object> synchronizationComparator = new OrderComparator();
private static final ThreadLocal<Map<Object, Object>> resources =
new NamedThreadLocal<Map<Object, Object>>("Transactional resources");
@@ -295,7 +292,7 @@ public abstract class TransactionSynchronizationManager {
}
List<TransactionSynchronization> synchs = synchronizations.get();
// Sort lazily here, not in registerSynchronization.
Collections.sort(synchs, synchronizationComparator);
OrderComparator.sort(synchs);
// Return unmodifiable snapshot, to avoid ConcurrentModificationExceptions
// while iterating and invoking synchronization callbacks that in turn
// might register further synchronizations.