Skip to content

Removing the hard dependency on Apache HTTP Client - #259

Merged
hiranya911 merged 4 commits into
hkj-http-retryfrom
hkj-parse-date
Mar 13, 2019
Merged

Removing the hard dependency on Apache HTTP Client#259
hiranya911 merged 4 commits into
hkj-http-retryfrom
hkj-parse-date

Conversation

@hiranya911

Copy link
Copy Markdown
Contributor

In #255 we used an Apache HTTP client API (DateUtils) to parse HTTP date headers. We have this library in our classpath at the moment as a transitive dependency of Google API client. But the Google API client is undergoing a refactor, and this dependency will be removed in a future release. In preparation for this, I'm creating our own DateUtils class by copying the related bit of code from the Apache HTTP client.

The original implementation in Apache HTTP client uses thread locals to cache the SimpleDateFormat instances, and use them in a thread safe manner. I used explicit locking instead, in order to avoid potential memory leaks that may arise from unreleased thread locals (other suggestions welcome).

@schmidt-sebastian schmidt-sebastian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My only comment is that you should probably add a NOTICE file similar to http://svn.apache.org/repos/asf/httpcomponents/httpclient/tags/4.3/NOTICE.txt, since that seems to be one of the requirements of the Apache License. Otherwise this looks good, including the simplification thanks to the synchronized locking.

@hiranya911

Copy link
Copy Markdown
Contributor Author

Added NOTICE.txt file, and also removed the Copyright Google Inc. statement from the DateUtils class.

@hiranya911
hiranya911 merged commit 0c63ed6 into hkj-http-retry Mar 13, 2019
@hiranya911
hiranya911 deleted the hkj-parse-date branch March 13, 2019 18:02
@matejsp

matejsp commented Mar 13, 2019

Copy link
Copy Markdown
Contributor

How about migrating to DateTimeFormatter? However it is only supported in Java 8 and forward.A lot of extra code for obsolete and EOL Java version.

@hiranya911

Copy link
Copy Markdown
Contributor Author

We cannot use Java 8 at the moment. Current GCP policy requires us to be Java 7 compatible.

hiranya911 added a commit that referenced this pull request Mar 14, 2019
* Basic framework for HTTP retries

* Implementing support for retry-after header

* Cleaned up the retry-after processing logic

* Moved the status code checking logic

* Updated tests

* Updated class names and tests

* Refactored retry impl and tests

* Simplified the retry handler

* More tests and docs

* Further cleaned up the impl and tests

* Decoupled retry initializer from credentials

* More code cleanup

* Cleaning up tests

* Not calling any retry code when RetryConfig = null

* Added an option to enable/disable retries on IO errors. Added some comments

* New test case

* Updated some comments; Cleaned up tests

* Fixed a typo in a comment

* Removing the hard dependency on Apache HTTP Client (#259)

* Copied DateUtils source from Apache HC

* Updated reference link

* Used locks instead of thread locals; Added tests

* Added a NOTICE file for third-party code
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.

3 participants