You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "LDonoughe-mdsol (via GitHub)" <gi...@apache.org> on 2023/08/04 22:06:07 UTC
[GitHub] [avro] LDonoughe-mdsol opened a new pull request, #2420: AVRO-3791: [Java] Include field in readField AvroTypeException
LDonoughe-mdsol opened a new pull request, #2420:
URL: https://github.com/apache/avro/pull/2420
## What is the purpose of the change
This pull request improves java error messages by including field in readField AvroTypeException fixing AVRO-3791
In order to bring more clarity and save users time error messages include the field avro fails to read. It is now immediately apparent which field in a record has issues that need correcting.
## Verifying this change
This change is already covered by existing tests, such as fieldDefaultNotAppliedForUnknownSymbol, unionErrorMessage, enumDefaultNotAppliedWhenWriterFieldMissing, TestReadingWritingDataInEvolvedSchemas, and jsonExcessFields
## Documentation
- Does this pull request introduce a new feature? No
- If yes, how is the feature documented? not applicable
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [avro] clesaec commented on a diff in pull request #2420: AVRO-3791: [Java] Include field in readField AvroTypeException
Posted by "clesaec (via GitHub)" <gi...@apache.org>.
clesaec commented on code in PR #2420:
URL: https://github.com/apache/avro/pull/2420#discussion_r1285478016
##########
lang/java/avro/src/main/java/org/apache/avro/generic/GenericDatumReader.java:
##########
@@ -257,7 +258,12 @@ protected Object readRecord(Object old, Schema expected, ResolvingDecoder in) th
*/
protected void readField(Object record, Field field, Object oldDatum, ResolvingDecoder in, Object state)
throws IOException {
- data.setField(record, field.name(), field.pos(), read(oldDatum, field.schema(), in), state);
+ try {
+ data.setField(record, field.name(), field.pos(), read(oldDatum, field.schema(), in), state);
+ } catch(AvroTypeException exception) {
+ String message = "Field \"" + field.name() + "\" content mismatch: " + exception.getMessage();
+ throw new AvroTypeException(message);
Review Comment:
In order to not loose the stack trace; use constructor with "cause" parameter; either
`throw new AvroTypeException(message, exception);`
or, to avoid having 2 AvroTypeException
`throw new AvroTypeException(message, exception.getCause());`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [avro] clesaec commented on pull request #2420: AVRO-3791: [Java] Include field in readField AvroTypeException
Posted by "clesaec (via GitHub)" <gi...@apache.org>.
clesaec commented on PR #2420:
URL: https://github.com/apache/avro/pull/2420#issuecomment-1680710207
need to run "mvn spotless::apply" command.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [avro] opwvhk commented on pull request #2420: AVRO-3791: [Java] Include field in readField AvroTypeException
Posted by "opwvhk (via GitHub)" <gi...@apache.org>.
opwvhk commented on PR #2420:
URL: https://github.com/apache/avro/pull/2420#issuecomment-1680414302
Looks good.
One question: do we want the field name be prefixed with the full record name?
Reasoning: field names are only unique within a record, which is uniquely identified by its full name. Then again, using only the field names is usually more readable (if possibly ambiguous).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org