@ Override public void run ( ) { if ( ! state . compareAndSet ( State . CREATED , State . PENDING ) ) { throw new IllegalStateException ( "Can only run a promise in the CREATED state" ) ; } T result ; try { result = supplier . get ( ) ; state . set ( State . COMPLETED ) ; observer . next ( result ) ; observer . completed ( true ) ; } catch ( Exception e ) { state . set ( State . ERROR ) ; observer . error ( e ) ; observer . completed ( false ) ; } observer = null ; //NOPMD }
This method calls the supplier and on successful completion informs the fulfilled consumers of the return value . If the supplier throws an exception the rejected consumers are informed . In either case when the call to the supplier completes the settled consumers are informed with an Optional containing the supplied value on success .