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

2.x: Make CompositeExcpetion thread-safe like 1.x and also fix some issues #4619

Merged
merged 1 commit into from
Sep 28, 2016

Commits on Sep 28, 2016

  1. 2.x: Make CompositeExcpetion thread-safe like 1.x and also fix some i…

    …ssues.
    
    Right now CompositeExcpetion has several issues:
    
    - `CompositeException(Throwable... exceptions)` doesn't deduplicate exceptions and flatten CompositeExceptions like `CompositeException(Iterable<? extends Throwable> errors)`
    - If using `CompositeException(Iterable<? extends Throwable> errors)` to create CompositeException, `suppress` cannot be used.
    - `suppress` doesn't update `cause`.
    - `suppress` doesn't deduplicate exceptions and flatten CompositeExceptions.
    - `suppress` and `Throwable.addSuppressed` are pretty confusing for Java 7+ users. Without looking at the implementation, it's hard to figure out the differences.
    
    This PR made the following changes:
    
    - Remove `CompositeException.suppress` so that it's easy to make CompositeException thread-safe.
      - This may cause some performance lost in some path rarely happening, e.g., an excpetion is thrown from `onError`, but that's not a big deal.
      - Since `suppress` is removed, it doesn't make sense to create an empty CompositeException, so `isEmpty` is removed and defense codes are added.
    - Defense codes for bad exceptions.
    - Deduplicate excepctions and flatten CompositeExceptions for `CompositeException(Throwable... exceptions)`.
    zsxwing committed Sep 28, 2016
    Configuration menu
    Copy the full SHA
    f94dfad View commit details
    Browse the repository at this point in the history