Skip to content

Commit 95ac79f

Browse files
authored
fix: state controller name in exception (#1002)
Fixes #1001
1 parent 297b084 commit 95ac79f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventSourceManager.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ public final void registerEventSource(EventSource eventSource)
129129
} catch (IllegalStateException | MissingCRDException e) {
130130
throw e; // leave untouched
131131
} catch (Exception e) {
132-
throw new OperatorException("Couldn't register event source: " + eventSource.name(), e);
132+
throw new OperatorException("Couldn't register event source: " + eventSource.name() + " for "
133+
+ controller.getConfiguration().getName() + " controller`", e);
133134
} finally {
134135
lock.unlock();
135136
}
136137
}
137138

139+
@SuppressWarnings("unchecked")
138140
public void broadcastOnResourceEvent(ResourceAction action, R resource, R oldResource) {
139141
for (var eventSource : eventSources) {
140142
if (eventSource instanceof ResourceEventAware) {
@@ -211,8 +213,8 @@ public Iterator<EventSource> iterator() {
211213
}
212214

213215
public Set<EventSource> all() {
214-
return new LinkedHashSet<>(sources.values().stream().flatMap(Collection::stream)
215-
.collect(Collectors.toList()));
216+
return sources.values().stream().flatMap(Collection::stream)
217+
.collect(Collectors.toCollection(LinkedHashSet::new));
216218
}
217219

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

241+
@SuppressWarnings("rawtypes")
239242
private Class<?> getDependentType(EventSource source) {
240243
return source instanceof ResourceEventSource
241244
? ((ResourceEventSource) source).getResourceClass()
@@ -265,6 +268,7 @@ private String keyFor(Class<?> dependentType) {
265268
return key;
266269
}
267270

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

0 commit comments

Comments
 (0)