Skip to content

Commit 69ca6fd

Browse files
authored
Merge pull request kubernetes-client#819 from ahadas/refactoring
Minor cleanup in SharedInformerFactory
2 parents 4e4d045 + 0c08666 commit 69ca6fd

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

util/src/main/java/io/kubernetes/client/informer/SharedInformerFactory.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,9 @@ public synchronized void startAllRegisteredInformers() {
171171
return;
172172
}
173173
informers.forEach(
174-
(informerType, informer) -> {
175-
if (!startedInformers.containsKey(informerType)) {
176-
startedInformers.put(informerType, informerExecutor.submit(informer::run));
177-
}
178-
});
174+
(informerType, informer) ->
175+
startedInformers.computeIfAbsent(
176+
informerType, key -> informerExecutor.submit(informer::run)));
179177
}
180178

181179
/** Stop all registered informers and shut down the thread pool. */
@@ -194,8 +192,7 @@ public synchronized void stopAllRegisteredInformers(boolean shutdownThreadPool)
194192
}
195193
informers.forEach(
196194
(informerType, informer) -> {
197-
if (startedInformers.containsKey(informerType)) {
198-
startedInformers.remove(informerType);
195+
if (startedInformers.remove(informerType) != null) {
199196
informer.stop();
200197
}
201198
});

0 commit comments

Comments
 (0)