Skip to content

Commit

Permalink
Work around OSGi Framework TCK that expects IllegalStateException
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tjwatson committed Dec 3, 2024
1 parent 793dcc5 commit caf78f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
osgi.ee; osgi.ee="II-1.0/JJ-2.0",
osgi.ee; osgi.ee="div/tb7a"
</org.osgi.framework.system.capabilities.extra>
<org.eclipse.osgi.internal.throw.ise.unregister>true</org.eclipse.osgi.internal.throw.ise.unregister>
</properties>
</configuration>
</execution>
Expand Down

0 comments on commit caf78f7

Please sign in to comment.