in src/main/java/org/apache/sling/event/impl/jobs/JobConsumerManager.java [356:398]
private void unbindService(final ServiceReference<?> serviceReference, final boolean isConsumer) {
final String[] topics = PropertiesUtil.toStringArray(serviceReference.getProperty(JobConsumer.PROPERTY_TOPICS));
if ( topics != null && topics.length > 0 ) {
final ConsumerInfo info = new ConsumerInfo(serviceReference, isConsumer);
boolean changed = false;
synchronized ( this.topicToConsumerMap ) {
for(final String t : topics) {
if ( t != null ) {
final String topic = t.trim();
if ( topic.length() > 0 ) {
final List<ConsumerInfo> consumers = this.topicToConsumerMap.get(topic);
if ( consumers != null ) { // sanity check
for(final ConsumerInfo oldConsumer : consumers) {
if ( oldConsumer.equals(info) && oldConsumer.executor != null ) {
// notify listener
for(final Object[] listenerObjects : this.listenerMap.values()) {
if ( listenerObjects[0] == oldConsumer.executor ) {
final JobExecutionContext context = (JobExecutionContext)listenerObjects[1];
context.asyncProcessingFinished(context.result().failed());
break;
}
}
}
}
consumers.remove(info);
if ( consumers.size() == 0 ) {
this.topicToConsumerMap.remove(topic);
changed = true;
}
}
}
}
}
if ( changed ) {
this.calculateTopics(this.propagationService != null);
}
}
if ( changed && this.propagationService != null ) {
logger.debug("Updating property provider with: {}", this.topics);
this.propagationService.setProperties(this.getRegistrationProperties());
}
}
}