test_class.file: oak-core-spi/src/test/java/org/apache/jackrabbit/oak/osgi/OsgiWhiteboardTest.java
test_class.identifier: OsgiWhiteboardTest
test_case.body: @Test
      public void testDoubleUnregister() {
          BundleContext bundleContext = mock(BundleContext.class);
          OsgiWhiteboard w = new OsgiWhiteboard(bundleContext);
  
          Runnable r = new Runnable() {
              @Override
              public void run() {
                  //
              }
          };
  
          final AtomicBoolean unregistered = new AtomicBoolean();
          ServiceRegistration sr = new ServiceRegistration() {
  
              @Override
              public void unregister() {
                  if (unregistered.get()) {
                      throw new IllegalStateException(
                              "Service already unregistered.");
                  }
                  unregistered.set(true);
              }
  
              @Override
              public void setProperties(Dictionary properties) {
              }
  
              @Override
              public ServiceReference getReference() {
                  return null;
              }
          };
  
          when(
                  bundleContext.registerService(Runnable.class.getName(), r,
                          new Hashtable<Object, Object>())).thenReturn(sr);
          Registration reg = w.register(Runnable.class, r,
                  new HashMap<String, Object>());
          reg.unregister();
  
          assertTrue(unregistered.get());
          reg.unregister();
      }
test_case.class_method_signature: OsgiWhiteboardTest.testDoubleUnregister()
test_case.full_signature: @Test public void testDoubleUnregister()
test_case.identifier: testDoubleUnregister
test_case.invocations: mock get set thenReturn when registerService getName register unregister assertTrue get unregister
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDoubleUnregister()
focal_class.declarator: log = LoggerFactory
              .getLogger(OsgiWhiteboard.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory
              .getLogger(OsgiWhiteboard.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: context
focal_class.modifier: private final
focal_class.original_string: private final BundleContext context;
focal_class.type: BundleContext
focal_class.var_name: context
focal_class.file: oak-core-spi/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiWhiteboard.java
focal_class.identifier: OsgiWhiteboard
focal_class.interfaces: implements Whiteboard
focal_class.class_method_signature: OsgiWhiteboard.OsgiWhiteboard(@NotNull BundleContext context)
focal_class.full_signature: public  OsgiWhiteboard(@NotNull BundleContext context)
focal_class.identifier: OsgiWhiteboard
focal_class.modifiers: public
focal_class.parameters: (@NotNull BundleContext context)
focal_class.signature:  OsgiWhiteboard(@NotNull BundleContext context)
focal_class.class_method_signature: OsgiWhiteboard.register(
              final Class<T> type, final T service, Map<?, ?> properties)
focal_class.full_signature: @Override public Registration register(
              final Class<T> type, final T service, Map<?, ?> properties)
focal_class.identifier: register
focal_class.modifiers: @Override public
focal_class.parameters: (
              final Class<T> type, final T service, Map<?, ?> properties)
focal_class.return: Registration
focal_class.signature: Registration register(
              final Class<T> type, final T service, Map<?, ?> properties)
focal_class.class_method_signature: OsgiWhiteboard.track(final Class<T> type)
focal_class.full_signature: @Override public Tracker<T> track(final Class<T> type)
focal_class.identifier: track
focal_class.modifiers: @Override public
focal_class.parameters: (final Class<T> type)
focal_class.return: Tracker<T>
focal_class.signature: Tracker<T> track(final Class<T> type)
focal_class.class_method_signature: OsgiWhiteboard.track(Class<T> type, Map<String, String> filterProperties)
focal_class.full_signature: @Override public Tracker<T> track(Class<T> type, Map<String, String> filterProperties)
focal_class.identifier: track
focal_class.modifiers: @Override public
focal_class.parameters: (Class<T> type, Map<String, String> filterProperties)
focal_class.return: Tracker<T>
focal_class.signature: Tracker<T> track(Class<T> type, Map<String, String> filterProperties)
focal_class.class_method_signature: OsgiWhiteboard.track(Class<T> type, Filter filter)
focal_class.full_signature: private Tracker<T> track(Class<T> type, Filter filter)
focal_class.identifier: track
focal_class.modifiers: private
focal_class.parameters: (Class<T> type, Filter filter)
focal_class.return: Tracker<T>
focal_class.signature: Tracker<T> track(Class<T> type, Filter filter)
focal_class.class_method_signature: OsgiWhiteboard.getServiceList(
              Map<ServiceReference, T> services)
focal_class.full_signature: private static List<T> getServiceList(
              Map<ServiceReference, T> services)
focal_class.identifier: getServiceList
focal_class.modifiers: private static
focal_class.parameters: (
              Map<ServiceReference, T> services)
focal_class.return: List<T>
focal_class.signature: List<T> getServiceList(
              Map<ServiceReference, T> services)
focal_method.body: @Override
      public <T> Registration register(
              final Class<T> type, final T service, Map<?, ?> properties) {
          checkNotNull(type);
          checkNotNull(service);
          checkNotNull(properties);
          checkArgument(type.isInstance(service));
  
          Dictionary<Object, Object> dictionary = new Hashtable<Object, Object>();
          for (Map.Entry<?, ?> entry : properties.entrySet()) {
              dictionary.put(entry.getKey(), entry.getValue());
          }
  
          final ServiceRegistration registration =
                  context.registerService(type.getName(), service, dictionary);
          return new Registration() {
              private volatile boolean unregistered;
              @Override
              public void unregister() {
                  try {
                      if (!unregistered) {
                          registration.unregister();
                          unregistered = true;
                      } else {
                          log.warn("Service {} of type {} unregistered multiple times", service, type);
                      }
                  } catch (IllegalStateException ex) {
                      log.warn("Error unregistering service: {} of type {}",
                              service, type.getName(), ex);
                  }
              }
          };
      }
focal_method.class_method_signature: OsgiWhiteboard.register(
              final Class<T> type, final T service, Map<?, ?> properties)
focal_method.full_signature: @Override public Registration register(
              final Class<T> type, final T service, Map<?, ?> properties)
focal_method.identifier: register
focal_method.invocations: checkNotNull checkNotNull checkNotNull checkArgument isInstance entrySet put getKey getValue registerService getName unregister warn warn getName
focal_method.modifiers: @Override public
focal_method.parameters: (
              final Class<T> type, final T service, Map<?, ?> properties)
focal_method.return: Registration
focal_method.signature: Registration register(
              final Class<T> type, final T service, Map<?, ?> properties)