Skip to content

Replace Guava dep with local RateLimiter implementation copy-paste#351

Merged
domesticmouse merged 1 commit intogooglemaps:masterfrom
apjanke:local-rate-limiter-impl
Oct 2, 2017
Merged

Replace Guava dep with local RateLimiter implementation copy-paste#351
domesticmouse merged 1 commit intogooglemaps:masterfrom
apjanke:local-rate-limiter-impl

Conversation

@apjanke
Copy link
Copy Markdown
Contributor

@apjanke apjanke commented Sep 29, 2017

Copies the RateLimiter implementation from Google Guava 23.0 to local classes and drops the Guava dependency. This removes the need for the Guava dependency, which some users feel is heavyweight, and may cause Java 7 compatibility issues. Addresses #285, especially #285 (comment).

This PR replaces the Guava dependency with a local copy of a minimal set of Guava classes/methods needed to implement RateLimiter, all under the new com.google.maps.internal.ratelimiter package. Code was copied from Guava 23.0 and hand-modified as necessary to get it running under Java 7 and without Guava-supplied annotations.

Doing a mechanical repackaging of RateLimiter and its dependencies would have been quite large (187 classes in the transitive dependency), so I started with RateLimiter and SmoothRateLimiter and pared their dependencies down by hand on a per-method basis, sticking all the dependencies in the com.google.maps.internal.ratelimiter package instead of breaking them out in separate packages like they are in the original Guava library.

Only four full classes (RateLimiter, SmoothRateLimiter, Stopwatch and Ticker) and a handful of methods from LongMath, Platform, and Preconditionshad to be pulled over. This seems like a reasonable amount of code to be adding to thegoogle-maps-services-java` codebase for manual maintenance. And there weren't a whole lot of edits besides removing annotations, so doing diff inspections against future releases of Guava should be manageable. I think this might be an acceptable maintenance burden in exchange for removing the Guava dependency.

I wasn't sure of exactly how to handle the copyright notices in the new files adapted from the Guava library. Since this is a derived work, and the bulk of the code is from the original library, I think the thing to do is to retain the original copyright notice, and to add a new 2017 copyright notice to reflect the modifications in the derived work. I've done so with the files here; let me know if it should be different.

All tests pass for me locally, running against Oracle JDK 1.7.0_79 on macOS.

…ndency

This replaces the Guava dependency with a local copy of a minimal set of
Guava classes/methods needed to implement RateLimiter, all under the new
com.google.maps.internal.ratelimiter package. Code was copied from Guava
23.0 and hand-modified as necessary to get it running under Java 7 and
without Guava-supplied annotations.
@apjanke apjanke mentioned this pull request Sep 29, 2017
@domesticmouse domesticmouse merged commit 7d7f0b9 into googlemaps:master Oct 2, 2017
@apjanke apjanke deleted the local-rate-limiter-impl branch November 13, 2017 01:36
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.

2 participants