Buggy code:
public final class VectorDumper extends AbstractJob { private static final Logger log = LoggerFactory . getLogger ( VectorDumper . class ) ; private VectorDumper ( ) { } @ Override public int run ( String [ ] args ) throws Exception { addInputOption ( ) ; addOutputOption ( ) ; addOption ( "useKey" , "u" , "If<seq2seq4repair_space>the<seq2seq4repair_space>Key<seq2seq4repair_space>is<seq2seq4repair_space>a<seq2seq4repair_space>vector<seq2seq4repair_space>than<seq2seq4repair_space>dump<seq2seq4repair_space>that<seq2seq4repair_space>instead" , false ) ; addOption ( "printKey" , "p" , "Print<seq2seq4repair_space>out<seq2seq4repair_space>the<seq2seq4repair_space>key<seq2seq4repair_space>as<seq2seq4repair_space>well,<seq2seq4repair_space>delimited<seq2seq4repair_space>by<seq2seq4repair_space>tab<seq2seq4repair_space>(or<seq2seq4repair_space>the<seq2seq4repair_space>value<seq2seq4repair_space>if<seq2seq4repair_space>useKey<seq2seq4repair_space>is<seq2seq4repair_space>true" , false ) ; addOption ( "dictionary" , "d" , "The<seq2seq4repair_space>dictionary<seq2seq4repair_space>file." , false ) ; addOption ( "dictionaryType" , "dt" , "The<seq2seq4repair_space>dictionary<seq2seq4repair_space>file<seq2seq4repair_space>type<seq2seq4repair_space>(text|seqfile)" , false ) ; addOption ( "csv" , "c" , "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" , false ) ; addOption ( "namesAsComments" , "n" , "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" , false ) ; addOption ( "nameOnly" , "N" , "Use<seq2seq4repair_space>the<seq2seq4repair_space>name<seq2seq4repair_space>as<seq2seq4repair_space>the<seq2seq4repair_space>value<seq2seq4repair_space>for<seq2seq4repair_space>each<seq2seq4repair_space>NamedVector<seq2seq4repair_space>(skip<seq2seq4repair_space>other<seq2seq4repair_space>vectors)" , false ) ; addOption ( "sortVectors" , "sort" , "Sort<seq2seq4repair_space>output<seq2seq4repair_space>key//value<seq2seq4repair_space>pairs<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>vector<seq2seq4repair_space>entries<seq2seq4repair_space>in<seq2seq4repair_space>abs<seq2seq4repair_space>magnitude<seq2seq4repair_space>descending<seq2seq4repair_space>order" , false ) ; addOption ( "quiet" , "q" , "Print<seq2seq4repair_space>only<seq2seq4repair_space>file<seq2seq4repair_space>contents" , false ) ; addOption ( "sizeOnly" , "sz" , "Dump<seq2seq4repair_space>only<seq2seq4repair_space>the<seq2seq4repair_space>size<seq2seq4repair_space>of<seq2seq4repair_space>the<seq2seq4repair_space>vector" , false ) ; addOption ( "numItems" , "ni" , "Output<seq2seq4repair_space>at<seq2seq4repair_space>most<seq2seq4repair_space><n><seq2seq4repair_space>vecors" , false ) ; addOption ( "vectorSize" , "vs" , ( "Truncate<seq2seq4repair_space>vectors<seq2seq4repair_space>to<seq2seq4repair_space><vs><seq2seq4repair_space>length<seq2seq4repair_space>when<seq2seq4repair_space>dumping<seq2seq4repair_space>(most<seq2seq4repair_space>useful<seq2seq4repair_space>when<seq2seq4repair_space>in" + "<seq2seq4repair_space>conjunction<seq2seq4repair_space>with<seq2seq4repair_space>-sort" ) , false ) ; <START_BUG> addOption ( buildOption ( "filter" , "fi" , ( "Only<seq2seq4repair_space>dump<seq2seq4repair_space>out<seq2seq4repair_space>those<seq2seq4repair_space>vectors<seq2seq4repair_space>whose<seq2seq4repair_space>name<seq2seq4repair_space>matches<seq2seq4repair_space>the<seq2seq4repair_space>filter." + "<seq2seq4repair_space>Multiple<seq2seq4repair_space>items<seq2seq4repair_space>may<seq2seq4repair_space>be<seq2seq4repair_space>specified<seq2seq4repair_space>by<seq2seq4repair_space>repeating<seq2seq4repair_space>the<seq2seq4repair_space>argument." ) , true , 1 , 100 , false , null ) ) ; <END_BUG> if ( ( parseArguments ( args , false , true ) ) == null ) { return - 1 ; } Path [ ] pathArr ; Configuration conf = new Configuration ( ) ; FileSystem fs = FileSystem . get ( conf ) ; Path input = getInputPath ( ) ; FileStatus fileStatus = fs . getFileStatus ( input ) ; if ( fileStatus . isDir ( ) ) { pathArr = FileUtil . stat2Paths ( fs . listStatus ( input , new OutputFilesFilter ( ) ) ) ; } else { FileStatus [ ] inputPaths = fs . globStatus ( input ) ; pathArr = new Path [ inputPaths . length ] ; int i = 0 ; for ( FileStatus fstatus : inputPaths ) { pathArr [ ( i ++ ) ] = fstatus . getPath ( ) ; } } String dictionaryType = getOption ( "dictionaryType" , "text" ) ; boolean sortVectors = hasOption ( "sortVectors" ) ; boolean quiet = hasOption ( "quiet" ) ; if ( ! quiet ) { VectorDumper . log . info ( ( "Sort?<seq2seq4repair_space>" + sortVectors ) ) ; } String [ ] dictionary = null ; if ( hasOption ( "dictionary" ) ) { String dictFile = getOption ( "dictionary" ) ; if ( "text" . equals ( dictionaryType ) ) { dictionary = VectorHelper . loadTermDictionary ( new File ( dictFile ) ) ; } else if ( "sequencefile" . equals ( dictionaryType ) ) { dictionary = VectorHelper . loadTermDictionary ( conf , dictFile ) ; } else { throw new IOException ( ( "Invalid<seq2seq4repair_space>dictionary<seq2seq4repair_space>type:<seq2seq4repair_space>" + dictionaryType ) ) ; } } Set < String > filters ; if ( hasOption ( "filter" ) ) { filters = new HashSet < String > ( getOptions ( "filter" ) ) ; } else { filters = null ; } boolean useCSV = hasOption ( "csv" ) ; boolean sizeOnly = hasOption ( "sizeOnly" ) ; boolean nameOnly = hasOption ( "nameOnly" ) ; boolean namesAsComments = hasOption ( "namesAsComments" ) ; boolean transposeKeyValue = hasOption ( "vectorAsKey" ) ; Writer writer ; boolean shouldClose ; File output = getOutputFile ( ) ; if ( output != null ) { shouldClose = true ; writer = Files . newWriter ( output , Charsets . UTF_8 ) ; } else { shouldClose = false ; writer = new OutputStreamWriter ( System . out ) ; } try { boolean printKey = hasOption ( "printKey" ) ; 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 numItems = null ; if ( hasOption ( "numItems" ) ) { numItems = Long . parseLong ( getOption ( "numItems" ) ) ; if ( quiet ) { writer . append ( "#Max<seq2seq4repair_space>Items<seq2seq4repair_space>to<seq2seq4repair_space>dump:<seq2seq4repair_space>" ) . append ( String . valueOf ( numItems ) ) . append ( '\n' ) ; } } int maxIndexesPerVector = ( hasOption ( "numIndexesPerVector" ) ) ? Integer . parseInt ( getOption ( "numIndexesPerVector" ) ) : Integer . MAX_VALUE ; long itemCount = 0 ; int fileCount = 0 ; for ( Path path : pathArr ) { if ( ( numItems != null ) && ( numItems <= itemCount ) ) { break ; } if ( quiet ) { VectorDumper . log . info ( "Processing<seq2seq4repair_space>file<seq2seq4repair_space>'{}'<seq2seq4repair_space>({}//{})" , new Object [ ] { path , ++ fileCount , pathArr . length } ) ; } SequenceFileIterable < Writable , Writable > iterable = new SequenceFileIterable < Writable , Writable > ( path , true , conf ) ; Iterator < Pair < Writable , Writable > > iterator = iterable . iterator ( ) ; long i = 0 ; while ( ( iterator . hasNext ( ) ) && ( ( numItems == null ) || ( itemCount < numItems ) ) ) { Pair < Writable , Writable > record = iterator . next ( ) ; Writable keyWritable = record . getFirst ( ) ; Writable valueWritable = record . getSecond ( ) ; if ( printKey ) { Writable notTheVectorWritable = ( transposeKeyValue ) ? valueWritable : keyWritable ; writer . write ( notTheVectorWritable . toString ( ) ) ; writer . write ( '\t' ) ; } Vector vector ;

Fix:
addOption ( buildOption ( "filter" , "fi" , ( "Only<seq2seq4repair_space>dump<seq2seq4repair_space>out<seq2seq4repair_space>those<seq2seq4repair_space>vectors<seq2seq4repair_space>whose<seq2seq4repair_space>name<seq2seq4repair_space>matches<seq2seq4repair_space>the<seq2seq4repair_space>filter." + "<seq2seq4repair_space>Multiple<seq2seq4repair_space>items<seq2seq4repair_space>may<seq2seq4repair_space>be<seq2seq4repair_space>specified<seq2seq4repair_space>by<seq2seq4repair_space>repeating<seq2seq4repair_space>the<seq2seq4repair_space>argument." ) , true , 1 , Integer . MAX_VALUE , false , null ) ) ;