Repository navigation
Allow users of the SDK to provide their own copy of the apache HTTP … - #1
Closed
campbellbartlett wants to merge 2 commits into
Closed
campbellbartlett wants to merge 2 commits into
campbellbartlett wants to merge 2 commits into
Conversation
Comment on lines
+33
to
+43
| public LegacyCloudinaryLoader() { | ||
| super(loadDefaultConfig(), getUploaderStrategy(loadDefaultConfig()), getApiStrategy(loadDefaultConfig())); | ||
| } | ||
|
|
||
| public LegacyCloudinaryLoader(Map<String, Object> configuration) { | ||
| super(new Configuration(configuration), getUploaderStrategy(new Configuration(configuration)), getApiStrategy(new Configuration(configuration))); | ||
| } | ||
|
|
||
| public LegacyCloudinaryLoader(String url) { | ||
| super(Configuration.from(url), getUploaderStrategy(Configuration.from(url)), getApiStrategy(Configuration.from(url))); | ||
| } |
Owner
Author
There was a problem hiding this comment.
The load_strategies configuration property introduces unnecessary complexity to these constructors. Due to Java 8's requirement that super() must be the first statement in a constructor, combined with the conditional nature of the legacy strategy loading, we're forced into a more complicated implementation than is ideal.
I think that this property only exists for testing purposes in CloudinaryTest.java. If it were up to me I would consider removing it entirely and restructuring those tests accordingly. This would lead to cleaner, more maintainable constructor logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses cloudinary#343 by making the SDK more flexible in how HTTP clients and strategies are configured.
Key Changes:
LegacyCloudinaryLoader.java(currently needed forcloudinary-tagliband tests, but could be phased out in future)The new architecture allows different HTTP library implementations (like okHttp or Jetty) to provide their own
CloudinaryClient.javaimplementations.Here's how it would work for a user of the
com.cloudinary.http5package:Custom HTTP client example:
Custom Strategy Example:
All existing initialization methods are still supported:
Next steps:
A similar implementation of
CloudinaryClientshould be created forcom.cloudinary.android.Breaking Change:
When upgrading, users will need to update their client instantiation from:
to:
This change affects all constructor overloads (with and without arguments).