From caf78f765569256664eec47b3fd9d28e67e17730 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Mon, 2 Dec 2024 15:30:48 -0600 Subject: [PATCH] Work around OSGi Framework TCK that expects IllegalStateException One test in the current OSGi Framework TCK expects an IllegalStateException to be thrown if a ServiceRegistration is unregistered more than once. This change adds a temporary internal property to restore the IllegalStateException which we enable while running the OSGi Framework TCK. --- .../osgi/internal/framework/EquinoxConfiguration.java | 6 ++++++ .../internal/serviceregistry/ServiceRegistrationImpl.java | 4 ++++ pom.xml | 1 + 3 files changed, 11 insertions(+) diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java index 14f398dcd39..21cd5b26da8 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxConfiguration.java @@ -274,6 +274,10 @@ public class EquinoxConfiguration implements EnvironmentInfo { public final int supportSignedBundles; public final boolean runtimeVerifySignedBundles; + // TODO temp internal prop to pass the TCK + public final static String PROP_THROW_ISE_UNREGISTER = "org.eclipse.osgi.internal.throw.ise.unregister"; //$NON-NLS-1$ + public final boolean THROW_ISE_UNREGISTER; + public static final class ConfigValues { /** * Value of {@link #localConfig} properties that should be considered @@ -670,6 +674,8 @@ org.osgi.framework.Constants.FRAMEWORK_LIBRARY_EXTENSIONS, getOSLibraryExtDefaul CLASS_CERTIFICATE = (supportSignedBundles & SIGNED_CONTENT_VERIFY_CERTIFICATE) != 0 && // Boolean.valueOf(getConfiguration(PROP_CLASS_CERTIFICATE_SUPPORT, "true")).booleanValue(); //$NON-NLS-1$ runtimeVerifySignedBundles = (supportSignedBundles & SIGNED_CONTENT_VERIFY_RUNTIME) != 0; + + THROW_ISE_UNREGISTER = "true".equals(getConfiguration(PROP_THROW_ISE_UNREGISTER)); //$NON-NLS-1$ } private static int getSupportSignedBundles(EquinoxConfiguration config) { diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java index 252f362c610..84cac8b8de8 100644 --- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/serviceregistry/ServiceRegistrationImpl.java @@ -225,6 +225,10 @@ public void unregister() { synchronized (registry) { synchronized (registrationLock) { if (state != REGISTERED) { /* in the process of unregisterING */ + if (context.getContainer().getConfiguration().THROW_ISE_UNREGISTER) { + // TODO temp behavior enabled to pass the OSGi TCK + throw new IllegalStateException(Msg.SERVICE_ALREADY_UNREGISTERED_EXCEPTION + ' ' + this); + } return; } diff --git a/pom.xml b/pom.xml index 222d666747e..45163cb6bd7 100644 --- a/pom.xml +++ b/pom.xml @@ -126,6 +126,7 @@ osgi.ee; osgi.ee="II-1.0/JJ-2.0", osgi.ee; osgi.ee="div/tb7a" + true