Closed
Description
Bug Report
I got the following error on one of my machines repeatedly, when the same code worked fine on others:
class java.util.UUID cannot be cast to class java.net.InetAddress (java.util.UUID and java.net.InetAddress are in module java.base of loader 'bootstrap')
at io.r2dbc.postgresql.codec.InetAddressCodec.doEncode(InetAddressCodec.java:35)
It took me some time to debug this (also because running the JVM with debugger enabled would change the behavior), but I finally found the culprit.
It seems that it can happen that java.util.UUID.class.hashCode() == java.net.InetAddress.class.hashCode()
and the CachedCodecLookup
implementation does not handle that case. I don't know why this happens and would assume that the JVM makes best effort to not let this happen, but it does happen for me and for as far as I can tell, the JVM and Java documentation do not guarantee that it can't happen.
Versions
- Driver: 0.8.11
- Database: 13.5
- Java: 11.0.15
- OS: Linux 5.10