public void up(MessageBatch batch) { if(secret_key == null) { log.trace("%s: discarded %s batch from %s as secret key is null", local_addr, batch.dest() == null? "mcast" : "unicast", batch.sender()); return; } BlockingQueue<Cipher> cipherQueue = decoding_ciphers; try { Cipher cipher=cipherQueue.take(); try { BiConsumer<Message,MessageBatch> decrypter=new Decrypter(cipher); batch.forEach(decrypter); } finally { cipherQueue.offer(cipher); } } catch(InterruptedException e) { log.error("%s: failed processing batch; discarding batch", local_addr, e); // we need to drop the batch if we for example have a failure fetching a cipher, or else other messages // in the batch might make it up the stack, bypassing decryption! This is not an issue because encryption // is below NAKACK2 or UNICAST3, so messages will get retransmitted return; } if(!batch.isEmpty()) up_prot.up(batch); }
public void up(MessageBatch batch) { Cipher cipher=null; try { if(secret_key == null) { log.trace("%s: discarded %s batch from %s as secret key is null", local_addr, batch.dest() == null? "mcast" : "unicast", batch.sender()); return; } BiConsumer<Message,MessageBatch> decrypter=new Decrypter(cipher=decoding_ciphers.take()); batch.forEach(decrypter); } catch(InterruptedException e) { log.error("%s: failed processing batch; discarding batch", local_addr, e); // we need to drop the batch if we for example have a failure fetching a cipher, or else other messages // in the batch might make it up the stack, bypassing decryption! This is not an issue because encryption // is below NAKACK2 or UNICAST3, so messages will get retransmitted return; } finally { if(cipher != null) decoding_ciphers.offer(cipher); } if(!batch.isEmpty()) up_prot.up(batch); }