Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@ public final void registerEventSource(EventSource eventSource)
} catch (IllegalStateException | MissingCRDException e) {
throw e; // leave untouched
} catch (Exception e) {
throw new OperatorException("Couldn't register event source: " + eventSource.name(), e);
throw new OperatorException("Couldn't register event source: " + eventSource.name() + " for "
+ controller.getConfiguration().getName() + " controller`", e);
} finally {
lock.unlock();
}
}

@SuppressWarnings("unchecked")
public void broadcastOnResourceEvent(ResourceAction action, R resource, R oldResource) {
for (var eventSource : eventSources) {
if (eventSource instanceof ResourceEventAware) {
Expand Down Expand Up @@ -211,8 +213,8 @@ public Iterator<EventSource> iterator() {
}

public Set<EventSource> all() {
return new LinkedHashSet<>(sources.values().stream().flatMap(Collection::stream)
.collect(Collectors.toList()));
return sources.values().stream().flatMap(Collection::stream)
.collect(Collectors.toCollection(LinkedHashSet::new));
}

public void clear() {
Expand All @@ -236,6 +238,7 @@ public void add(EventSource eventSource) {
sources.computeIfAbsent(keyFor(eventSource), k -> new ArrayList<>()).add(eventSource);
}

@SuppressWarnings("rawtypes")
private Class<?> getDependentType(EventSource source) {
return source instanceof ResourceEventSource
? ((ResourceEventSource) source).getResourceClass()
Expand Down Expand Up @@ -265,6 +268,7 @@ private String keyFor(Class<?> dependentType) {
return key;
}

@SuppressWarnings("unchecked")
public <S> ResourceEventSource<R, S> get(Class<S> dependentType, String name) {
final var sourcesForType = sources.get(keyFor(dependentType));
if (sourcesForType == null || sourcesForType.isEmpty()) {
Expand Down