Buggy code:
public RRset [ ] findRecords ( Name name , short type ) { } public RRset [ ] findAnyRecords ( Name name , short type ) { } private void verifyRecords ( Cache tcache ) { } private final byte getCred ( short section , boolean isAuth ) { } private static void markAdditional ( RRset rrset , Set names ) { } public SetResponse addMessage ( Message in ) { boolean isAuth = in . getHeader ( ) . getFlag ( AA ) ; Record question = in . getQuestion ( ) ; Name qname ; Name curname ; short qtype ; short qclass ; byte cred ; short rcode = in . getHeader ( ) . getRcode ( ) ; boolean haveAnswer = false ; boolean completed = false ; boolean restart = false ; RRset [ ] answers ; RRset [ ] auth ; RRset [ ] addl ; SetResponse response = null ; boolean verbose = Options . check ( "verbosecache" ) ; HashSet additionalNames ; if ( ( ( rcode != ( Rcode . NOERROR ) ) && ( rcode != ( Rcode . NXDOMAIN ) ) ) || ( question == null ) ) return null ; qname = question . getName ( ) ; qtype = question . getType ( ) ; qclass = question . getDClass ( ) ; curname = qname ; additionalNames = new HashSet ( ) ; answers = in . getSectionRRsets ( ANSWER ) ; for ( int i = 0 ; i < ( answers . length ) ; i ++ ) { if ( ( answers [ i ] . getDClass ( ) ) != qclass ) continue ; short type = answers [ i ] . getType ( ) ; Name name = answers [ i ] . getName ( ) ; cred = getCred ( ANSWER , isAuth ) ; if ( ( type == ( Type . CNAME ) ) && ( name . equals ( curname ) ) ) { CNAMERecord cname ; addRRset ( answers [ i ] , cred ) ; if ( curname == qname ) response = new SetResponse ( SetResponse . CNAME , answers [ i ] ) ; cname = ( ( CNAMERecord ) ( answers [ i ] . first ( ) ) ) ; curname = cname . getTarget ( ) ; restart = true ; haveAnswer = true ; } else if ( ( type == ( Type . DNAME ) ) && ( curname . subdomain ( name ) ) ) { DNAMERecord dname ; addRRset ( answers [ i ] , cred ) ; if ( curname == qname ) response = new SetResponse ( SetResponse . DNAME , answers [ i ] ) ; dname = ( ( DNAMERecord ) ( answers [ i ] . first ( ) ) ) ; try { curname = curname . fromDNAME ( dname ) ; } catch ( NameTooLongException e ) { break ; } restart = true ; haveAnswer = true ; } else if ( ( ( type == qtype ) || ( qtype == ( Type . ANY ) ) ) && ( name . equals ( curname ) ) ) { addRRset ( answers [ i ] , cred ) ; completed = true ; haveAnswer = true ; if ( curname == qname ) { if ( response == null ) response = new SetResponse ( SetResponse . SUCCESSFUL ) ; response . addRRset ( answers [ i ] ) ; } Cache . markAdditional ( answers [ i ] , additionalNames ) ; } if ( restart ) { restart = false ; <START_BUG> i = 0 ; <END_BUG> } } auth = in . getSectionRRsets ( AUTHORITY ) ; RRset soa = null ; RRset ns = null ; for ( int i = 0 ; i < ( auth . length ) ; i ++ ) { if ( ( ( auth [ i ] . getType ( ) ) == ( Type . SOA ) ) && ( curname . subdomain ( auth [ i ] . getName ( ) ) ) ) soa = auth [ i ] ; else if ( ( ( auth [ i ] . getType ( ) ) == ( Type . NS ) ) && ( curname . subdomain ( auth [ i ] . getName ( ) ) ) ) ns = auth [ i ] ; } if ( ! completed ) { short cachetype = ( rcode == ( Rcode . NXDOMAIN ) ) ? ( ( short ) ( 0 ) ) : qtype ; if ( ( soa != null ) || ( ns == null ) ) { cred = getCred ( AUTHORITY , isAuth ) ; SOARecord soarec = null ; if ( soa != null ) soarec = ( ( SOARecord ) ( soa . first ( ) ) ) ; addNegative ( curname , cachetype , soarec , cred ) ; if ( response == null ) { byte responseType ; if ( rcode == ( Rcode . NXDOMAIN ) ) responseType = SetResponse . NXDOMAIN ; else responseType = SetResponse . NXRRSET ; response = SetResponse . ofType ( responseType ) ; } } else if ( ns != null ) { cred = getCred ( AUTHORITY , isAuth ) ; addRRset ( ns , cred ) ; Cache . markAdditional ( ns , additionalNames ) ; if ( response == null ) response = new SetResponse ( SetResponse . DELEGATION , ns ) ; } } else if ( ( rcode == ( Rcode . NOERROR ) ) && ( ns != null ) ) { cred = getCred ( AUTHORITY , isAuth ) ; addRRset ( ns , cred ) ; Cache . markAdditional ( ns , additionalNames ) ; } addl = in . getSectionRRsets ( ADDITIONAL ) ;

Fix:
i = - 1 ;