Skip to content

NPE in CompositeException when nested throws on initCause #3599

Closed
@emilianogc

Description

@emilianogc

The following example throws a NPE

public class Test {
    public static class CustomException extends Throwable {
        public synchronized Throwable initCause(Throwable cause) {
            throw new UnsupportedOperationException();
        }
    }
    public static void main(String ... args) {
        new CompositeException(Arrays.asList(
                new CustomException(),
                new UnsupportedOperationException(),
                new IllegalStateException())).getCause();
    }
}

The stacktrace is the following:

Exception in thread "main" java.lang.NullPointerException
    at rx.exceptions.CompositeException.getCause(CompositeException.java:126)
    at Test.main(Test.java:18)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions