Buggy code:
private AddModuleArgument ( String fullName , CommandLineCompleter completer ) { } @ Override public boolean canAppearNext ( CommandContext ctx ) throws CommandFormatException { } } private static final String JBOSS_HOME = "JBOSS_HOME" ; private static final String PATH_SEPARATOR = File . pathSeparator ; private static final String MODULE_SEPARATOR = "," ; private static final String ACTION_ADD = "add" ; private static final String ACTION_REMOVE = "remove" ; private final ArgumentWithValue action = new ArgumentWithValue ( this , new DefaultCompleter ( new CandidatesProvider ( ) { @ Override public Collection < String > getAllCandidates ( CommandContext ctx ) { } } ) , 0 , "--action" ) ; private final ArgumentWithValue name ; private final ArgumentWithValue mainClass ; private final ArgumentWithValue resources ; private final ArgumentWithValue dependencies ; private final ArgumentWithValue props ; private final ArgumentWithValue moduleArg ; private final ArgumentWithValue slot ; private File modulesDir ; public ASModuleHandler ( CommandContext ctx ) { } @ Override public boolean isAvailable ( CommandContext ctx ) { } @ Override protected void doHandle ( CommandContext ctx ) throws CommandLineException { } protected void addModule ( final ParsedCommandLine parsedCmd ) throws CommandLineException { final String moduleName = name . getValue ( parsedCmd , true ) ; final String resourcePaths = resources . getValue ( parsedCmd , true ) ; final String [ ] resourceArr = resourcePaths . split ( ASModuleHandler . PATH_SEPARATOR ) ; File [ ] resourceFiles = new File [ resourceArr . length ] ; for ( int i = 0 ; i < ( resourceArr . length ) ; ++ i ) { final File f = new File ( resourceArr [ i ] ) ; if ( ! ( f . exists ( ) ) ) { throw new CommandLineException ( ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>locate<seq2seq4repair_space>" + ( f . getAbsolutePath ( ) ) ) ) ; } resourceFiles [ i ] = f ; } final File moduleDir = getModulePath ( getModulesDir ( ) , moduleName , slot . getValue ( parsedCmd ) ) ; if ( moduleDir . exists ( ) ) { throw new CommandLineException ( ( ( ( "Module<seq2seq4repair_space>" + moduleName ) + "<seq2seq4repair_space>already<seq2seq4repair_space>exists<seq2seq4repair_space>at<seq2seq4repair_space>" ) + ( moduleDir . getAbsolutePath ( ) ) ) ) ; } if ( ! ( moduleDir . mkdirs ( ) ) ) { throw new CommandLineException ( ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>create<seq2seq4repair_space>directory<seq2seq4repair_space>" + ( moduleDir . getAbsolutePath ( ) ) ) ) ; } final ModuleConfigImpl config ; final String moduleXml = moduleArg . getValue ( parsedCmd ) ; if ( moduleXml != null ) { config = null ; final File source = new File ( moduleXml ) ; if ( ! ( source . exists ( ) ) ) { throw new CommandLineException ( ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>locate<seq2seq4repair_space>the<seq2seq4repair_space>file<seq2seq4repair_space>on<seq2seq4repair_space>the<seq2seq4repair_space>filesystem:<seq2seq4repair_space>" + ( source . getAbsolutePath ( ) ) ) ) ; } ASModuleHandler . copy ( source , new File ( moduleDir , "module.xml" ) ) ; } else { config = new ModuleConfigImpl ( moduleName ) ; } for ( File f : resourceFiles ) { ASModuleHandler . copy ( f , new File ( moduleDir , f . getName ( ) ) ) ; if ( config != null ) { config . addResource ( new ResourceRoot ( f . getName ( ) ) ) ; } } if ( config != null ) { final String dependenciesStr = dependencies . getValue ( parsedCmd ) ; if ( dependenciesStr != null ) { final String [ ] depsArr = dependenciesStr . split ( ",+" ) ; for ( String dep : depsArr ) { config . addDependency ( new ModuleDependency ( dep ) ) ; } } final String propsStr = props . getValue ( parsedCmd ) ; if ( propsStr != null ) { final String [ ] pairs = propsStr . split ( "," ) ; for ( String pair : pairs ) { int equals = pair . indexOf ( '=' ) ; if ( equals == ( - 1 ) ) { throw new CommandFormatException ( ( ( ( ( "Property<seq2seq4repair_space>'" + pair ) + "'<seq2seq4repair_space>in<seq2seq4repair_space>'" ) + propsStr ) + "'<seq2seq4repair_space>is<seq2seq4repair_space>missing<seq2seq4repair_space>the<seq2seq4repair_space>equals<seq2seq4repair_space>sign." ) ) ; } final String propName = pair . substring ( 0 , equals ) ; if ( propName . isEmpty ( ) ) { throw new CommandFormatException ( ( ( ( ( "Property<seq2seq4repair_space>name<seq2seq4repair_space>is<seq2seq4repair_space>missing<seq2seq4repair_space>for<seq2seq4repair_space>'" + pair ) + "'<seq2seq4repair_space>in<seq2seq4repair_space>'" ) + propsStr ) + "'" ) ) ; } config . setProperty ( propName , pair . substring ( ( equals + 1 ) ) ) ; } } final String mainCls = mainClass . getValue ( parsedCmd ) ; if ( mainCls != null ) { config . setMainClass ( mainCls ) ; } FileWriter moduleWriter = null ; final File moduleFile = new File ( moduleDir , "module.xml" ) ; try { moduleWriter = new FileWriter ( moduleFile ) ; <START_BUG> XMLExtendedStreamWriter xmlWriter = ASModuleHandler . create ( XMLOutputFactory . newFactory ( ) . createXMLStreamWriter ( moduleWriter ) ) ; <END_BUG> config . writeContent ( xmlWriter , null ) ; xmlWriter . flush ( ) ; } catch ( IOException e ) { throw new CommandLineException ( ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>create<seq2seq4repair_space>file<seq2seq4repair_space>" + ( moduleFile . getAbsolutePath ( ) ) ) , e ) ; } catch ( XMLStreamException e ) { throw new CommandLineException ( ( "Failed<seq2seq4repair_space>to<seq2seq4repair_space>write<seq2seq4repair_space>to<seq2seq4repair_space>" + ( moduleFile . getAbsolutePath ( ) ) ) , e ) ; } finally { if ( moduleWriter != null ) { try { moduleWriter . close ( ) ; } catch ( IOException e ) { } } } } } private void removeModule ( ParsedCommandLine parsedCmd ) throws CommandLineException { } protected File getModulePath ( File modulesDir , final String moduleName , String slot ) throws CommandLineException { } protected File getModulesDir ( ) throws CommandLineException { } public static XMLExtendedStreamWriter create ( XMLStreamWriter writer ) throws CommandLineException { } public static void copy ( final File source , final File target ) throws CommandLineException { } }

Fix:
XMLExtendedStreamWriter xmlWriter = ASModuleHandler . create ( XMLOutputFactory . newInstance ( ) . createXMLStreamWriter ( moduleWriter ) ) ;