Buggy code:
public class TernaryTriePrimitive implements SerializableTrie , Trie { private static final int FORMAT_VERSION = 1 ; private TCharList labels = new TCharArrayList ( ) ; private TIntList nodes = new TIntArrayList ( ) ; private int root ; private double threshold ; private char delimiter ; public TernaryTriePrimitive ( ) { } public TernaryTriePrimitive ( double t ) { } public TernaryTriePrimitive ( double t , char d ) { } public void bulkLoadTrie ( Map < String , Integer > items ) { } public List < Match > getAllMatches ( String [ ] tokens ) { } public Match getLongestMatch ( String [ ] tokens , int start ) { } public Match getLongestMatchAndInternalNodeId ( String [ ] tokens , int start , TernaryTriePrimitive . InternalNodeId nodeId ) { } public int get ( String [ ] tokens ) { } public int get ( String key ) { } public String getPrefixThresholdedString ( String s ) { String [ ] split = s . split ( String . valueOf ( delimiter ) ) ; String [ ] prefixSplit = new String [ split . length ] ; for ( int i = 0 ; i < ( split . length ) ; i ++ ) { <START_BUG> prefixSplit [ i ] = split [ i ] . substring ( 0 , getRelevantLength ( s ) ) ; <END_BUG> } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < ( prefixSplit . length ) ; i ++ ) { sb . append ( prefixSplit [ i ] ) ; if ( i < ( ( prefixSplit . length ) - 1 ) ) { sb . append ( delimiter ) ; } } return sb . toString ( ) ; } public int getPrefixId ( String partialKey ) { } public int getPrefixId ( String [ ] partialKey ) { } public void visitAggregateValues ( AggregateValueVisitor visitor ) { } private void visitAggregateValues ( AggregateValueVisitor visitor , int node , Set < Integer > parentValues ) { } public void put ( String [ ] tokens , int value ) { } public void put ( String key , int value ) { } private int put ( int node , String [ ] tokens , int iToken , int pos , int value ) { } private int getLessChild ( int node ) { } private int getEqualChild ( int node ) { } private int getGreatChild ( int node ) { } private int getNodeValue ( int node ) { } private char getNodeKey ( int node ) { } private int getNewNode ( char chr ) { } private void setLessChild ( int parentNode , int childNode ) { } private void setEqualChild ( int parentNode , int childNode ) { } private void setGreatChild ( int parentNode , int childNode ) { } private void setNodeValue ( int node , int value ) { } public int getTotalNodes ( ) { } private void getNodesPerLevel ( TIntIntHashMap num , int level , int node ) { } public int [ ] getNodesPerLevel ( ) { } private void getCollapsableLengths ( int node , int length , TIntIntMap distribution ) { } public TIntIntMap getCollapsableLengths ( ) { } public String getContent ( ) { } private StringBuilder getContent ( int node , StringBuilder repr , String prefix ) { } public String getTreeView ( ) { } private StringBuilder getTreeView ( int node , StringBuilder sb ) { } private int getRelevantLength ( String key ) { } public void serialize ( OutputStream stream ) throws IOException { } public Trie deserialize ( InputStream stream ) throws IOException { } private class InternalNodeId { private int id ; public InternalNodeId ( int id ) { } public void setId ( int id ) { } public int getId ( ) { } } }

Fix:
prefixSplit [ i ] = split [ i ] . substring ( 0 , getRelevantLength ( split [ i ] ) ) ;