linkedin / avro-util

Collection of utilities to allow writing java code that operates across a wide range of avro versions.
BSD 2-Clause "Simplified" License
76 stars 59 forks source link

fix complex default conversion - handle list #522

Closed dg-builder closed 11 months ago

dg-builder commented 12 months ago

FieldBuilder19, FieldBuilder110, FieldBuilder111 handle conversion of default values into "acceptable" default values. However, this conversion wasn't handling default values that were non-empty lists.

Added UTs to test this case.

More details on this method in the java doc:

  /**
   * we want to be very generous with what we let users provide for default values.
   * sadly, (modern) avro can only handle specific classes/collections/primitive-wrappers
   * (see org.apache.avro.util.internal.JacksonUtils.toJson(Object, JsonGenerator) in 1.9+)
   * @param mightNotBeFriendly a proposed field default value that might originate from
   *                           a call like AvroCompatibilityHelper.getGenericDefaultValue()
   * @return a representation of the input that avro likes for use as a field default value
   */
codecov-commenter commented 12 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (cd17a70) 45.78% compared to head (0e048de) 45.81%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #522 +/- ## ============================================ + Coverage 45.78% 45.81% +0.02% - Complexity 4444 4445 +1 ============================================ Files 403 403 Lines 28070 28091 +21 Branches 4622 4628 +6 ============================================ + Hits 12853 12871 +18 + Misses 13664 13663 -1 - Partials 1553 1557 +4 ``` | [Files](https://app.codecov.io/gh/linkedin/avro-util/pull/522?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=linkedin) | Coverage Δ | | |---|---|---| | [...routil1/compatibility/avro110/FieldBuilder110.java](https://app.codecov.io/gh/linkedin/avro-util/pull/522?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=linkedin#diff-aGVscGVyL2ltcGxzL2hlbHBlci1pbXBsLTExMC9zcmMvbWFpbi9qYXZhL2NvbS9saW5rZWRpbi9hdnJvdXRpbDEvY29tcGF0aWJpbGl0eS9hdnJvMTEwL0ZpZWxkQnVpbGRlcjExMC5qYXZh) | `83.33% <100.00%> (+1.51%)` | :arrow_up: | | [...routil1/compatibility/avro111/FieldBuilder111.java](https://app.codecov.io/gh/linkedin/avro-util/pull/522?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=linkedin#diff-aGVscGVyL2ltcGxzL2hlbHBlci1pbXBsLTExMS9zcmMvbWFpbi9qYXZhL2NvbS9saW5rZWRpbi9hdnJvdXRpbDEvY29tcGF0aWJpbGl0eS9hdnJvMTExL0ZpZWxkQnVpbGRlcjExMS5qYXZh) | `77.38% <100.00%> (+2.05%)` | :arrow_up: | | [...avroutil1/compatibility/avro19/FieldBuilder19.java](https://app.codecov.io/gh/linkedin/avro-util/pull/522?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=linkedin#diff-aGVscGVyL2ltcGxzL2hlbHBlci1pbXBsLTE5L3NyYy9tYWluL2phdmEvY29tL2xpbmtlZGluL2F2cm91dGlsMS9jb21wYXRpYmlsaXR5L2F2cm8xOS9GaWVsZEJ1aWxkZXIxOS5qYXZh) | `83.33% <100.00%> (+1.51%)` | :arrow_up: | ... and [6 files with indirect coverage changes](https://app.codecov.io/gh/linkedin/avro-util/pull/522/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=linkedin)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.