class SafeSubscriber implements Subscriber<T>, Subscription {

    @Override
    public void onError(Throwable t) {
        Objects.requireNonNull(t);
        if (done) {
            return;
        }
        done = true;

        if (upstream.get() == null) {
            Throwable npe = new NullPointerException("Subscription not set!");

            try {
                downstream.onSubscribe(Subscriptions.empty());
            } catch (Throwable e) {
                // can't call onError because the actual's state may be corrupt at this point
                Infrastructure.handleDroppedException(new CompositeException(t, e));
                return;
            }
            try {
                downstream.onError(new CompositeException(t, npe));
            } catch (Throwable e) {
                // nothing we can do.
                Infrastructure.handleDroppedException(new CompositeException(t, npe, e));
            }
            return;
        }

        try {
            downstream.onError(t);
        } catch (Throwable ex) {
            // nothing we can do.
            Infrastructure.handleDroppedException(new CompositeException(t, ex));
        }
    }

    public  SafeSubscriber(Subscriber<? super T> downstream);

}