Skip to content

Conversation

maheshsooryambylu
Copy link
Collaborator

Content Upload fix with Content Streaming:
Please refer the PR #121 for overall fix approach and details. The main difference here when compared to that PR is that there is no restTemplate here and hence removed all the dependency with that of springfaramework. Could match the performance if not exactly same as that with restTemplate. May be we need to test for performance with this fix and with that should be good to ship this.

@PujaDeshmukh17
Copy link
Contributor

NIT: withouspelling in the PR title.

sdm/pom.xml Outdated
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.4.2</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move the version to top of pom.

Choose a reason for hiding this comment

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

Done!

sdm/pom.xml Outdated
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.90</minimum>
<minimum>0.85</minimum>
Copy link
Contributor

Choose a reason for hiding this comment

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

why was this reduced?

return cachedToken;
}

public static Map<String, String> fillTokenExchangeBody(String token, SDMCredentials sdmEnv) {
Copy link
Contributor

Choose a reason for hiding this comment

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

SDMCredentials sdmEnv is passed but not used, can we remove it.

Choose a reason for hiding this comment

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

SDMCredentials sdmEnv is passed but not used, can we remove it.

Done


public static Map<String, String> fillTokenExchangeBody(String token, SDMCredentials sdmEnv) {
Map<String, String> parameters = new HashMap<>();
parameters.put("assertion", token);
Copy link
Contributor

Choose a reason for hiding this comment

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

We can add a null check for token and throw an exception if ever token is null.

Choose a reason for hiding this comment

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

This is the application access token and if null the app framework would have thrown the exception even before all these flows!

try {
httpClient = HttpClients.createDefault();
if (sdmCredentials.getClientId() == null) {
throw new IOException("No SDM binding found");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move the message to constants.

Choose a reason for hiding this comment

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

Done

HttpPost httpPost =
new HttpPost(
sdmCredentials.getBaseTokenUrl()
+ "/oauth/token?grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer");
Copy link
Contributor

Choose a reason for hiding this comment

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

"/oauth/token?grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer" can be moved to a constant.

Choose a reason for hiding this comment

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

Done

HttpResponse response = httpClient.execute(httpPost);
String responseBody = extractResponseBodyAsString(response);
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
logger.error("Error fetching token with JWT bearer : " + responseBody);
Copy link
Contributor

Choose a reason for hiding this comment

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

In case status is not 200 do we still need to continue the processing? Or can we throw an exception from here and exit?

Choose a reason for hiding this comment

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

Done

throw new OAuth2ServiceException(
"Unexpected error while fetching client protocol: " + e.getMessage());
} catch (IOException e) {
logger.error(
Copy link
Contributor

Choose a reason for hiding this comment

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

In case of IO exception do we not need to throw any exception? We are only logging it?

Choose a reason for hiding this comment

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

Done!

public class RetryUtils {

private RetryUtils() {
// Doesn't do anything
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this?

Choose a reason for hiding this comment

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

Yes, we need a default constructor for a class with the static methods.

@smaheshbhat
Copy link

smaheshbhat commented Mar 20, 2025

Thanks for the review comments @PujaDeshmukh17
On the junit coverage as I mentioned in the group chat i would request some one to take up the unit test coverage and with that task we can put back the coverage rule

PujaDeshmukh17
PujaDeshmukh17 previously approved these changes Mar 28, 2025
Copy link
Contributor

@PujaDeshmukh17 PujaDeshmukh17 left a comment

Choose a reason for hiding this comment

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

Looks good, Thanks

@maheshsooryambylu maheshsooryambylu changed the title Large file upload fix withou rest template Large file upload fix without rest template Mar 28, 2025
yashmeet29
yashmeet29 previously approved these changes Apr 1, 2025
Comment on lines 114 to 119
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a Critical Security Risk in this library version. Please check this.

@ashishjain14
Copy link
Collaborator

Hi @maheshsooryambylu : Can we close this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants