Buggy code:
public final class VectorDumper { private static final Logger log = LoggerFactory . getLogger ( VectorDumper . class ) ; private VectorDumper ( ) { } public static void main ( String [ ] args ) throws Exception { DefaultOptionBuilder obuilder = new DefaultOptionBuilder ( ) ; ArgumentBuilder abuilder = new ArgumentBuilder ( ) ; GroupBuilder gbuilder = new GroupBuilder ( ) ; Option seqOpt = obuilder . withLongName ( "seqFile" ) . withRequired ( false ) . withArgument ( abuilder . withName ( "seqFile" ) . withMinimum ( 1 ) . withMaximum ( 1 ) . create ( ) ) . withDescription ( "The<seq2seq4repair_space>Sequence<seq2seq4repair_space>File<seq2seq4repair_space>containing<seq2seq4repair_space>the<seq2seq4repair_space>Vectors" ) . withShortName ( "s" ) . create ( ) ; Option vectorAsKeyOpt = obuilder . withLongName ( "useKey" ) . withRequired ( false ) . withDescription ( "If<seq2seq4repair_space>the<seq2seq4repair_space>Key<seq2seq4repair_space>is<seq2seq4repair_space>a<seq2seq4repair_space>vector,<seq2seq4repair_space>then<seq2seq4repair_space>dump<seq2seq4repair_space>that<seq2seq4repair_space>instead" ) . withShortName ( "u" ) . create ( ) ; Option printKeyOpt = obuilder . withLongName ( "printKey" ) . withRequired ( false ) . withDescription ( "Print<seq2seq4repair_space>out<seq2seq4repair_space>the<seq2seq4repair_space>key<seq2seq4repair_space>as<seq2seq4repair_space>well,<seq2seq4repair_space>delimited<seq2seq4repair_space>by<seq2seq4repair_space>a<seq2seq4repair_space>tab<seq2seq4repair_space>(or<seq2seq4repair_space>the<seq2seq4repair_space>value<seq2seq4repair_space>if<seq2seq4repair_space>useKey<seq2seq4repair_space>is<seq2seq4repair_space>true)" ) . withShortName ( "p" ) . create ( ) ; Option outputOpt = obuilder . withLongName ( "output" ) . withRequired ( false ) . withArgument ( abuilder . withName ( "output" ) . withMinimum ( 1 ) . withMaximum ( 1 ) . create ( ) ) . withDescription ( "The<seq2seq4repair_space>output<seq2seq4repair_space>file.<seq2seq4repair_space>If<seq2seq4repair_space>not<seq2seq4repair_space>specified,<seq2seq4repair_space>dumps<seq2seq4repair_space>to<seq2seq4repair_space>the<seq2seq4repair_space>console" ) . withShortName ( "o" ) . create ( ) ; Option dictOpt = obuilder . withLongName ( "dictionary" ) . withRequired ( false ) . withArgument ( abuilder . withName ( "dictionary" ) . withMinimum ( 1 ) . withMaximum ( 1 ) . create ( ) ) . withDescription ( "The<seq2seq4repair_space>dictionary<seq2seq4repair_space>file.<seq2seq4repair_space>" ) . withShortName ( "d" ) . create ( ) ; Option dictTypeOpt = obuilder . withLongName ( "dictionaryType" ) . withRequired ( false ) . withArgument ( abuilder . withName ( "dictionaryType" ) . withMinimum ( 1 ) . withMaximum ( 1 ) . create ( ) ) . withDescription ( "The<seq2seq4repair_space>dictionary<seq2seq4repair_space>file<seq2seq4repair_space>type<seq2seq4repair_space>(text|sequencefile)" ) . withShortName ( "dt" ) . create ( ) ; Option csvOpt = obuilder . withLongName ( "csv" ) . withRequired ( false ) . withDescription ( "Output<seq2seq4repair_space>the<seq2seq4repair_space>Vector<seq2seq4repair_space>as<seq2seq4repair_space>CSV.<seq2seq4repair_space>Otherwise<seq2seq4repair_space>it<seq2seq4repair_space>substitutes<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>terms<seq2seq4repair_space>for<seq2seq4repair_space>vector<seq2seq4repair_space>cell<seq2seq4repair_space>entries" ) . withShortName ( "c" ) . create ( ) ; Option namesAsCommentsOpt = obuilder . withLongName ( "namesAsComments" ) . withRequired ( false ) . withDescription ( "If<seq2seq4repair_space>using<seq2seq4repair_space>CSV<seq2seq4repair_space>output,<seq2seq4repair_space>optionally<seq2seq4repair_space>add<seq2seq4repair_space>a<seq2seq4repair_space>comment<seq2seq4repair_space>line<seq2seq4repair_space>for<seq2seq4repair_space>each<seq2seq4repair_space>NamedVector<seq2seq4repair_space>(if<seq2seq4repair_space>the<seq2seq4repair_space>vector<seq2seq4repair_space>is<seq2seq4repair_space>one)<seq2seq4repair_space>printing<seq2seq4repair_space>out<seq2seq4repair_space>the<seq2seq4repair_space>name" ) . withShortName ( "n" ) . create ( ) ; Option sizeOpt = obuilder . withLongName ( "sizeOnly" ) . withRequired ( false ) . withDescription ( "Dump<seq2seq4repair_space>only<seq2seq4repair_space>the<seq2seq4repair_space>size<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>vector" ) . withShortName ( "sz" ) . create ( ) ; Option helpOpt = obuilder . withLongName ( "help" ) . withDescription ( "Print<seq2seq4repair_space>out<seq2seq4repair_space>help" ) . withShortName ( "h" ) . create ( ) ; <START_BUG> Group group = gbuilder . withName ( "Options" ) . withOption ( seqOpt ) . withOption ( outputOpt ) . withOption ( dictTypeOpt ) . withOption ( dictOpt ) . withOption ( csvOpt ) . withOption ( vectorAsKeyOpt ) . withOption ( printKeyOpt ) . withOption ( sizeOpt ) . create ( ) ; <END_BUG> try { Parser parser = new Parser ( ) ; parser . setGroup ( group ) ; CommandLine cmdLine = parser . parse ( args ) ; if ( cmdLine . hasOption ( helpOpt ) ) { VectorDumper . printHelp ( group ) ; return ; } if ( cmdLine . hasOption ( seqOpt ) ) { Path path = new Path ( cmdLine . getValue ( seqOpt ) . toString ( ) ) ; Configuration conf = new Configuration ( ) ; String dictionaryType = "text" ; if ( cmdLine . hasOption ( dictTypeOpt ) ) { dictionaryType = cmdLine . getValue ( dictTypeOpt ) . toString ( ) ; } String [ ] dictionary = null ; if ( cmdLine . hasOption ( dictOpt ) ) { if ( "text" . equals ( dictionaryType ) ) { dictionary = VectorHelper . loadTermDictionary ( new File ( cmdLine . getValue ( dictOpt ) . toString ( ) ) ) ; } else if ( "sequencefile" . equals ( dictionaryType ) ) { dictionary = VectorHelper . loadTermDictionary ( conf , cmdLine . getValue ( dictOpt ) . toString ( ) ) ; } else { throw new OptionException ( dictTypeOpt ) ; } } boolean useCSV = cmdLine . hasOption ( csvOpt ) ; boolean sizeOnly = cmdLine . hasOption ( sizeOpt ) ; boolean namesAsComments = cmdLine . hasOption ( namesAsCommentsOpt ) ; boolean transposeKeyValue = cmdLine . hasOption ( vectorAsKeyOpt ) ; Writer writer ; if ( cmdLine . hasOption ( outputOpt ) ) { writer = Files . newWriter ( new File ( cmdLine . getValue ( outputOpt ) . toString ( ) ) , Charsets . UTF_8 ) ; } else { writer = new OutputStreamWriter ( System . out ) ; } try { boolean printKey = cmdLine . hasOption ( printKeyOpt ) ; if ( useCSV && ( dictionary != null ) ) { writer . write ( "#" ) ; for ( int j = 0 ; j < ( dictionary . length ) ; j ++ ) { writer . write ( dictionary [ j ] ) ; if ( j < ( ( dictionary . length ) - 1 ) ) { writer . write ( ',' ) ; } } writer . write ( '\n' ) ; } long i = 0 ; for ( Pair < Writable , Writable > record : new org . apache . mahout . common . iterator . sequencefile . SequenceFileIterable < Writable , Writable > ( path , true , conf ) ) { Writable keyWritable = record . getFirst ( ) ; Writable valueWritable = record . getSecond ( ) ; if ( printKey ) { Writable notTheVectorWritable = ( transposeKeyValue ) ? valueWritable : keyWritable ; writer . write ( notTheVectorWritable . toString ( ) ) ; writer . write ( '\t' ) ; }

Fix:
Group group = gbuilder . withName ( "Options" ) . withOption ( seqOpt ) . withOption ( outputOpt ) . withOption ( dictTypeOpt ) . withOption ( dictOpt ) . withOption ( csvOpt ) . withOption ( vectorAsKeyOpt ) . withOption ( printKeyOpt ) . withOption ( sizeOpt ) . withOption ( helpOpt ) . create ( ) ;