cziegeler commented on a change in pull request #34:
URL:
https://github.com/apache/sling-org-apache-sling-models-impl/pull/34#discussion_r803552412
##########
File path:
src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
##########
@@ -204,7 +204,11 @@ public Callback(ServiceReference<?>[] refs, BundleContext
context) {
public void onDisposed() {
if (refs != null) {
for (ServiceReference<?> ref : refs) {
- context.ungetService(ref);
+ try {
+ context.ungetService(ref);
+ } catch (IllegalStateException | IllegalArgumentException
| NullPointerException exception) {
Review comment:
I don't think that throwing a RuntimeException is the right thing here..
An IllegalStateException can happen as a race condition; from the javadocs:
java.lang.IllegalStateException - If this BundleContext is no longer valid.
java.lang.IllegalArgumentException - If the specified ServiceReference was
not created by the same framework instance as this BundleContext.
So imho it makes sense to catch and ignore IllegalStateException; everything
else does not need to be catched as those would hint at an programming error
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]