Skip to content

Replace reflection with X-HTTP-Method-Override - #1083

Merged
bitwiseman merged 2 commits into
hub4j:masterfrom
bitwiseman:issue/754
Apr 9, 2021
Merged

bitwiseman merged 2 commits into
hub4j:masterfrom
bitwiseman:issue/754

Conversation

@bitwiseman

@bitwiseman bitwiseman commented Apr 8, 2021 •

Copy link
Copy Markdown
Member

Description

To workaround the limitation where HttpURLConnection does not support PATCH method, the library was using reflection to change the method string. This involved quite a bit of hackery.

This change replaces all that with the X-HTTP-Method-Override.

Tested with a few API calls and but mostly manually updated test resources.

Fixes #754

@aalmiray

Before submitting a PR:

We love getting PRs, but we hate asking people for the same basic changes every time.

  • Push your changes to a branch other than master. Create your PR from that branch.
  • Add JavaDocs and other comments
  • Write tests that run and pass in CI. See CONTRIBUTING.md for details on how to capture snapshot data.
  • Run mvn -D enable-ci clean install site locally. If this command doesn't succeed, your change will not pass CI.

When creating a PR:

  • Fill in the "Description" above.
  • Enable "Allow edits from maintainers".

@bitwiseman

Copy link
Copy Markdown
Member Author

@gsmet Heads up, if you are using the built-in HttpConnector in your systems as opposed to okttp3.OkHttpConnector this may effect your tests. The product change should be transparent to end-users but test systems that Wiremock and expect specific requests will detect the difference.

@gsmet

gsmet commented Apr 9, 2021

Copy link
Copy Markdown
Contributor

Thanks for the heads up. I don't use the HttpConnector in production as this dark magic reflection thingy didn't work in native mode with GraalVM so that's a good thing it's gone! But sure my tests will be affected.

@timja timja left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could look at a multi release jar and using the built in modern http client at some point as well

@bitwiseman
bitwiseman merged commit 837526c into hub4j:master Apr 9, 2021
@bitwiseman
bitwiseman deleted the issue/754 branch April 9, 2021 16:49
@gsmet

gsmet commented Apr 21, 2021

Copy link
Copy Markdown
Contributor

@bitwiseman any chance you could release a new version? I start seeing complaints about this from people trying JDK 16.

bitwiseman added a commit to bitwiseman/github-api that referenced this pull request May 27, 2021
This reverts commit 837526c, reversing
changes made to 8b3f50d.
bitwiseman added a commit that referenced this pull request Jun 1, 2021
Revert #1083 reflective access for PATCH method
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.

Illegal Reflective Access Operation to field java.net.HttpURLConnection.method

3 participants