Skip to content

fix: state controller name in exception #1002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2022
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