dnsContext.setStore( store );
session.setAttribute( getContextKey(), dnsContext );
DomainNameService.execute( dnsContext, ( DnsMessage ) message );
DnsMessage response = dnsContext.getReply();
session.write( response );
}
catch ( Exception e )
{
LOG.error( e.getLocalizedMessage(), e );
DnsMessage request = ( DnsMessage ) message;
DnsException de = ( DnsException ) e;
DnsMessageModifier modifier = new DnsMessageModifier();
modifier.setTransactionId( request.getTransactionId() );
modifier.setMessageType( MessageType.RESPONSE );
modifier.setOpCode( OpCode.QUERY );
modifier.setAuthoritativeAnswer( false );
modifier.setTruncated( false );
modifier.setRecursionDesired( request.isRecursionDesired() );
modifier.setRecursionAvailable( false );
modifier.setReserved( false );
modifier.setAcceptNonAuthenticatedData( false );
modifier.setResponseCode( ResponseCode.convert( ( byte ) de.getResponseCode() ) );
modifier.setQuestionRecords( request.getQuestionRecords() );
modifier.setAnswerRecords( new ArrayList<ResourceRecord>() );
modifier.setAuthorityRecords( new ArrayList<ResourceRecord>() );
modifier.setAdditionalRecords( new ArrayList<ResourceRecord>() );
session.write( modifier.getDnsMessage() );