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

[Kernel] Add Default client implementations #1843

Closed
wants to merge 4 commits into from

Conversation

vkorukanti
Copy link
Collaborator

@vkorukanti vkorukanti commented Jun 18, 2023

Context

This PR is part of #1783.

Description

Following client implementations for the default module are added:

 * `JsonHandler`
 * `ExpressionHandler`
 * `FileSystemClient`

and the supporting classes.

How was this patch tested?

UTs

@vkorukanti vkorukanti force-pushed the pr3-jsonFSHandlers branch 2 times, most recently from de97c4e to 0667019 Compare June 21, 2023 20:33

private static Object decodeElement(JsonNode jsonValue, DataType dataType)
{
if (jsonValue.isNull()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we check for nullable field here too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

its not needed here. We do a check before coming here. There are couple of places the check needs to be done when parsing the array element or parsing the map value element. Added a checks to throw exception of the null type is not expected.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought this is different from rootNode.get(name) == null as it's a json literal null value?

@vkorukanti vkorukanti force-pushed the pr3-jsonFSHandlers branch 3 times, most recently from 49885c3 to 497a28b Compare June 22, 2023 16:51
Following client implementations for the default module are added:

 * `JsonHandler`
 * `ExpressionHandler`
 * `FileSystemClient`

and the supporting classes.
currentFileReader = new BufferedReader(
new InputStreamReader(stream, StandardCharsets.UTF_8));
} catch (Exception e){
Utils.closeCloseables(stream); // close it avoid leaking resources
Copy link
Collaborator

Choose a reason for hiding this comment

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

propagate the exception?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Utils.closeCloseables already throws an unchecked exception.

Related to this: The iterator interface needs to have some kind of checked exception throwing, but we can't override the interface. Added this to the list. We may need to revisit this. Unchecked exceptions are not always good.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't the original exception e suppressed here though?

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 on the iterator interface

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No its not.

            if (exception == null) {
                    exception = new RuntimeException(ex);
                }
                else {
                    exception.addSuppressed(ex);
                }

We keep the first exception (wrap it in RuntimeException because of the no-checked exceptions). Subsequent exceptions are added to suprrssed. they are still available, but won't be printed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean whatever exception caused us to reach the catch block here at all. Not sure if I'm missing something obvious

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we fail to open the file or something and stream = null we just continue on here no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, got it. Added a silent close version of the API. I think this exception e is the main one we want to preserve.

Copy link
Collaborator

@allisonport-db allisonport-db left a comment

Choose a reason for hiding this comment

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

LGTM

@vkorukanti vkorukanti deleted the pr3-jsonFSHandlers branch September 14, 2023 11:55
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.

3 participants