Buggy code:
public class Cache extends NameSet { private abstract static class Element implements TypedObject { byte credibility ; int expire ; protected void setValues ( byte credibility , long ttl ) { } public final boolean expired ( ) { } public abstract int getType ( ) { } } private static class PositiveElement extends Cache . Element { RRset rrset ; public PositiveElement ( RRset r , byte cred , long maxttl ) { } public int getType ( ) { } public String toString ( ) { } } private static class NegativeElement extends Cache . Element { int type ; Name name ; SOARecord soa ; public NegativeElement ( Name name , int type , SOARecord soa , byte cred , long maxttl ) { } public int getType ( ) { } public String toString ( ) { } } private static class CacheCleaner extends Thread { private Reference cacheref ; private long interval ; public CacheCleaner ( Cache cache , int cleanInterval ) { } private boolean clean ( Cache cache ) { } public void run ( ) { } } private static final int defaultCleanInterval = 30 ; private Verifier verifier ; private boolean secure ; private int maxncache = - 1 ; private int maxcache = - 1 ; private Cache . CacheCleaner cleaner ; private int dclass ; public Cache ( int dclass , int cleanInterval ) { } public Cache ( int dclass ) { } public Cache ( ) { } public void clearCache ( ) { } public Cache ( String file ) throws IOException { } public void addRecord ( Record r , byte cred , Object o ) { } public void addRRset ( RRset rrset , byte cred ) { } public void addNegative ( Name name , int type , SOARecord soa , byte cred ) { } private void logLookup ( Name name , int type , String msg ) { } public SetResponse lookupRecords ( Name name , int type , byte minCred ) { } private RRset [ ] findRecords ( Name name , int type , byte minCred ) { } public RRset [ ] findRecords ( Name name , int type ) { } public RRset [ ] findAnyRecords ( Name name , int type ) { } private void verifyRecords ( Cache tcache ) { } private final byte getCred ( int 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 ; int qtype ; int qclass ; byte cred ; <START_BUG> short rcode = in . getHeader ( ) . getRcode ( ) ; <END_BUG> boolean haveAnswer = false ; boolean completed = 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 ; int type = answers [ i ] . getType ( ) ; Name name = answers [ i ] . getName ( ) ; cred = getCred ( ANSWER , isAuth ) ; 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 ) ; } else 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 ( ) ; 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 ; } haveAnswer = true ; } } auth = in . getSectionRRsets ( AUTHORITY ) ; RRset soa = null ; RRset ns = null ; for ( int i = 0 ; i < ( auth . length ) ;

Fix:
int rcode = in . getHeader ( ) . getRcode ( ) ;