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 182940 Details for
Bug 329940
Should detect recursive calls to ServiceFactory.getService
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to detect recursion, log an error and return null.
bug329940-patch.txt (text/plain), 5.25 KB, created by
BJ Hargrave
on 2010-11-11 17:13:12 EST
(
hide
)
Description:
Patch to detect recursion, log an error and return null.
Filename:
MIME Type:
Creator:
BJ Hargrave
Created:
2010-11-11 17:13:12 EST
Size:
5.25 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.osgi >Index: core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceUse.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/framework/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceUse.java,v >retrieving revision 1.6 >diff -u -r1.6 ServiceUse.java >--- core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceUse.java 6 Aug 2010 19:51:45 -0000 1.6 >+++ core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceUse.java 11 Nov 2010 22:09:00 -0000 >@@ -43,6 +43,9 @@ > /** bundle's use count for this service */ > /* @GuardedBy("this") */ > private int useCount; >+ /** true if we are calling the factory getService method. Used to detect recursion. */ >+ /* @GuardedBy("this") */ >+ private boolean factoryInUse; > > /** Internal framework object. */ > >@@ -56,6 +59,7 @@ > */ > ServiceUse(BundleContextImpl context, ServiceRegistrationImpl<S> registration) { > this.useCount = 0; >+ this.factoryInUse = false; > S service = registration.getServiceObject(); > if (service instanceof ServiceFactory<?>) { > @SuppressWarnings("unchecked") >@@ -116,6 +120,17 @@ > if (Debug.DEBUG_SERVICES) { > Debug.println("getService[factory=" + registration.getBundle() + "](" + context.getBundleImpl() + "," + registration + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ > } >+ // check for recursive call >+ if (factoryInUse == true) { >+ if (Debug.DEBUG_SERVICES) { >+ Debug.println(factory + ".getService() recursively called."); //$NON-NLS-1$ >+ } >+ >+ ServiceException se = new ServiceException(NLS.bind(Msg.SERVICE_FACTORY_RECURSION, factory.getClass().getName(), "getService"), ServiceException.FACTORY_RECURSION); //$NON-NLS-1$ >+ context.getFramework().publishFrameworkEvent(FrameworkEvent.WARNING, registration.getBundle(), se); >+ return null; >+ } >+ factoryInUse = true; > final S service; > try { > service = AccessController.doPrivileged(new PrivilegedAction<S>() { >@@ -133,6 +148,8 @@ > ServiceException se = new ServiceException(NLS.bind(Msg.SERVICE_FACTORY_EXCEPTION, factory.getClass().getName(), "getService"), ServiceException.FACTORY_EXCEPTION, t); //$NON-NLS-1$ > context.getFramework().publishFrameworkEvent(FrameworkEvent.ERROR, registration.getBundle(), se); > return null; >+ } finally { >+ factoryInUse = false; > } > > if (service == null) { >Index: osgi/src/org/osgi/framework/ServiceException.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/framework/bundles/org.eclipse.osgi/osgi/src/org/osgi/framework/ServiceException.java,v >retrieving revision 1.10 >diff -u -r1.10 ServiceException.java >--- osgi/src/org/osgi/framework/ServiceException.java 6 Aug 2010 19:51:44 -0000 1.10 >+++ osgi/src/org/osgi/framework/ServiceException.java 11 Nov 2010 22:09:00 -0000 >@@ -68,6 +68,12 @@ > * An error occurred invoking a remote service. > */ > public static final int REMOTE = 5; >+ /** >+ * The service factory resulted in a recursive call to itself. >+ * >+ * @since 1.6 >+ */ >+ public static final int FACTORY_RECURSION = 6; > > /** > * Creates a {@code ServiceException} with the specified message and >Index: supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/framework/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties,v >retrieving revision 1.46 >diff -u -r1.46 ExternalMessages.properties >--- supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties 22 Apr 2010 14:48:28 -0000 1.46 >+++ supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties 11 Nov 2010 22:09:00 -0000 >@@ -46,6 +46,7 @@ > MANIFEST_INVALID_HEADER_EXCEPTION=Invalid manifest header {0}: \"{1}\" > MANIFEST_IOEXCEPTION=An error occurred while reading the manifest file. > SERVICE_FACTORY_EXCEPTION=Exception in {0}.{1}() >+SERVICE_FACTORY_RECURSION=Recursive ServiceFactory call in {0}.{1}() > SERVICE_NOT_INSTANCEOF_CLASS_EXCEPTION=The service object is not an instance of the service class {0} > SERVICE_FACTORY_NOT_INSTANCEOF_CLASS_EXCEPTION={0}.getService() returned a service object that is not an instance of the service class {1} > SERVICE_OBJECT_NULL_EXCEPTION={0}.getService() returned a null service object >Index: supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.equinox/framework/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java,v >retrieving revision 1.16 >diff -u -r1.16 Msg.java >--- supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java 16 Oct 2008 18:13:14 -0000 1.16 >+++ supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java 11 Nov 2010 22:09:00 -0000 >@@ -72,6 +72,7 @@ > > public static String SERVICE_FACTORY_EXCEPTION; > public static String SERVICE_OBJECT_NULL_EXCEPTION; >+ public static String SERVICE_FACTORY_RECURSION; > > public static String STARTLEVEL_EXCEPTION_INVALID_REQUESTED_STARTLEVEL; > public static String STARTLEVEL_CANT_CHANGE_SYSTEMBUNDLE_STARTLEVEL;
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 329940
:
182940
|
182941