Skip to content
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

consistent format for dataverseContacts JSON #5724 #5737

Merged
merged 3 commits into from
Apr 10, 2019

Conversation

pdurbin
Copy link
Member

@pdurbin pdurbin commented Apr 9, 2019

Connects to #5724.

@coveralls
Copy link

coveralls commented Apr 9, 2019

Coverage Status

Coverage increased (+0.04%) to 18.026% when pulling 50c5c2d on 5724-dataverse-contacts into a377d33 on develop.

@djbrooke
Copy link
Contributor

djbrooke commented Apr 9, 2019

Closing this test-only PR as the tests are included in #5739.

@pdurbin
Copy link
Member Author

pdurbin commented Apr 9, 2019

Reopening as this is the "as usual" one we want (not a weird hotfix to master etc.)

@pdurbin pdurbin reopened this Apr 9, 2019
@pdurbin pdurbin changed the title assert dataverseContacts, etc from JSON printer #5724 consistent format for dataverseContacts JSON #5724 Apr 10, 2019
Copy link
Contributor

@matthew-a-dunlap matthew-a-dunlap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! The lambda bug was super weird for sure!

@pdurbin
Copy link
Member Author

pdurbin commented Apr 10, 2019

Maybe @michbarsinai knows how to make it work but it was way easier to just take it out.

@kcondon kcondon merged commit f51e4cf into develop Apr 10, 2019
@kcondon kcondon deleted the 5724-dataverse-contacts branch April 10, 2019 21:00
@michbarsinai
Copy link
Member

@matthew-a-dunlap what lambda bug?

@pdurbin
Copy link
Member Author

pdurbin commented Apr 11, 2019

@michbarsinai please see #5724 (comment) for my take. In 50c5c2d I modified the public static JsonArrayBuilder json(List<DataverseContact> dataverseContacts) method, taking out

    return dataverseContacts.stream()
            .map(dc -> jsonObjectBuilder()
            .add("displayOrder", dc.getDisplayOrder())
            .add("contactEmail", dc.getContactEmail())
            ).collect(toJsonArray());

... and replacing it with this non-lamda function:

    JsonArrayBuilder jsonArrayOfContacts = Json.createArrayBuilder();
    for (DataverseContact dataverseContact : dataverseContacts) {
        NullSafeJsonBuilder contactJsonObject = NullSafeJsonBuilder.jsonObjectBuilder();
        contactJsonObject.add("displayOrder", dataverseContact.getDisplayOrder());
        contactJsonObject.add("contactEmail", dataverseContact.getContactEmail());
        jsonArrayOfContacts.add(contactJsonObject);
    }
    return jsonArrayOfContacts;

It's the weirdest thing. If you look at 50c0de8 (and earlier commit) you can see that the lambda version is emitting JSON for dataverse contacts from a unit test. But the later commit to remove the lambda was the quickest way to get the deployed app to emit JSON for dataverse contacts. I hope this makes sense. Again, in production the lambda would only ever emit an empty JSON array for dataset contacts. Weird.

@michbarsinai
Copy link
Member

michbarsinai commented Apr 11, 2019 via email

@pdurbin
Copy link
Member Author

pdurbin commented Apr 11, 2019

I have no idea but if we figure it out let's put it in a JavaOne^h^h^h CodeOne talk next year. 😄

@pdurbin pdurbin added this to the 4.13 milestone Apr 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants