Skip to content
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: Plugin lookup workaround for System.properties access restrictions #5820

Merged
merged 2 commits into from Jan 25, 2018

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Jan 25, 2018

The PR adds a try-catch around the System property lookup inside the RxJavaPlugins in case a security manager prevents reading arbitrary property entries.

This mainly affects the rxjava.plugin.[index].class lookup which were introduced due to the 31 character key limit on Android.

However, when running in a container such as Tomcat, a security manager may prevent reading these type of prefixed entries (where [index] can't be known upfront), crashing the initialization.

Update:

The System.getProperties() can also fail, therefore, retrieving the properties has been factored out into a separate method that returns an empty properties.

Fixes #5819.

@codecov
Copy link

codecov bot commented Jan 25, 2018

Codecov Report

Merging #5820 into 1.x will increase coverage by 0.17%.
The diff coverage is 95%.

Impacted file tree graph

@@             Coverage Diff              @@
##                1.x    #5820      +/-   ##
============================================
+ Coverage     84.07%   84.25%   +0.17%     
- Complexity     2881     2891      +10     
============================================
  Files           290      290              
  Lines         18258    18264       +6     
  Branches       2495     2495              
============================================
+ Hits          15351    15388      +37     
+ Misses         2013     1996      -17     
+ Partials        894      880      -14
Impacted Files Coverage Δ Complexity Δ
src/main/java/rx/plugins/RxJavaPlugins.java 74.74% <95%> (+1.62%) 29 <1> (+1) ⬆️
...ain/java/rx/internal/schedulers/SchedulerWhen.java 83.78% <0%> (-4.06%) 4% <0%> (ø)
src/main/java/rx/observers/SerializedObserver.java 97.82% <0%> (-2.18%) 19% <0%> (-1%)
.../rx/internal/schedulers/CachedThreadScheduler.java 89.32% <0%> (-1.95%) 6% <0%> (ø)
...c/main/java/rx/observables/BlockingObservable.java 85.21% <0%> (-1.41%) 37% <0%> (-1%)
...ternal/operators/OperatorOnBackpressureBuffer.java 93.75% <0%> (-1.25%) 8% <0%> (ø)
...n/java/rx/internal/operators/CachedObservable.java 81.67% <0%> (-1.05%) 6% <0%> (ø)
.../rx/internal/operators/OperatorWindowWithTime.java 41.79% <0%> (+0.37%) 3% <0%> (ø) ⬇️
...ain/java/rx/internal/operators/OperatorReplay.java 82.77% <0%> (+0.39%) 15% <0%> (ø) ⬇️
src/main/java/rx/subjects/ReplaySubject.java 87.91% <0%> (+0.43%) 30% <0%> (ø) ⬇️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 265fb48...a8c72c9. Read the comment docs.

Copy link
Contributor

@artem-zinnatullin artem-zinnatullin left a comment

Choose a reason for hiding this comment

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

LGTM but few comments

* therefore, the SecurityException is turned into an empty properties.
* @return the Properties to use for looking up settings
*/
/* test */ static Properties getSystemPropertiesSafe() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove "test"?

Copy link
Member Author

Choose a reason for hiding this comment

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

It indicates the method is package private for testing purposes instead of private.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's consistent with the other methods. ¯_(ツ)_/¯

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, haven't seen these in a while, my bad

// https://github.com/ReactiveX/RxJava/issues/5819
// We don't seem to have access to all properties.
// At least print the exception to the console.
ex.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe call RxJavaPlugins.onError() or however that api is called in 1.x?

I believe people won't like stacktrace popping up in their logs without ability to swallow it

Copy link
Member Author

Choose a reason for hiding this comment

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

Can't call that because this is part of the initialization process of RxJavaPlugins, the error handler would come from the same system properties and the default does nothing.

Copy link
Contributor

Choose a reason for hiding this comment

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

mhm, I see, ok

@akarnokd akarnokd merged commit ef32950 into ReactiveX:1.x Jan 25, 2018
@akarnokd akarnokd deleted the PluginsSecurityExceptionFix branch January 25, 2018 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants