Skip to content
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

Cache NPE issue #3272

Closed
FqqCS opened this issue Jun 25, 2021 · 0 comments
Closed

Cache NPE issue #3272

FqqCS opened this issue Jun 25, 2021 · 0 comments
Assignees
Labels
Milestone

Comments

@FqqCS
Copy link

FqqCS commented Jun 25, 2021

In Class:io.fabric8.kubernetes.client.informers.cache.Cache

In method "replace" , if arg "list" is empty; this.indices will be set to an empty hashmap. in method "byIndex",object "index" used without check NPE, so when watch a kind without any resource, and then using byIndex to get, NPE happened. maybe should return an empty object instead of throw NPE.

// In byIndex
Map<String, Set> index = this.indices.get(indexName);
Set set = index.get(indexKey);

public synchronized void replace(List list, String resourceVersion) {
Map<String, T> newItems = new HashMap<>();
for (T item : list) {
String key = keyFunc.apply(item);
newItems.put(key, item);
}
this.items = newItems;

// rebuild any index
**this.indices = new HashMap<>();**
for (Map.Entry<String, T> itemEntry : items.entrySet()) {
  this.updateIndices(null, itemEntry.getValue(), itemEntry.getKey());
}

}

@shawkins shawkins self-assigned this Jun 25, 2021
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Jun 25, 2021
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Jun 25, 2021
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Jun 25, 2021
@manusa manusa added the bug label Jun 28, 2021
@manusa manusa added this to the 5.5.0 milestone Jun 28, 2021
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Jun 28, 2021
@manusa manusa closed this as completed in 0dd0ad1 Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants