Buggy code:
public class SimpleResolver implements Resolver { public static final int DEFAULT_PORT = 53 ; private InetAddress addr ; private int port = SimpleResolver . DEFAULT_PORT ; private boolean useTCP ; private boolean ignoreTruncation ; private byte EDNSlevel = - 1 ; private TSIG tsig ; private int timeoutValue = 10 * 1000 ; private static final short DEFAULT_UDPSIZE = 512 ; private static final short EDNS_UDPSIZE = 1280 ; private static String defaultResolver = "localhost" ; private static int uniqueID = 0 ; public SimpleResolver ( String hostname ) throws UnknownHostException { } public SimpleResolver ( ) throws UnknownHostException { } public static void setDefaultResolver ( String hostname ) { } public void setPort ( int port ) { } public void setTCP ( boolean flag ) { } public void setIgnoreTruncation ( boolean flag ) { } public void setEDNS ( int level ) { } public void setTSIGKey ( Name name , byte [ ] key ) { } public void setTSIGKey ( String name , String key ) { } public void setTSIGKey ( String key ) throws UnknownHostException { } public void setTimeout ( int secs ) { } private byte [ ] readUDP ( DatagramSocket s , int max ) throws IOException { } private void writeUDP ( DatagramSocket s , byte [ ] out , InetAddress addr , int port ) throws IOException { } private byte [ ] readTCP ( Socket s ) throws IOException { } private void writeTCP ( Socket s , byte [ ] out ) throws IOException { } private Message parseMessage ( byte [ ] b ) throws WireParseException { } private void verifyTSIG ( Message query , Message response , byte [ ] b , TSIG tsig ) { } private void applyEDNS ( Message query ) { } private int maxUDPSize ( Message query ) { } public Message send ( Message query ) throws IOException { if ( Options . check ( "verbose" ) ) System . err . println ( ( ( ( "Sending<seq2seq4repair_space>to<seq2seq4repair_space>" + ( addr . getHostAddress ( ) ) ) + ":" ) + ( port ) ) ) ; if ( ( query . getHeader ( ) . getOpcode ( ) ) == ( Opcode . QUERY ) ) { Record question = query . getQuestion ( ) ; if ( ( question != null ) && ( ( question . getType ( ) ) == ( Type . AXFR ) ) ) return sendAXFR ( query ) ; } query = ( ( Message ) ( query . clone ( ) ) ) ; applyEDNS ( query ) ; if ( ( tsig ) != null ) <START_BUG> query . setTSIG ( tsig , NOERROR , null ) ; <END_BUG> byte [ ] out = query . toWire ( MAXLENGTH ) ; int udpSize = maxUDPSize ( query ) ; boolean tcp = false ; do { byte [ ] in ; if ( ( useTCP ) || ( ( out . length ) > udpSize ) ) tcp = true ; if ( tcp ) { Socket s = new Socket ( addr , port ) ; s . setSoTimeout ( timeoutValue ) ; try { writeTCP ( s , out ) ; in = readTCP ( s ) ; } finally { s . close ( ) ; } } else { DatagramSocket s = new DatagramSocket ( ) ; s . setSoTimeout ( timeoutValue ) ; try { writeUDP ( s , out , addr , port ) ; in = readUDP ( s , udpSize ) ; } finally { s . close ( ) ; } } Message response = parseMessage ( in ) ; verifyTSIG ( query , response , in , tsig ) ; if ( ( ( ! tcp ) && ( ! ( ignoreTruncation ) ) ) && ( response . getHeader ( ) . getFlag ( TC ) ) ) tcp = true ; else return response ; } while ( true ) ; } public Object sendAsync ( final Message query , final ResolverListener listener ) { } private Message sendAXFR ( Message query ) throws IOException { } }

Fix:
tsig . apply ( query , null ) ;