public List < Command > receive ( final Command command ) { Assert . requireNonNull ( command , "command" ) ; LOG . trace ( "Received command of type {}" , command . getClass ( ) . getSimpleName ( ) ) ; List < Command > response = new LinkedList ( ) ; // collecting parameter pattern if ( ! ( command instanceof InterruptLongPollCommand ) ) { // signal commands must not update thread-confined state for ( DolphinServerAction it : dolphinServerActions ) { it . setDolphinResponse ( response ) ; // todo: can be deleted as soon as all action refer to the SMS } serverModelStore . setCurrentResponse ( response ) ; } List < CommandHandler > actions = registry . getActionsFor ( command . getClass ( ) ) ; if ( actions . isEmpty ( ) ) { LOG . warn ( "There is no server action registered for received command type {}, known commands types are {}" , command . getClass ( ) . getSimpleName ( ) , registry . getActions ( ) . keySet ( ) ) ; return response ; } // copying the list of actions allows an Action to unregister itself // avoiding ConcurrentModificationException to be thrown by the loop List < CommandHandler > actionsCopy = new ArrayList < CommandHandler > ( ) ; actionsCopy . addAll ( actions ) ; try { for ( CommandHandler action : actionsCopy ) { action . handleCommand ( command , response ) ; } } catch ( Exception exception ) { throw exception ; } return response ; }
doesn t fail on missing commands