Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 215979 Details for
Bug 379865
Getting OSGi service references with simple filter is slow
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
possible fix
379865.patch (text/plain), 3.02 KB, created by
Thomas Watson
on 2012-05-21 11:53:20 EDT
(
hide
)
Description:
possible fix
Filename:
MIME Type:
Creator:
Thomas Watson
Created:
2012-05-21 11:53:20 EDT
Size:
3.02 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.osgi >diff --git core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java >index 7634ca9..d711419 100644 >--- core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java >+++ core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceRegistry.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2010 IBM Corporation and others. >+ * Copyright (c) 2004, 2012 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -948,42 +948,44 @@ > * @return List<ServiceRegistrationImpl> > */ > private List<ServiceRegistrationImpl<?>> lookupServiceRegistrations(String clazz, Filter filter) { >- List<ServiceRegistrationImpl<?>> result; >+ List<ServiceRegistrationImpl<?>> registrationsCopy; > synchronized (this) { > if (clazz == null) { /* all services */ >- result = allPublishedServices; >+ registrationsCopy = allPublishedServices; > } else { > /* services registered under the class name */ >- result = publishedServicesByClass.get(clazz); >+ registrationsCopy = publishedServicesByClass.get(clazz); > } > >- if ((result == null) || result.isEmpty()) { >+ if ((registrationsCopy == null) || registrationsCopy.isEmpty()) { > @SuppressWarnings("unchecked") > List<ServiceRegistrationImpl<?>> empty = Collections.EMPTY_LIST; > return empty; > } > >- result = new ArrayList<ServiceRegistrationImpl<?>>(result); /* make a new list since we don't want to change the real list */ >+ registrationsCopy = new ArrayList<ServiceRegistrationImpl<?>>(registrationsCopy); /* make a new list since we don't want to change the real list */ > } > > if (filter == null) { >- return result; >+ return registrationsCopy; > } > >- for (Iterator<ServiceRegistrationImpl<?>> iter = result.iterator(); iter.hasNext();) { >- ServiceRegistrationImpl<?> registration = iter.next(); >+ // bug 379865: use an additive approach instead of removal >+ // to help with performance when removing large numbers of registrations >+ List<ServiceRegistrationImpl<?>> filteredRegistrations = new ArrayList<ServiceRegistrationImpl<?>>(registrationsCopy.size()); >+ for (ServiceRegistrationImpl<?> registration : registrationsCopy) { > ServiceReferenceImpl<?> reference; > try { > reference = registration.getReferenceImpl(); > } catch (IllegalStateException e) { >- iter.remove(); /* service was unregistered after we left the synchronized block above */ >+ /* service was unregistered after we left the synchronized block above */ > continue; > } >- if (!filter.match(reference)) { >- iter.remove(); >+ if (filter.match(reference)) { >+ filteredRegistrations.add(registration); > } > } >- return result; >+ return filteredRegistrations; > } > > /**
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 379865
:
215826
|
215827
|
215828
|
215829
|
215979
|
215986