Closed lukaseder closed 3 years ago
A ClassCastException is thrown when calling RowMetadata.getColumnNames().toArray(T[])
ClassCastException
RowMetadata.getColumnNames().toArray(T[])
System.out.println( Flux.from(cf.create()) .flatMap(c -> Mono.from(c.createStatement("select 1 as a").execute())) .flatMap(it -> it.map((r, m) -> { String[] s = m.getColumnNames().toArray(new String[0]); return ""; })) .blockFirst() );
The implementation is simply wrong:
@Override @SuppressWarnings("unchecked") public <T> T[] toArray(T[] a) { return (T[]) toArray(); }
Rather than fixing that particular implementation, I suggest that MssqlRowMetadata doesn't implement Collection<String>. I don't see why it should.
MssqlRowMetadata
Collection<String>
I'll be happy to report more of these, and maybe even send PRs, but I'd like to discuss the SPI question first: https://github.com/r2dbc/r2dbc-spi/issues/219
Bug Report
Versions
Current Behavior
A
ClassCastException
is thrown when callingRowMetadata.getColumnNames().toArray(T[])
Steps to reproduce
Possible Solution
The implementation is simply wrong:
Rather than fixing that particular implementation, I suggest that
MssqlRowMetadata
doesn't implementCollection<String>
. I don't see why it should.