[client-v2] Compiled POJO setter emits invalid bytecode (VerifyError) when the column type does not match the primitive field type
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
- #3000 de @polyglotAI-bot — fechado sem integrar
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 58/100
Direção de pesquisa
Reproduza a falha com a consulta POJO de client-v2 mostrada e, em seguida, inspecione SerializerUtils.compilePOJOSetter e binaryReaderMethodForType, incluindo os branches longToOpcode, floatToOpcode e doubleToOpcode. Está concluído quando bindings primitivos incompatíveis gerarem setters verificáveis com conversões de narrowing ou widening do Java, e colunas com valores Number puderem ser lidas em campos primitivos sem um VerifyError.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Describe the bug
client-v2 compiles a POJO field setter into bytecode (SerializerUtils.compilePOJOSetter). When the column type
and the POJO field's primitive type do not match exactly, the generated class is invalid and reading fails with
java.lang.VerifyError (thrown when the compiled setter class is first linked, i.e. on the first row read).
Two distinct groups of combinations are affected.
1. The value left on the stack is not converted to the setter's primitive type.
binaryReaderMethodForType only computed a conversion opcode for a few reader/field combinations
(longToOpcode, floatToOpcode and doubleToOpcode return -1 for byte/short/char/boolean, and the
Int8/UInt8/Int16/Enum8/Enum16/Bool branches computed no conversion at all). So, for example:
- an
Int64,UInt32,Float32,Float64orBFloat16column bound to abyte,short,charorbooleanfield - an
Int8,UInt8,Int16,Enum8,Enum16orBoolcolumn bound to along,floatordoublefield
leave a value of the wrong type on the operand stack for the setter descriptor, and the generated class does not verify.
2. A primitive field bound to a column that is not read into a primitive.
The generic branch emits LDC of a class constant for the target type and CHECKCAST with its internal name.
For a primitive target that produces a class constant named "I"/"J" and a CHECKCAST int, and the value read
by readValue (an Object) is passed to a primitive setter descriptor. So Int128, UInt128, Int256, UInt256
and Decimal* columns cannot be read into a primitive field at all, even though the value is a Number.
Steps to reproduce
public class Pojo {
private short v;
public short getV() { return v; }
public void setV(short v) { this.v = v; }
}
String sql = "SELECT toInt64(300) AS v"; // also: toFloat64(-2.7), toInt8(-5) into a long field, ...
TableSchema schema = client.getTableSchemaFromQuery(sql);
client.register(Pojo.class, schema);
client.queryAll(sql, Pojo.class, schema); // -> java.lang.VerifyError
The same happens with SELECT toInt128(-2) AS v or SELECT toDecimal64(123.45, 2) AS v bound to a long/double
field (group 2).
Expected behaviour
The value is converted to the field's primitive type following Java's narrowing/widening rules (as already happens
for an Int32 column bound to a byte field), and a Number-valued column can be read into a primitive field.
Error log
java.lang.VerifyError
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
...
at com.clickhouse.client.api.data_formats.internal.SerializerUtils.compilePOJOSetter(SerializerUtils.java:...)
Configuration
- Client version:
main(0.11.0-rc1) - Language: Java
- Client:
client-v2(POJO binding /queryAll(sql, Pojo.class, schema))
- Linguagem predominante
- Java
- Estrelas
- 1.6k
- Forks
- 640
- Merge médio
- 1d 12h
- PRs com merge (30d)
- 42
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de ClickHouse/clickhouse-java
-
bug jdbc-v2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
ClickHouse/clickhouse-java#3214 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
ClickHouse/clickhouse-java#3212 ·
Mantenedores costumam responder em até 1 dia
-
bug client-api-v2 test
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 92/100
ClickHouse/clickhouse-java#3076 ·
Mantenedores costumam responder em até 1 dia
-
area:sql-parser bug client-v1
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 92/100
ClickHouse/clickhouse-java#3066 ·
Mantenedores costumam responder em até 1 dia
-
bug client-api-v2 jdbc-v2
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 78/100
ClickHouse/clickhouse-java#2957 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de ClickHouse/clickhouse-java
Issues semelhantes
-
[Bug] Lock owned by another client (e.g. Text app) cannot be unlocked from the appTalvez já em andamento @falkloewert assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
oracle/graalvm-reachability-metadata#11026 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
checkstyle/checkstyle#22050 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
enhancement Improvement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
zowe/zowe-client-java-sdk#647 ·
-
RRX SAX: </rdf:RDF> inside rdf:parseType="Literal" ends the document ("Inconsistent parserMode:TOP")Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
apache/jena#4334 · 1 comentário ·
Mantenedores costumam responder em até 1 dia