-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
1.x: add shorter RxJavaPlugin class lookup approach. #3513
Conversation
👍 |
@@ -141,7 +156,7 @@ public void registerObservableExecutionHook(RxJavaObservableExecutionHook impl) | |||
} | |||
} | |||
|
|||
private static Object getPluginImplementationViaProperty(Class<?> pluginClass) { | |||
/* test */ static Object getPluginImplementationViaProperty(Class<?> pluginClass, Properties props) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change test
to VisibleForTesting
? It's pretty common pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find this VisibleForTesting
in RxJava.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VisibleForTesting
is in Guava
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant not annotation but comment.
On Wed, Nov 11, 2015, 21:32 Shixiong Zhu [email protected] wrote:
In src/main/java/rx/plugins/RxJavaPlugins.java
#3513 (comment):@@ -141,7 +156,7 @@ public void registerObservableExecutionHook(RxJavaObservableExecutionHook impl)
}
}
- private static Object getPluginImplementationViaProperty(Class<?> pluginClass) {
- /* test */ static Object getPluginImplementationViaProperty(Class<?> pluginClass, Properties props) {
VisibleForTesting is in Guava
—
Reply to this email directly or view it on GitHub
https://github.com/ReactiveX/RxJava/pull/3513/files#r44567271.
@artem_zin
69b32a8
to
caab1cf
Compare
Updated: made strings local constants and using |
An alternative pattern could be this:
|
I agree that if the plugin cannot be found we should crash the app. |
caab1cf
to
c7e2ecf
Compare
Updated the code to crash if the plugin implementation is missing. |
Thanks! |
1.x: add shorter RxJavaPlugin class lookup approach.
This adds a new pattern and lookup method that let's the developer specify the custom plugins with shorter system property keys. Android is quite restrictive and allows only 31 characters.
The new pattern splits the target simple class name and its implementation into two separate system properties:
The index tag (
1
) can be any string of your chosing:but make sure they are paired, otherwise nothing will happen.
If there are multiple
class
entries with the sameSimpleClassName
one of them will be chosen (depending on the walk order injava.util.Properties
).Related issue #2835.