Buggy code:
final String name = this . name . getValue ( args ) ; final boolean keepContent = this . keepContent . isPresent ( args ) ; final boolean allRelevantServerGroups = this . allRelevantServerGroups . isPresent ( args ) ; final String serverGroupsStr = this . serverGroups . getValue ( args ) ; final String path = this . path . getValue ( args ) ; final File f ; if ( path != null ) { f = new File ( path ) ; if ( ! ( f . exists ( ) ) ) { throw new OperationFormatException ( ( ( "Path<seq2seq4repair_space>'" + ( f . getAbsolutePath ( ) ) ) + "'<seq2seq4repair_space>doesn't<seq2seq4repair_space>exist." ) ) ; } if ( ! ( isCliArchive ( f ) ) ) { throw new OperationFormatException ( ( ( "File<seq2seq4repair_space>'" + ( f . getAbsolutePath ( ) ) ) + "'<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>a<seq2seq4repair_space>valid<seq2seq4repair_space>CLI<seq2seq4repair_space>archive.<seq2seq4repair_space>CLI<seq2seq4repair_space>archives<seq2seq4repair_space>should<seq2seq4repair_space>have<seq2seq4repair_space>a<seq2seq4repair_space>'.cli'<seq2seq4repair_space>extension." ) ) ; } } else { f = null ; } if ( isCliArchive ( f ) ) { if ( name != null ) { throw new OperationFormatException ( ( ( this . name . getFullName ( ) ) + "<seq2seq4repair_space>can't<seq2seq4repair_space>be<seq2seq4repair_space>used<seq2seq4repair_space>in<seq2seq4repair_space>combination<seq2seq4repair_space>with<seq2seq4repair_space>a<seq2seq4repair_space>CLI<seq2seq4repair_space>archive." ) ) ; } if ( ( serverGroupsStr != null ) || allRelevantServerGroups ) { throw new OperationFormatException ( ( ( ( ( this . serverGroups . getFullName ( ) ) + "<seq2seq4repair_space>and<seq2seq4repair_space>" ) + ( this . allRelevantServerGroups . getFullName ( ) ) ) + "<seq2seq4repair_space>can't<seq2seq4repair_space>be<seq2seq4repair_space>used<seq2seq4repair_space>in<seq2seq4repair_space>combination<seq2seq4repair_space>with<seq2seq4repair_space>a<seq2seq4repair_space>CLI<seq2seq4repair_space>archive." ) ) ; } if ( keepContent ) { throw new OperationFormatException ( ( ( this . keepContent . getFullName ( ) ) + "<seq2seq4repair_space>can't<seq2seq4repair_space>be<seq2seq4repair_space>used<seq2seq4repair_space>in<seq2seq4repair_space>combination<seq2seq4repair_space>with<seq2seq4repair_space>a<seq2seq4repair_space>CLI<seq2seq4repair_space>archive." ) ) ; } MountHandle root ; try { root = extractArchive ( f ) ; } catch ( IOException e ) { throw new OperationFormatException ( ( ( "Unable<seq2seq4repair_space>to<seq2seq4repair_space>extract<seq2seq4repair_space>archive<seq2seq4repair_space>'" + ( f . getAbsolutePath ( ) ) ) + "'<seq2seq4repair_space>to<seq2seq4repair_space>temporary<seq2seq4repair_space>location" ) ) ; } final File currentDir = ctx . getCurrentDir ( ) ; ctx . setCurrentDir ( root . getMountSource ( ) ) ; String holdbackBatch = activateNewBatch ( ctx ) ; try { String script = this . script . getValue ( args ) ; if ( script == null ) { script = "undeploy.scr" ; } File scriptFile = new File ( ctx . getCurrentDir ( ) , script ) ; if ( ! ( scriptFile . exists ( ) ) ) { throw new CommandFormatException ( ( ( ( ( "ERROR:<seq2seq4repair_space>script<seq2seq4repair_space>'" + script ) + "'<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space>in<seq2seq4repair_space>archive<seq2seq4repair_space>'" ) + ( f . getAbsolutePath ( ) ) ) + "'." ) ) ; } BufferedReader reader = null ; try { reader = new BufferedReader ( new FileReader ( scriptFile ) ) ; String line = reader . readLine ( ) ; while ( ( ! ( ctx . isTerminated ( ) ) ) && ( line != null ) ) { ctx . handle ( line ) ; line = reader . readLine ( ) ; } } catch ( FileNotFoundException e ) { throw new CommandFormatException ( ( ( ( ( "ERROR:<seq2seq4repair_space>script<seq2seq4repair_space>'" + script ) + "'<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space>in<seq2seq4repair_space>archive<seq2seq4repair_space>'" ) + ( f . getAbsolutePath ( ) ) ) + "'." ) ) ; } catch ( IOException e ) { throw new CommandFormatException ( ( ( ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>read<seq2seq4repair_space>the<seq2seq4repair_space>next<seq2seq4repair_space>command<seq2seq4repair_space>from<seq2seq4repair_space>" + ( scriptFile . getName ( ) ) ) + ":<seq2seq4repair_space>" ) + ( e . getMessage ( ) ) ) , e ) ; } catch ( CommandLineException e ) { throw new CommandFormatException ( e . getMessage ( ) , e ) ; } finally { if ( reader != null ) { try { reader . close ( ) ; } catch ( IOException e ) { } } } return ctx . getBatchManager ( ) . getActiveBatch ( ) . toRequest ( ) ; } finally { ctx . setCurrentDir ( currentDir ) ; discardBatch ( ctx , holdbackBatch ) ; try { root . close ( ) ; } catch ( IOException ignore ) { } } } if ( name == null ) { throw new OperationFormatException ( "Deployment<seq2seq4repair_space>name<seq2seq4repair_space>is<seq2seq4repair_space>missing." ) ; } final ModelControllerClient client = ctx . getModelControllerClient ( ) ; DefaultOperationRequestBuilder builder ; final List < String > deploymentNames ; if ( ( name . indexOf ( '*' ) ) < 0 ) { deploymentNames = Collections . singletonList ( name ) ; } else { <START_BUG> deploymentNames = Util . getMatchingDeployments ( client , name ) ; <END_BUG> if ( deploymentNames . isEmpty ( ) ) { throw new CommandFormatException ( ( "No<seq2seq4repair_space>deployment<seq2seq4repair_space>matched<seq2seq4repair_space>wildcard<seq2seq4repair_space>expression<seq2seq4repair_space>" + name ) ) ; } } for ( String deploymentName : deploymentNames ) { final List < String > serverGroups ; if ( ctx . isDomainMode ( ) ) { if ( allRelevantServerGroups ) { if ( keepContent ) { serverGroups = Util . getAllEnabledServerGroups ( deploymentName , client ) ; } else { try { serverGroups = Util . getServerGroupsReferencingDeployment ( deploymentName , client ) ; } catch ( CommandLineException e ) { throw new CommandFormatException ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>retrieve<seq2seq4repair_space>all<seq2seq4repair_space>referencing<seq2seq4repair_space>server<seq2seq4repair_space>groups" , e ) ; } } } else { if ( serverGroupsStr == null ) { serverGroups = Collections . emptyList ( ) ; } else { serverGroups = Arrays . asList ( serverGroupsStr . split ( "," ) ) ; } } if ( serverGroups . isEmpty ( ) ) { if ( keepContent ) { throw new OperationFormatException ( "None<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>server<seq2seq4repair_space>groups<seq2seq4repair_space>is<seq2seq4repair_space>specified<seq2seq4repair_space>or<seq2seq4repair_space>references<seq2seq4repair_space>specified<seq2seq4repair_space>deployment." ) ; } } else { for ( String group : serverGroups ) { ModelNode groupStep = Util . configureDeploymentOperation ( UNDEPLOY , deploymentName , group ) ; steps . add ( groupStep ) ; groupStep = Util . configureDeploymentOperation ( REMOVE , deploymentName , group ) ; steps . add ( groupStep ) ; } } } else { if ( Util . isDeployedAndEnabledInStandalone ( deploymentName , client ) ) { builder = new DefaultOperationRequestBuilder ( ) ; builder . setOperationName ( UNDEPLOY ) ; builder . addNode ( DEPLOYMENT , deploymentName ) ; steps . add ( builder . buildRequest ( ) ) ; } } }

Fix:
deploymentNames = Util . getDeployments ( client , name ) ;