Source:
<code>private void waitForInputTransformers() throws InterruptedException { final String propertyId = "id"; Set<String> propertyValues = new HashSet<>(inputTransformerIds.getTransformerIds()); if (propertyValues.isEmpty()) { return; } long lastChecked = new Date().getTime(); long end = lastChecked + transformerWaitTimeoutMillis; for (; ; ) { if (configDeleted.get()) { throw new IllegalStateException(); } for (ServiceReference serviceReference : inputTransformers) { Object propertyValue = serviceReference.getProperty(propertyId); if (propertyValue instanceof String) { propertyValues.remove(propertyValue); LOGGER.debug("Remaining property values {}", propertyValues); } } if (propertyValues.isEmpty()) { LOGGER.trace("Finished finding all InputTransformers"); break; } if (lastChecked >= end) { LOGGER.warn( "Not all input transformers were found, starting up CDM route anyways. Ingested resources may not have expected metadata"); break; } else { LOGGER.trace( "Waiting seconds before checking InputTransformers again", TimeUnit.MILLISECONDS.toSeconds(transformerCheckPeriodMillis)); lastChecked += transformerCheckPeriodMillis; <START> lock.wait(transformerCheckPeriodMillis); <END> } } }</code><technical_language>if caller of method is acquiring lock, acquire in clear are. a wait() object in a method synchronizing is a good practice easily lead issues maintenance if a developer decides remove synchronization in calling method</technical_language>

Target:
private void waitForInputTransformers() throws InterruptedException { Set<String> configuredInputTransformers = inputTransformerIds.getIds(); if (configuredInputTransformers.isEmpty()) { return; } Set<String> requiredInputTransformers = new HashSet<>(configuredInputTransformers); long lastChecked = System.currentTimeMillis(); long end = lastChecked + transformerWaitTimeoutMillis; LOGGER.trace( "Beginning wait for InputTransformers for seconds", TimeUnit.MILLISECONDS.toSeconds(transformerWaitTimeoutMillis)); for (; ; ) { for (ServiceReference serviceReference : inputTransformers) { Object propertyValue = serviceReference.getProperty(TRANSFORMER_ID_PROPERTY); if (propertyValue instanceof String) { requiredInputTransformers.remove(propertyValue); LOGGER.debug("Remaining property values {}", requiredInputTransformers); } } if (requiredInputTransformers.isEmpty()) { LOGGER.trace("Finished finding all InputTransformers"); break; } if (lastChecked >= end) { throw new IllegalArgumentException( String.format( "Not all expected Input Transformers were found within %s seconds. Expected: %s, but didn't find: %s. " + "CDMs will not be able to start without all required InputTransformers. Either remove the un-found " + "IDs from the InputTransformer ID JSON files under etc/transformers, or ensure the bundle providing " + "the missing InputTransformer is started.", TimeUnit.MILLISECONDS.toSeconds(transformerWaitTimeoutMillis), configuredInputTransformers, requiredInputTransformers)); } else { LOGGER.trace( "Waiting seconds before checking InputTransformers again", TimeUnit.MILLISECONDS.toSeconds(transformerCheckPeriodMillis)); lastChecked += transformerCheckPeriodMillis; synchronized (lock) { lock.wait(transformerCheckPeriodMillis); } } } }