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 doesn't find getMetadata method although it is present #1902

Closed
ctron opened this issue Dec 10, 2019 · 0 comments · Fixed by #1903
Closed

Cache doesn't find getMetadata method although it is present #1902

ctron opened this issue Dec 10, 2019 · 0 comments · Fixed by #1903

Comments

@ctron
Copy link
Contributor

ctron commented Dec 10, 2019

The Cache implementation doesn't find the getMetadata method although it is present:

2019-12-10T14:32:21.596Z ERROR [ReflectorRunnable] Failure in list-watch: java.lang.ReflectiveOperationException: java.lang.NoSuchMethodException: io.enmasse.iot.model.v1.IoTProject.getMetadata()
java.lang.RuntimeException: java.lang.ReflectiveOperationException: java.lang.NoSuchMethodException: io.enmasse.iot.model.v1.IoTProject.getMetadata()
	at io.fabric8.kubernetes.client.informers.cache.Cache.metaNamespaceKeyFunc(Cache.java:365)
	at io.fabric8.kubernetes.client.informers.cache.DeltaFIFO.keyOf(DeltaFIFO.java:381)
	at io.fabric8.kubernetes.client.informers.cache.DeltaFIFO.replace(DeltaFIFO.java:165)
	at io.fabric8.kubernetes.client.informers.cache.ReflectorRunnable.syncWith(ReflectorRunnable.java:145)
	at io.fabric8.kubernetes.client.informers.cache.ReflectorRunnable.run(ReflectorRunnable.java:69)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ReflectiveOperationException: java.lang.NoSuchMethodException: io.enmasse.iot.model.v1.IoTProject.getMetadata()
	at io.fabric8.kubernetes.client.utils.ReflectUtils.objectMetadata(ReflectUtils.java:31)
	at io.fabric8.kubernetes.client.informers.cache.Cache.metaNamespaceKeyFunc(Cache.java:355)
	... 10 more
Caused by: java.lang.NoSuchMethodException: io.enmasse.iot.model.v1.IoTProject.getMetadata()
	at java.base/java.lang.Class.getDeclaredMethod(Class.java:2475)
	at io.fabric8.kubernetes.client.utils.ReflectUtils.objectMetadata(ReflectUtils.java:28)
	... 11 more

This is due to the fact that ReflectUtils uses getDeclaredMethod, which will only find methods which are directly declared on the class:

Method mdField = obj.getClass().getDeclaredMethod("getMetadata");
return (ObjectMeta) mdField.invoke(obj);

Instead of doing reflection, the code should check for instanceof HasMetadata and maybe then use Class#getMethod.

ctron added a commit to ctron/kubernetes-client that referenced this issue Dec 10, 2019
ctron added a commit to ctron/enmasse that referenced this issue Dec 10, 2019
ctron added a commit to EnMasseProject/enmasse that referenced this issue Dec 11, 2019
ctron added a commit to ctron/kubernetes-client that referenced this issue Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant