Author: cziegeler
Date: Sun Jun 3 13:46:47 2012
New Revision: 1345672
URL: http://svn.apache.org/viewvc?rev=1345672&view=rev
Log:
SLING-2500 : NPE in SortingServiceTracker#getSortedServices
Modified:
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/SortingServiceTracker.java
Modified:
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/SortingServiceTracker.java
URL:
http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/SortingServiceTracker.java?rev=1345672&r1=1345671&r2=1345672&view=diff
==============================================================================
---
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/SortingServiceTracker.java
(original)
+++
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/SortingServiceTracker.java
Sun Jun 3 13:46:47 2012
@@ -92,24 +92,26 @@ public class SortingServiceTracker<T>
* Return a sorted list of the services.
*/
public List<T> getSortedServices() {
- if ( this.sortedServiceCache == null || this.lastCount <
this.getTrackingCount() ) {
+ List<T> result = this.sortedServiceCache;
+ if ( result == null || this.lastCount < this.getTrackingCount() ) {
this.lastCount = this.getTrackingCount();
final ServiceReference[] references = this.getServiceReferences();
if ( references == null || references.length == 0 ) {
- this.sortedServiceCache = Collections.emptyList();
+ result = Collections.emptyList();
} else {
Arrays.sort(references);
- this.sortedServiceCache = new ArrayList<T>();
+ result = new ArrayList<T>();
for(int i=0;i<references.length;i++) {
@SuppressWarnings("unchecked")
final T service =
(T)this.getService(references[references.length - 1 - i]);
if ( service != null ) {
- this.sortedServiceCache.add(service);
+ result.add(service);
}
}
}
+ this.sortedServiceCache = result;
}
- return this.sortedServiceCache;
+ return result;
}
/**