Source:
public void updateManagedService( long maxWaitTime, String servicePid, Map<String, Object> properties, @Nullable String bundleLocation) throws SynchronizedInstallerException, InterruptedException { long startTime = System.currentTimeMillis(); waitForServiceToBeAvailable(maxWaitTime, servicePid); long remainingTime = getRemainingTime(startTime, maxWaitTime, DEFAULT_POLLING_INTERVAL); LOGGER.debug( "Registering service configuration listener to listen to service with pid of {}.", servicePid); SynchronizedConfigurationListener listener = new SynchronizedConfigurationListener(servicePid); ServiceRegistration<?> registration = bundleContext.registerService(ConfigurationListener.class.getName(), listener, null); Callable<Boolean> isServiceUpdated = () -> { LOGGER.trace( "Waiting for service with pid to reflect configuration updates...", servicePid); return listener.isUpdated(); }; LOGGER.info("Updating configuration of service with pid [{}].", servicePid); try { Configuration config = configAdmin.getConfiguration(servicePid, bundleLocation); config.setBundleLocation(bundleLocation); config.update(toDic(properties)); LOGGER.debug("Updated configuration of service with pid [{}].", servicePid); wait( isServiceUpdated, remainingTime, DEFAULT_POLLING_INTERVAL, "Managed service failed to update within [" + maxWaitTime + "] ms."); } catch (InterruptedException | SynchronizedInstallerException e) { throw e; } catch (IOException e) { throw new SynchronizedInstallerException( "Failed to update managed service configuration with pid of [" + servicePid + "]", e); } catch (Exception e) { throw new SynchronizedInstallerException( "Exception was thrown while waiting for service with pid of [" + servicePid + "] to be updated.", e); } finally { registration.unregister(); } }

Target:
public void updateManagedService( long maxWaitTime, String servicePid, Map<String, Object> properties, @Nullable String bundleLocation) throws InterruptedException { long startTime = System.currentTimeMillis(); waitForServiceToBeAvailable(maxWaitTime, servicePid); LOGGER.debug( "Registering service configuration listener to listen to service with pid of {}.", servicePid); SynchronizedConfigurationListener listener = getConfigListener(servicePid); ServiceRegistration<?> registration = bundleContext.registerService(ConfigurationListener.class.getName(), listener, null); Callable<Boolean> isServiceUpdated = () -> { LOGGER.trace( "Waiting for service with pid to reflect configuration updates...", servicePid); return listener.isUpdated(); }; LOGGER.info("Updating configuration of service with pid [{}].", servicePid); try { Configuration config = configAdmin.getConfiguration(servicePid, bundleLocation); config.setBundleLocation(bundleLocation); config.update(toDic(properties)); LOGGER.debug("Updated configuration of service with pid [{}].", servicePid); wait( isServiceUpdated, getRemainingTime(startTime, maxWaitTime), DEFAULT_POLLING_INTERVAL, "Managed service failed to update within [" + maxWaitTime + "] ms."); } catch (InterruptedException | SynchronizedInstallerException e) { throw e; } catch (IOException e) { throw new SynchronizedInstallerException( "Failed to update managed service configuration with pid of [" + servicePid + "]", e); } catch (Exception e) { throw new SynchronizedInstallerException( "Exception was thrown while waiting for service with pid of [" + servicePid + "] to be updated.", e); } finally { registration.unregister(); } }