@ Override public void preDestroy ( ) { if ( eventStreams . isEmpty ( ) ) { return ; } // EventStream#close signals stream loop that breaks // as a consequence, EventStreamServlet ends current request processing and call this#closeEventStream // this#closeEventStream removes event stream from this#eventStreams list resulting in concurrent change // to cope with this concurrent change uses a temporary array // toArray API is a little confusing for me regarding returned array // to be on safe side let toArray to determine array size // also I presume returned array is not altered by list updates for ( EventStream eventStream : eventStreams . toArray ( new EventStream [ 0 ] ) ) { log . debug ( "Force close stale event stream |%s|." , eventStream ) ; eventStream . close ( ) ; } }
Closes all event streams still opened when event stream manager is destroyed .