Skip to content

CRT 0.4.13 API Update #1588

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

Closed
wants to merge 26 commits into from
Closed

Conversation

rccarper
Copy link
Contributor

@rccarper rccarper commented Jan 10, 2020

Description

This was done by rebasing master onto crt-api-update, then rebasing crt-api-update onto aws-crt-dev-preview, making some additional changes to account for API changes, and then creating this branch. I'm open to merging this into aws-crt-dev-preview first if that's preferable to merging everything into master.

As such, there are a lot of changes here not done by myself. Only the changes done in commit 2723640 are, in that sense, actually new. More detail about those changes:

  • This points the SDK to the latest build of the Java CRT available in Maven, ie, 0.4.19.
  • This required updating a handful of places where the API has changed.
  • I'm currently relying on the existing unit tests invoked by mvn clean install, and would be open to any other means of validating these changes if someone knows better.
  • Possible point for API discussion: the AwsCrtAsyncHttpClient now takes an EventLoopGroup and HostResolver via its builder. It would be possible to have the client create these objects itself, making a simpler experience for the user. However, because this does add the cost of an EventLoopGroup and HostResolver to each created AwsCrtAsyncHttpClient, and handling it for them potentially hides that cost, it seemed better to have the user explicitly specify their own. For example, a customer may use a pattern that creates a large number of clients, not realizing each client is spinning up an EventLoopGroup and HostResolver.

Testing

mvn clean install

[x ] I confirm that this pull request can be released under the Apache 2 license

private final int maxConnectionsPerEndpoint;


public AwsCrtAsyncHttpClient(DefaultBuilder builder, AttributeMap config) throws CrtRuntimeException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure we want to declare a checked exception here?
caveat: I know very little about standards/style with Java exceptions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally pulled that over as part of inlining the ClientBootstrap constructor that's since been removed. (It created the EventLoopGroup and HostResolver like I had also previously inlined.) Because they are now passed as arguments, and nothing is being added, I don't think anything is being added here that warrants in. (This is not to say that it had to be brought over in the first place.). So, I have taken it out. However, I would be open to adding it back in if there is a good argument for it!

Comment on lines 100 to 104
try (EventLoopGroup elg = new EventLoopGroup(builder.eventLoopSize);
HostResolver hr = new HostResolver(elg)) {

bootstrap = own(new ClientBootstrap(elg, hr));
socketOptions = own(new SocketOptions());
Copy link
Contributor

Choose a reason for hiding this comment

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

why are the elg and hr "try-with-resources", while the rest of the CrtResources are "owned"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't have to worry about this now that we aren't creating the EventLoopGroup or HostResolver inside of this constructor. Previously, it was because I was brining over a chunk of code from a now removed ClientBootStrap constructor that created these objects internally. Because of that, and because they were being passed to the ClientBootstrap, it didn't seem necessary to track them with "own". (But I might have been wrong!)

@rccarper rccarper force-pushed the crt-0.4.13-api-update branch 4 times, most recently from 67bf7c4 to f063809 Compare January 20, 2020 19:04
Copy link
Contributor

@graebm graebm left a comment

Choose a reason for hiding this comment

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

caveat: only looked at the 2 parts of code Ryan said he'd most recently touched

Factoring out EventLoopGroup/HostResolver from client constructor, fixing bug reported by Sonar
@rccarper rccarper force-pushed the crt-0.4.13-api-update branch from f063809 to 285e671 Compare January 22, 2020 18:58
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 17 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@rccarper rccarper closed this Jan 22, 2020
@rccarper rccarper deleted the crt-0.4.13-api-update branch January 22, 2020 19:19
@codecov-io
Copy link

Codecov Report

Merging #1588 into master will increase coverage by 0.11%.
The diff coverage is 85%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1588      +/-   ##
============================================
+ Coverage     75.64%   75.75%   +0.11%     
- Complexity      638      721      +83     
============================================
  Files           898      903       +5     
  Lines         28141    28481     +340     
  Branches       2221     2254      +33     
============================================
+ Hits          21288    21577     +289     
- Misses         5836     5868      +32     
- Partials       1017     1036      +19
Flag Coverage Δ Complexity Δ
#unittests 75.75% <85%> (+0.11%) 721 <83> (+83) ⬆️
Impacted Files Coverage Δ Complexity Δ
...p/crt/internal/AwsCrtResponseBodySubscription.java 100% <100%> (ø) 5 <5> (?)
...http/crt/internal/AwsCrtRequestBodySubscriber.java 78% <78%> (ø) 12 <12> (?)
.../amazon/awssdk/http/crt/AwsCrtAsyncHttpClient.java 80.15% <80.15%> (ø) 22 <22> (?)
...http/crt/internal/AwsCrtResponseBodyPublisher.java 88.46% <88.46%> (ø) 31 <31> (?)
...ttp/crt/internal/AwsCrtAsyncHttpStreamAdapter.java 93.61% <93.61%> (ø) 13 <13> (?)
...nio/netty/internal/OldConnectionReaperHandler.java 81.81% <0%> (-9.1%) 0% <0%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9a2b7e9...285e671. Read the comment docs.

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