Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 329940 | Differences between
and this patch

Collapse All | Expand All

(-).settings/.api_filters (+9 lines)
Lines 809-814 Link Here
809
</message_arguments>
809
</message_arguments>
810
</filter>
810
</filter>
811
</resource>
811
</resource>
812
<resource path="osgi/src/org/osgi/framework/ServiceException.java" type="org.osgi.framework.ServiceException">
813
<filter comment="Ingore OSGi API" id="1141899266">
814
<message_arguments>
815
<message_argument value="1.6"/>
816
<message_argument value="3.7"/>
817
<message_argument value="FACTORY_RECURSION"/>
818
</message_arguments>
819
</filter>
820
</resource>
812
<resource path="osgi/src/org/osgi/framework/ServiceReference.java" type="org.osgi.framework.ServiceReference">
821
<resource path="osgi/src/org/osgi/framework/ServiceReference.java" type="org.osgi.framework.ServiceReference">
813
<filter comment="Ignore OSGi API" id="403853384">
822
<filter comment="Ignore OSGi API" id="403853384">
814
<message_arguments>
823
<message_arguments>
(-)core/framework/org/eclipse/osgi/internal/serviceregistry/ServiceUse.java (+17 lines)
Lines 43-48 Link Here
43
	/** bundle's use count for this service */
43
	/** bundle's use count for this service */
44
	/* @GuardedBy("this") */
44
	/* @GuardedBy("this") */
45
	private int useCount;
45
	private int useCount;
46
	/** true if we are calling the factory getService method. Used to detect recursion. */
47
	/* @GuardedBy("this") */
48
	private boolean factoryInUse;
46
49
47
	/** Internal framework object. */
50
	/** Internal framework object. */
48
51
Lines 56-61 Link Here
56
	 */
59
	 */
57
	ServiceUse(BundleContextImpl context, ServiceRegistrationImpl<S> registration) {
60
	ServiceUse(BundleContextImpl context, ServiceRegistrationImpl<S> registration) {
58
		this.useCount = 0;
61
		this.useCount = 0;
62
		this.factoryInUse = false;
59
		S service = registration.getServiceObject();
63
		S service = registration.getServiceObject();
60
		if (service instanceof ServiceFactory<?>) {
64
		if (service instanceof ServiceFactory<?>) {
61
			@SuppressWarnings("unchecked")
65
			@SuppressWarnings("unchecked")
Lines 116-121 Link Here
116
		if (Debug.DEBUG_SERVICES) {
120
		if (Debug.DEBUG_SERVICES) {
117
			Debug.println("getService[factory=" + registration.getBundle() + "](" + context.getBundleImpl() + "," + registration + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
121
			Debug.println("getService[factory=" + registration.getBundle() + "](" + context.getBundleImpl() + "," + registration + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
118
		}
122
		}
123
		// check for recursive call
124
		if (factoryInUse == true) {
125
			if (Debug.DEBUG_SERVICES) {
126
				Debug.println(factory + ".getService() recursively called."); //$NON-NLS-1$
127
			}
128
129
			ServiceException se = new ServiceException(NLS.bind(Msg.SERVICE_FACTORY_RECURSION, factory.getClass().getName(), "getService"), ServiceException.FACTORY_RECURSION); //$NON-NLS-1$
130
			context.getFramework().publishFrameworkEvent(FrameworkEvent.WARNING, registration.getBundle(), se);
131
			return null;
132
		}
133
		factoryInUse = true;
119
		final S service;
134
		final S service;
120
		try {
135
		try {
121
			service = AccessController.doPrivileged(new PrivilegedAction<S>() {
136
			service = AccessController.doPrivileged(new PrivilegedAction<S>() {
Lines 133-138 Link Here
133
			ServiceException se = new ServiceException(NLS.bind(Msg.SERVICE_FACTORY_EXCEPTION, factory.getClass().getName(), "getService"), ServiceException.FACTORY_EXCEPTION, t); //$NON-NLS-1$ 
148
			ServiceException se = new ServiceException(NLS.bind(Msg.SERVICE_FACTORY_EXCEPTION, factory.getClass().getName(), "getService"), ServiceException.FACTORY_EXCEPTION, t); //$NON-NLS-1$ 
134
			context.getFramework().publishFrameworkEvent(FrameworkEvent.ERROR, registration.getBundle(), se);
149
			context.getFramework().publishFrameworkEvent(FrameworkEvent.ERROR, registration.getBundle(), se);
135
			return null;
150
			return null;
151
		} finally {
152
			factoryInUse = false;
136
		}
153
		}
137
154
138
		if (service == null) {
155
		if (service == null) {
(-)osgi/src/org/osgi/framework/ServiceException.java (+6 lines)
Lines 68-73 Link Here
68
	 * An error occurred invoking a remote service.
68
	 * An error occurred invoking a remote service.
69
	 */
69
	 */
70
	public static final int REMOTE 				= 5;
70
	public static final int REMOTE 				= 5;
71
	/**
72
	 * The service factory resulted in a recursive call to itself.
73
	 * 
74
	 * @since 1.6
75
	 */
76
	public static final int	FACTORY_RECURSION	= 6;
71
77
72
	/**
78
	/**
73
	 * Creates a {@code ServiceException} with the specified message and
79
	 * Creates a {@code ServiceException} with the specified message and
(-)supplement/src/org/eclipse/osgi/framework/internal/core/ExternalMessages.properties (+1 lines)
Lines 46-51 Link Here
46
MANIFEST_INVALID_HEADER_EXCEPTION=Invalid manifest header {0}: \"{1}\"
46
MANIFEST_INVALID_HEADER_EXCEPTION=Invalid manifest header {0}: \"{1}\"
47
MANIFEST_IOEXCEPTION=An error occurred while reading the manifest file.
47
MANIFEST_IOEXCEPTION=An error occurred while reading the manifest file.
48
SERVICE_FACTORY_EXCEPTION=Exception in {0}.{1}()
48
SERVICE_FACTORY_EXCEPTION=Exception in {0}.{1}()
49
SERVICE_FACTORY_RECURSION=Recursive ServiceFactory call in {0}.{1}()
49
SERVICE_NOT_INSTANCEOF_CLASS_EXCEPTION=The service object is not an instance of the service class {0}
50
SERVICE_NOT_INSTANCEOF_CLASS_EXCEPTION=The service object is not an instance of the service class {0}
50
SERVICE_FACTORY_NOT_INSTANCEOF_CLASS_EXCEPTION={0}.getService() returned a service object that is not an instance of the service class {1}
51
SERVICE_FACTORY_NOT_INSTANCEOF_CLASS_EXCEPTION={0}.getService() returned a service object that is not an instance of the service class {1}
51
SERVICE_OBJECT_NULL_EXCEPTION={0}.getService() returned a null service object
52
SERVICE_OBJECT_NULL_EXCEPTION={0}.getService() returned a null service object
(-)supplement/src/org/eclipse/osgi/framework/internal/core/Msg.java (+1 lines)
Lines 72-77 Link Here
72
72
73
	public static String SERVICE_FACTORY_EXCEPTION;
73
	public static String SERVICE_FACTORY_EXCEPTION;
74
	public static String SERVICE_OBJECT_NULL_EXCEPTION;
74
	public static String SERVICE_OBJECT_NULL_EXCEPTION;
75
	public static String SERVICE_FACTORY_RECURSION;
75
76
76
	public static String STARTLEVEL_EXCEPTION_INVALID_REQUESTED_STARTLEVEL;
77
	public static String STARTLEVEL_EXCEPTION_INVALID_REQUESTED_STARTLEVEL;
77
	public static String STARTLEVEL_CANT_CHANGE_SYSTEMBUNDLE_STARTLEVEL;
78
	public static String STARTLEVEL_CANT_CHANGE_SYSTEMBUNDLE_STARTLEVEL;

Return to bug 329940