Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.20.0
Description
Currently, though ProtoToRowConverter try to handle PROTO3 as follows:
public ProtoToRowConverter(RowType rowType, PbFormatConfig formatConfig) throws PbCodegenException { try { Descriptors.Descriptor descriptor = PbFormatUtils.getDescriptor(formatConfig.getMessageClassName()); Class<?> messageClass = Class.forName( formatConfig.getMessageClassName(), true, Thread.currentThread().getContextClassLoader()); String fullMessageClassName = PbFormatUtils.getFullJavaName(descriptor); boolean readDefaultValuesForPrimitiveTypes = formatConfig.isReadDefaultValues(); if (descriptor.getFile().getSyntax() == Syntax.PROTO3) { // pb3 always read default values for primitive types readDefaultValuesForPrimitiveTypes = true; } //... }
However, protoc will compile message of PROTO3 as
FileDescriptor rather than Descriptor, thus the following code will throw exception:
public static Descriptors.Descriptor getDescriptor(String className) { try { Class<?> pbClass = Class.forName(className, true, Thread.currentThread().getContextClassLoader()); return (Descriptors.Descriptor) pbClass.getMethod(PbConstant.PB_METHOD_GET_DESCRIPTOR).invoke(null); } catch (Exception e) { throw new IllegalArgumentException( String.format("get %s descriptors error!", className), e); } }
Attachments
Attachments
Issue Links
- links to