-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AVRO-1849 Fix C++ schema to JSON converter #97
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Simon,
I noticed your pull request in the issue, it is a pity that it went unnoticed for so long. Thanks for the fix, if you are still willing to go forward with it, please see the suggestion in my comment.
Thanks,
Zoltan
std::ostringstream os; | ||
compiledSchema.toJson(os); | ||
std::string result = os.str(); | ||
result.erase( std::remove_if( result.begin(), result.end(), ::isspace ), result.end() ); // Remove whitespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of removing all whitespaces, consecutive whitespaces should be collapsed into a single space. It is true that it doesn't matter how many whitespaces there are, but it does matter whether there is or isn't whitespace between specific characters. A slight modification will give the desired result as described in http://stackoverflow.com/a/8362145/5613485
Additionally this line uses a different style than the other lines, there should be no spaces after '('-s or before ')'-s.
Thanks Zoltan. With regards whitespace in general, the reason for eradicating whitespace But if you think it's a change worth making, I'm happy to make it. With regards the length of time it took to pick up this Jira, obviously I Thanks and regards On Wed, Sep 21, 2016 at 12:49 PM, Zoltan Ivanfi [email protected]
|
Regarding the mixture of different whitespaces, my suggestion was meant to include replacing all of them with spaces before collapsing them. I should have mentioned it explicitly, sorry. On the other hand, your argument is valid as well, and what's more, there are cases where the existence of a whitespace doesn't make a difference - for example "[{" vs. "[ {". I haven't noticed it yesterday, but your test cases do not contain spaces in any location where their removal would matter. As such, apart from the minor styling difference, the current implementation is fine by me. Regarding your question about specific mailing lists for different programming languages, I don't believe they exist. |
"{\"name\":\"f2\",\"type\":\"int\"}]}", | ||
/* Avro-C++ cannot do a round-trip on error schemas. | ||
* "{\"type\":\"error\",\"name\":\"Test\",\"fields\":" | ||
"[{\"name\":\"f1\",\"type\":\"long\"}," |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Comment style is inconsistent, some lines start with a *, while others don't.
Thanks for flagging up these style issues. I believe I've fixed them all now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Simon,
I added a minor comment regarding BOOST_CHECKPOINT.
I also noticed that avro/lang/c++/build.sh doesn't run SchemaTests. I know that you only added one test case to this already existing test, but if it doesn't take too much of your time could you please update the shell script to actually run the test you extended? If you argue that it is out of scope, I can also do it in a follow-up change.
Thanks,
Zoltan
// used to construct it, apart from whitespace changes. | ||
static void testRoundTrip(const char* schema) | ||
{ | ||
BOOST_CHECKPOINT(schema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other tests have been updated to use BOOST_TEST_CHECKPOINT, please update this as well.
…ELinux (see Jira 1925). lang/c++/build.sh refers to the lang/c++/build directory which is empty. These are now fixed.
Hi Zoltan, I'm glad you asked for the fix to lang/c++/build.sh - I was going to start I've also committed a minor change to the root level build.sh script. When Thanks On Fri, Sep 23, 2016 at 7:33 PM, Zoltan Ivanfi [email protected]
|
Hi Simon, I feel that your fix for AVRO-1925 in the top-level Your change to ~/git/avro/lang/c++ $ git pull github pull/97/head Updating fcd0a65..f7826c6 4 files changed, 82 insertions(+), 19 deletions(-) ~/git/avro/lang/c++ $ ./build.sh test -- Configuring done -- Generating done -- Build files have been written to: /home/zi/git/avro/lang/c++/build make: *** No targets specified and no makefile found. Stop. Based on your description in AVRO-1926 it seems to me that things work differently on your computer: Your makefiles are not generated in Zoltan |
…SchemaTests to the list of tests. Also revert SELinux changes to build.sh as these should be committed separately
Hi Zoltan, I've reverted the changes to the build.sh and lang/c++/build.sh files. I'm Apologies for the multiple changes - I hope this is converging on something On Mon, Sep 26, 2016 at 2:13 PM, Zoltan Ivanfi [email protected]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Simon,
No problem, multiple rounds are normal in code reviews. Your contribution is definitely useful, thanks for your time!
Zoltan
Hi Simon, Tom committed your change, could you please close the pull request? Thanks, Zoltan |
…ity based on parsing canonical form (#97) I noticed that we were deriving PartialEq for Schema while my understanding is that the spec asserts that equality between schemas has to rely on parsing canonical form. So I manually impemented PartialEq and Eq based on that. I also created a bunch of issues to follow with the tests that I had to comment because they were failing.
https://docs.gradle.org/current/userguide/task_configuration_avoidance.html Thanks to [dcabasson](https://github.com/dcabasson) for the collaboration
…in (#2310) AVRO-3732: * Try again to avoid gradle welcome banner in CI * ci: try turning on github actions compatibility tests * fix ci syntax * ci: fix yaml indentation * ci: comment out fail fast * ci: fix matrix structure * CI: try matrix with allowed failures * CI: give up on conditional failures allowed for now; exclude java 13 * CI: info output for builds * Try to resolve the test failures on windows regarding default encoding handling * Fix encoding support on windows, for real this time * CI: add unsupported-java-versions job * CI: run the unsupported java versions job on all the OS versions After all, they'll all fail almost immediately anyway * README: Update badge to use github actions rather than travis * add support for generating optional getters * README: fix CI badge syntax * README: fix CI badge image * add doc for optional getter field generation * Update changelog to note the recent merged pull request * CI: disable the gradle daemon to try to eliminate the sporadic clean failure on windows * Remove security policy; not a CommerceHub OSS project any more * Update various files for commercehub-oss -> davidmc24 github move * Working version of custom conversions against modern gradle; still need to adjust for earlier versions * Don't use MapProperty yet; it wasn't introduced until Gradle 5.1 * Don't use ListProperty It changed incompatibly between Gradle 4.4 and Gralde 4.5 * Don't use Class.newInstance(), as it was deprecated in Java 11 * Update issue templates * Update bug_report.md to add a checklist * Update feature_request.md to include a checklist * CI: don't bother doing maintenance builds on old OS versions; only use latest * CI: update another place with os versions that I missed * version: 0.18.0 * version: 0.18.1-SNAPSHOT * update to Avro 1.9.2 since https://issues.apache.org/jira/browse/AVRO-2548 has been fixed there * Add support for Gradle 6.0-6.2, drop support for gradle <5.1 (#101) * Update changelog for #104 * Add support for Java 13 * Add support for testing multiple kotlin versions * Update plugin's own build to address some deprecation warnings of APIs being removed in Gradle 7 * BuildCacheSupportFunctionalSpec no longer needs an @IgnoreIf, as we only support versions where the Build Cache is supported. * Remove license plugin It was resulting in deprecation warnings about Gradle 7, a new version wasn't available, and I don't think it was providing real value. * Lots of test updates * Remove taskInfoAbsent, as it isn't needed any more with the versions of Gradle we support * Remove isMultipleClassDirectoriesUsed, as all versions of Gradle we support now use it * Leverage GradleRunner's withPluginClasspath feature when able to use plugin DSL to apply the test plugin * Add addDefaultRepository utility method * Add applyPlugin override that takes a version * Rename addDependency to addImplementationDependency; add addRuntimeDependency and addDependency that takes a configuration argument * Use stripMargin more consistently * Add tests for Kotlin DSL usage (#61) * Handle a test that appears to fail on Windows due to weird file locking behaviors * Update to note a Kotlin-Java version incompatibility * Update to gradle 6.2.2 * Official Gradle Wrapper Validation Action See: https://github.com/gradle/wrapper-validation-action Added as a dedicated Workflow * Support Task Configuration Avoidance (#97) https://docs.gradle.org/current/userguide/task_configuration_avoidance.html Thanks to [dcabasson](https://github.com/dcabasson) for the collaboration * Update test result directory names * Work around a bug showing in Gradle 5.1 It appears that in Gradle 5.1, TaskContainer's `withType` overwrites the results of `matching`, causing java compilation tasks to be returned. This results in a circular task dependency. Changing the order to filter by type first fixes it. * See if we can get Java 14 support working with a Gradle 6.3 nightly build * Update codenarc support so it works in Java 14+; update compatibility notes * version: 0.19.0 * version: 0.19.1-SNAPSHOT * Create FUNDING.yml * Update bug_report.md * Fix schema dependency resolution when types are referenced with a `{ "type": NAME }` block rather than just `NAME` (#107) * Eliminate `NullPointerException` handling in schema dependency resolution, as it no longer appears to be needed. * version: 0.19.1 * version: 0.19.2-SNAPSHOT * Add (#115) * Update version compatibility support * Built using Gradle 6.5 * Updated compatibility testing to include Java 14 * Updated compatibility testing through Gradle 6.5 * version: 0.20.0 * version: 0.20.1-SNAPSHOT * ci: Tweak how the jobs are run to reduce execution time and unreliability Mac OS X jobs have been failing with messages that they were cancelled. My theory is that either Mac OS X jobs are flakey right now, or I'm hitting an execution timeout of some kind. Either way, this reduces how long jobs run for and how many are run on Mac OS X. Hopefully it will complete faster (providing faster feedback) and be more reliable. * CI: try using eskatos/gradle-command-action to improve build speed This enables use of the daemon and easy caching of wrapper Might enable depenendcy caching latter (isn't on by default yet) * CI: try turning on build scans * CI: fix the build It looks like there may be an incompatibility between gradle-entrprise and gradle-github-actions; try just gradle-enterprise for now. Also, gralde-enterprise needs to be applied in the settings file with the latest version. * CI: some build tweaks for performance Enable github actions plugin to capture metadata in build scans Enable parallel builds Enable dependency caching * Correcting cache annotation for classpath * Correcting cache annotation for classpath - add items to unreleased changelog * Update to Avro 1.10.0 * Add a test project to aid in reproducing problems * Test cleanup and CHANGES.md additions for Avro 1.10.0 support * Fix test name for optionalGettersForNullableFieldsOnly * Confirm that the nullable getter is still generated when createOptionalGetters is enabled * Formatting fixes and test simplification * Fix optionalGettersForNullableFieldsOnly test naming and CHANGES formatting * Ensure option conditions are checked against relevant file portions * Remove apache staging dependency and pull release from JCenter * Ensure createOptionalGetters test checks correct mainClassContent * Remove extraneous newline from test repository definition * version: 0.21.0 * version: 0.21.1-SNAPSHOT * build: add coverage reporting using JaCoCo and Codecov * CI: flag codecov report by OS * Add support for multiple IDL files with the same name in different directories (#123) * Update AvroUtils and Strings, with unit test coverage * Fix codenarc failures * Fix a test typo (Fixes #125) * Update test-project to remove references to dataTimeLogicalType * Plugin DSL is no longer incubating, and is now recommended. * Upgrade to Avro 0.10.1 because of https://issues.apache.org/jira/browse/AVRO-2924 * Added compatibility testing against 1.10.0 and 1.10.1 * More spock assert about generated Java Code was added. Type uuid is not compilable with Avro 1.10.1 * Avro 1.10.1 was set also in test-project/build.gradle * Minor post pull-request-merge tweaks * Update compatibility with Java/Gradle, tweak build spead * Improve Java version support Use a Java 15-compatible version of Jacoco (currently requires a snapshot build) Use a new Java 9+ option in Gradle 6.6 that use cross-compilation to ensure that APIs not available in previous versions aren't used improperly * Correct Java 15 Gradle version compatibility * Add support for configuration cache and update kotlin testing Closes #129 * Make codenarc happy Fix ClosureStatementOnOpeningLineOfMultipleLineClosure violation * Address not all versions of kotlin plugin supporting config cache * version: 0.22.0 * version: 0.23.0-SNAPSHOT * Add link to discussions for Q&A * Revert "Add link to discussions for Q&A" This reverts commit 946cf47. * Add link to discussions for Q&A * Add feature requests to template chooser * Try moving feature requests to discussions * Update README to reflect changes in historical version handling * Update notes about pre-1.0 versions * Work towards a 1.0 release * Fix up POMs, add signing; to satisfy Maven Central requirements * version: 1.0.0 * version: 1.0.1-SNAPSHOT * version: 1.0.0 (take 2) * version: 1.0.0 (take 3) * version: 1.0.1-SNAPSHOT * Remove remaining references to jcenter * Build using Avro 1.10.2 * Build using Gradle 6.8.3 * Try running compatibility tests from github actions rather than gradle * Try extracting kotlin plugin compatibility testing to its own workflow * Try to fix CI job * Try to fix CI job * Fix testKotlinPluginCompatibility * Next try at kotlin compatibility * More matrix stuff * More matrix compatibility tweaks * More matrix compatibility tweaks * More matrix compatibility tweaks * More matrix compatibility tweaks * Upgrade gradle used to build the project to 7.0-rc-1 in order to support the build running on Java 16 * More changes for Gradle 7 compatibility * Add gradle compatibility tests * More spock 2.0 and Gradle 7 compatibility changes * Fix checkstyle violation * Tweak CI targets * Adjust compatibility notes/testing for java 16/17 * Use nexus publish plugin to automate management of OSSRH interactions * Adjust test report directories * Fix os compatibility tests * Update changelog * version: 1.1.0 * version: 1.1.1-SNAPSHOT * Try to fix publishing * Temporary change to test the CI publishing fix * Revert "Temporary change to test the CI publishing fix" This reverts commit 4fb85a4. * Re-add support for Avro 1.9.x * Update release notes * Throw error if avdl will be overwritten * Add to changelog * Minor touchups on avpr conflict detection * Add support for better coverage reporting... and disable it because it conflicts with configuration caching in Gradle 7.0 * version: 1.2.0 * version: 1.2.1-SNAPSHOT * Add examples/default-custom-types * Update for Gradle 7.1 * CI: update to setup-java v2 * Update comment on code coverage support * Update build/test to Gradle 7.1.1 * Update test-project to reproduce #167 * Explicitly declare dependencies between sources jar tasks and GenerateAvroJavaTasks (#167) * Satisfy checkstyle * Simplify sources jar handling and fix configuration avoidance * Fix compatibility with Gradle before 6.0 * version: 1.2.1 * version: 1.2.2-SNAPSHOT * Upgrade to Gradle 7.2 * Update CI to indicate that Java 17 has been released, even though it's not supported yet. * Upgrade CodeNarc to build cleanly on Java 17 * Add some scripts to aid troubleshooting * Update readme to use implementation rather than compile configuration * Add avsc-from-external-jar and avsc-from-subproject examples * Make some minor adjustments to GradleAvroProtocolTask due to investigation of #174 * Add design for potential "additional schema" configurations feature * Add block to example to show custom resource dir usage * Update avsc-from-subproject example to compile schema for schema project, exclude generated classes from cat jar * Fix cachability for cat jar in example * GenerateAvroProtocolTask: don't delegate to the system classloader, even implicitly * Add an example that generated a UUID field * Add test project for kotlin * Update for avro 1.11.0 * Drop support for Avro 1.9.0-1.10.2 Due to an incompatibility introduced in Avro 1.11.0 error: no suitable constructor found for SpecificRecordBuilderBase(Schema,SpecificData) * Update kotlin compatibility testing * Update Java compatibility testing * Update to build with Gradle 7.3; add Java 17 compatibility * CI: Attempt to fix kotlin compatibility testing * More kotlin compatibility testing fixes * CI: update to gradle-build-action v2 * version: 1.3.0 * version: 1.3.1-SNAPSHOT * CI: enable automatic staging repository releasing * Drop kotlin plugin integration * Add note about seeking new maintainer to readme * version: 1.4.0 * version: 1.4.1-SNAPSHOT * Add 'additionalVelocityTool' capability. Allows user to provide tools that will be available in Velocity templates at generation time. * Update changelog * Update versions of Gradle/Avro/Java * version: 1.5.0 * version: 1.5.1-SNAPSHOT * Support specifying classpath for additional velocity tool classes * Add test for classpath property in GenerateAvroJavaTask * Minor cleanup * Fix test: escape backslashes in a Windows path * Drop Java compatibility testing for outdated versions * Update for Gradle 7.6 and Java 19 * Fix up cross-version compatibility for the Gradle 7.6 adjustments * Update changelog * version: 1.6.0 * version: 1.6.1-SNAPSHOT * Update changelog * Add ability to use conversions and type factories residing outside of build classpath * Fix compatibility with Gradle < 7.1 * Add documentation for using conversions and type factories located outside of build classpath * Add deprecations for methods used to configure conversions and type factories with classes * Prep for 1.7.0 release * version: 1.7.1-SNAPSHOT * Fix vulnerabilities in transitive dependencies * version: 1.7.1 * version: 1.7.2-SNAPSHOT * Update github actions that ran in node 12 * Fix Kotlin DSL setup snippet * move everything to lang/java/gradle-plugin --------- Co-authored-by: David M. Carr <[email protected]> Co-authored-by: David M. Carr <[email protected]> Co-authored-by: Ben Speakmon <[email protected]> Co-authored-by: Markus Helbig <[email protected]> Co-authored-by: Denis Cabasson <[email protected]> Co-authored-by: mcwhitak <[email protected]> Co-authored-by: Michael Whitaker <[email protected]> Co-authored-by: Vladimir Kralik <[email protected]> Co-authored-by: Ola Hungerford <[email protected]> Co-authored-by: David M. Carr <[email protected]> Co-authored-by: Dave Cracauer <[email protected]> Co-authored-by: Paul Kofmann <[email protected]> Co-authored-by: Marcin Erdmann <[email protected]> Co-authored-by: Marcel Henrich <[email protected]> Co-authored-by: Antonio Martinović <[email protected]>
A ValidSchema with no records produced invalid JSON when converting to JSON in C++. This is now fixed.