Skip to content

Conversation

@psainics
Copy link
Collaborator

@psainics psainics commented Dec 5, 2024

httpErrorManagement

@Amit-CloudSufi Amit-CloudSufi changed the title Http error management Added HTTP error detail provider and refactored HTTP-sink and source package to handle error provider and fix sonar issues Dec 5, 2024
inputSchema = Schema.parseJson(hConf.get(INPUT_SCHEMA_KEY));
return new HTTPRecordWriter(config, inputSchema);
} catch (IOException e) {
String errorMessage = "Unable to parse and write the record";
Copy link
Collaborator

Choose a reason for hiding this comment

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

error Message should be unable to parse the input schema.

Copy link
Collaborator

Choose a reason for hiding this comment

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

updated

} catch (IOException e) {
String errorMessage = "Unable to parse and write the record";
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
errorMessage, e.getMessage(), ErrorType.UNKNOWN, true, new IOException(errorMessage));
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can wrap this IOException in IllegalState as this is because somehow schema becomes corrupt in the conf.

Copy link
Collaborator

Choose a reason for hiding this comment

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

updated

if (config.getMethod().equals(REQUEST_METHOD_PUT) || config.getMethod().equals(REQUEST_METHOD_PATCH) ||
config.getMethod().equals(REQUEST_METHOD_DELETE)
&& !placeHolderList.isEmpty()) {
&& !placeHolderList.isEmpty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

revert the changes due to indentation as it makes things confusing for the reviewer. In actions on save, reformat the file only where you are making changes

Copy link
Collaborator

Choose a reason for hiding this comment

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

reverted

}

// Use try-with-resources to ensure response is closed
try (CloseableHttpResponse response = executeHttpRequest(httpClient, url)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

keep a single try with resources block for httpClient and respose

Copy link
Collaborator

Choose a reason for hiding this comment

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

updated

if (inputSchema == null) {
fields = Collections.emptyList();
} else {
assert inputSchema.getFields() != null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

are you catching the assertion error somewhere?
if not, you can go ahead with old format, CDF has some validations for schema which will check it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

handled using java 8, removed assert

collector.addFailure(errorMessage, "Please ensure that correct credentials are provided.");
}
}
} catch (IOException e) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need catch block for HttpHostConnectException which was there previously

Copy link
Collaborator

Choose a reason for hiding this comment

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

added back

throw new RuntimeException("Failed to read line from http page buffer", e);
String errorMessage = "Unable to read line from http page buffer";
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
errorMessage, e.getMessage(), ErrorType.UNKNOWN, true, new IOException(errorMessage));
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we creating a new exception when we have instance of IOException here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

updated

public static final TestConfiguration CONFIG =
new TestConfiguration(Constants.Explore.EXPLORE_ENABLED, false,
Constants.AppFabric.SPARK_COMPAT, Compat.SPARK_COMPAT);
new TestConfiguration(EXPLORE_ENABLED, false, Constants.AppFabric.SPARK_COMPAT, Compat.SPARK_COMPAT);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why this change is required? we dont use these classes for test anymore.

@psainics
Copy link
Collaborator Author

psainics commented Dec 5, 2024

The Bump PR is merged, please rebase again with develop, there are conflicts 😿

@Amit-CloudSufi Amit-CloudSufi removed their request for review December 6, 2024 08:50
@Amit-CloudSufi
Copy link
Collaborator

Not need anymore, raise a new PR - #16.
closing this one

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.

4 participants