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

Use MethodHandles to access AWS Request metadata #2655

Merged
merged 2 commits into from
May 5, 2021

Conversation

mcculls
Copy link
Contributor

@mcculls mcculls commented Apr 23, 2021

Reduces the need to maintain a side-table of metadata by using method handles to access named (public) getters.

@mcculls mcculls added inst: aws sdk AWS SDK instrumentation inst: others All other instrumentations labels Apr 23, 2021
@mcculls mcculls force-pushed the mcculls/awsRequestAccessWithMethodHandles branch from c028c8a to eff6ee0 Compare April 23, 2021 11:57
@mcculls mcculls force-pushed the mcculls/awsRequestAccessWithMethodHandles branch from eff6ee0 to f42ef66 Compare May 4, 2021 10:00
@mcculls mcculls marked this pull request as ready for review May 4, 2021 11:13
@mcculls mcculls requested a review from a team as a code owner May 4, 2021 11:13
Copy link
Contributor

@tylerbenson tylerbenson left a comment

Choose a reason for hiding this comment

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

Much better solution.

@mcculls mcculls force-pushed the mcculls/awsRequestAccessWithMethodHandles branch from f42ef66 to ea041d5 Compare May 4, 2021 22:05
Comment on lines 8 to 14
private static final ClassValue<RequestAccess> REQUEST_ACCESS =
new ClassValue<RequestAccess>() {
@Override
protected RequestAccess computeValue(final Class<?> requestType) {
return new RequestAccess(requestType);
}
};
Copy link
Member

Choose a reason for hiding this comment

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

I consolidated these in to GenericClassValue last week, so that you could write

  private static final ClassValue<RequestAccess> REQUEST_ACCESS =
      GenericClassValue.of(new Function<Class<?>, RequestAccess>() {
        @Override
        public RequestAccess apply(final Class<?> requestType) {
          return new RequestAccess(requestType);
        }
      });

and optionally factor out a function to construct an instance from a class parameter and drop the helper class, or

  private static final ClassValue<RequestAccess> REQUEST_ACCESS = GenericClassValue.of(RequestAccess::new);

and drop the helper class when we drop JDK7.

@mcculls mcculls merged commit 0126687 into master May 5, 2021
@mcculls mcculls deleted the mcculls/awsRequestAccessWithMethodHandles branch May 5, 2021 10:34
@github-actions github-actions bot added this to the 0.80.0 milestone May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inst: aws sdk AWS SDK instrumentation inst: others All other instrumentations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants