Program: 4175
Project: 4175
Buggy source:
public void testShutdown() throws Exception {
  Executor executor=ExecutorsHelper.newProcessingQueue("String_Node_Str");
  SSLContext context=SSLContext.getInstance("String_Node_Str");
  context.init(null,null,null);
  final SSLReadWriteChannel clientChannel=new SSLReadWriteChannel(context,executor);
  final SSLReadWriteChannel serverChannel=new SSLReadWriteChannel(context,executor);
  NIODispatcher.instance().getScheduledExecutorService().submit(new Runnable(){
    public void run(){
      clientChannel.initialize(null,new String[]{"String_Node_Str"},true,false);
      serverChannel.initialize(null,new String[]{"String_Node_Str"},false,false);
    }
  }
).get();
  Pipe clientToServer=Pipe.open();
  Pipe serverToClient=Pipe.open();
  serverToClient.source().configureBlocking(false);
  serverToClient.sink().configureBlocking(false);
  clientToServer.source().configureBlocking(false);
  clientToServer.sink().configureBlocking(false);
  clientChannel.setReadChannel(new IRWrapper(serverToClient.source()));
  clientChannel.setWriteChannel(new IWWrapper(clientToServer.sink()));
  serverChannel.setReadChannel(new IRWrapper(clientToServer.source()));
  serverChannel.setWriteChannel(new IWWrapper(serverToClient.sink()));
  String serverOut="String_Node_Str";
  String clientOut="String_Node_Str";
  new WriteBufferChannel(serverOut.getBytes(),serverChannel);
  new WriteBufferChannel(clientOut.getBytes(),clientChannel);
  final ByteBuffer clientRead=ByteBuffer.allocate(100);
  final ByteBuffer serverRead=ByteBuffer.allocate(100);
  for (int i=0; i < 10; i++) {
    NIODispatcher.instance().getScheduledExecutorService().submit(new Runnable(){
      public void run(){
        try {
          clientChannel.shutdown();
          serverChannel.shutdown();
          clientChannel.read(clientRead);
          serverChannel.read(serverRead);
          clientChannel.handleWrite();
          serverChannel.handleWrite();
        }
 catch (        IOException iox) {
          throw new RuntimeException(iox);
        }
      }
    }
).get();
    Thread.sleep(100);
  }
  assertEquals(serverOut,new String(clientRead.array(),0,clientRead.position()));
  assertEquals(clientOut,new String(serverRead.array(),0,serverRead.position()));
  serverToClient.source().close();
  serverToClient.sink().close();
  clientToServer.source().close();
  clientToServer.sink().close();
  clientChannel.shutdown();
  serverChannel.shutdown();
  try {
    clientChannel.read(BufferUtils.getEmptyBuffer());
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
  try {
    serverChannel.read(BufferUtils.getEmptyBuffer());
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
  try {
    clientChannel.write(BufferUtils.getEmptyBuffer());
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
  try {
    serverChannel.write(BufferUtils.getEmptyBuffer());
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
  try {
    clientChannel.handleWrite();
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
  try {
    serverChannel.handleWrite();
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
}

Fixed version (ground truth):
public void testShutdown() throws Exception {
  Executor executor=ExecutorsHelper.newProcessingQueue("String_Node_Str");
  SSLContext context=SSLContext.getInstance("String_Node_Str");
  context.init(null,null,null);
  final SSLReadWriteChannel clientChannel=new SSLReadWriteChannel(context,executor,NIODispatcher.instance().getBufferCache(),NIODispatcher.instance().getScheduledExecutorService());
  final SSLReadWriteChannel serverChannel=new SSLReadWriteChannel(context,executor,NIODispatcher.instance().getBufferCache(),NIODispatcher.instance().getScheduledExecutorService());
  NIODispatcher.instance().getScheduledExecutorService().submit(new Runnable(){
    public void run(){
      clientChannel.initialize(null,new String[]{"String_Node_Str"},true,false);
      serverChannel.initialize(null,new String[]{"String_Node_Str"},false,false);
    }
  }
).get();
  Pipe clientToServer=Pipe.open();
  Pipe serverToClient=Pipe.open();
  serverToClient.source().configureBlocking(false);
  serverToClient.sink().configureBlocking(false);
  clientToServer.source().configureBlocking(false);
  clientToServer.sink().configureBlocking(false);
  clientChannel.setReadChannel(new IRWrapper(serverToClient.source()));
  clientChannel.setWriteChannel(new IWWrapper(clientToServer.sink()));
  serverChannel.setReadChannel(new IRWrapper(clientToServer.source()));
  serverChannel.setWriteChannel(new IWWrapper(serverToClient.sink()));
  String serverOut="String_Node_Str";
  String clientOut="String_Node_Str";
  new WriteBufferChannel(serverOut.getBytes(),serverChannel);
  new WriteBufferChannel(clientOut.getBytes(),clientChannel);
  final ByteBuffer clientRead=ByteBuffer.allocate(100);
  final ByteBuffer serverRead=ByteBuffer.allocate(100);
  for (int i=0; i < 10; i++) {
    NIODispatcher.instance().getScheduledExecutorService().submit(new Runnable(){
      public void run(){
        try {
          clientChannel.shutdown();
          serverChannel.shutdown();
          clientChannel.read(clientRead);
          serverChannel.read(serverRead);
          clientChannel.handleWrite();
          serverChannel.handleWrite();
        }
 catch (        IOException iox) {
          throw new RuntimeException(iox);
        }
      }
    }
).get();
    Thread.sleep(100);
  }
  assertEquals(serverOut,new String(clientRead.array(),0,clientRead.position()));
  assertEquals(clientOut,new String(serverRead.array(),0,serverRead.position()));
  serverToClient.source().close();
  serverToClient.sink().close();
  clientToServer.source().close();
  clientToServer.sink().close();
  clientChannel.shutdown();
  serverChannel.shutdown();
  try {
    clientChannel.read(BufferUtils.getEmptyBuffer());
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
  try {
    serverChannel.read(BufferUtils.getEmptyBuffer());
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
  try {
    clientChannel.write(BufferUtils.getEmptyBuffer());
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
  try {
    serverChannel.write(BufferUtils.getEmptyBuffer());
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
  try {
    clientChannel.handleWrite();
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
  try {
    serverChannel.handleWrite();
    fail("String_Node_Str");
  }
 catch (  ClosedChannelException expected) {
  }
}