Program: 144254
Project: 144254
Buggy source:
@Override protected Result doInBackground(String... params){
  Op op=Op.valueOf(params[0]);
  Result result=new Result(op);
  try {
    Log.d(CLASS_NAME,String.format("String_Node_Str",op));
    int port;
    Socket newSocket;
switch (op) {
case CONNECT:
      String host=params[1];
    port=Integer.parseInt(params[2]);
  Log.d(CLASS_NAME,String.format("String_Node_Str",host,port));
newSocket=new Socket();
newSocket.connect(new InetSocketAddress(host,port),3000);
publishProgress(CONNECTED.toString());
result.object=newSocket;
break;
case LISTEN:
port=Integer.parseInt(params[1]);
ServerSocketChannel serverChannel=ServerSocketChannel.open();
serverChannel.configureBlocking(false);
serverChannel.socket().bind(new InetSocketAddress(port));
Log.d(CLASS_NAME,String.format("String_Node_Str",port));
publishProgress(LISTENING.toString());
while (!task.isCancelled()) {
SocketChannel channel=serverChannel.accept();
Thread.sleep(100);
if (channel != null) {
result.object=channel.socket();
publishProgress(CONNECTED.toString());
break;
}
}
if (task.isCancelled()) {
serverChannel.close();
Log.d(CLASS_NAME,String.format("String_Node_Str",port));
result.exception=new Exception("String_Node_Str");
}
break;
case RECEIVE:
if (socket != null && socket.isConnected()) {
Log.d(CLASS_NAME,String.format("String_Node_Str",socket.getInetAddress().getHostAddress(),socket.getPort()));
receiveFromSocket();
}
break;
case SEND:
if (socket != null && socket.isConnected()) {
Log.d(CLASS_NAME,String.format("String_Node_Str",socket.getInetAddress().getHostAddress(),socket.getPort()));
sendToSocket();
}
break;
case DISCONNECT:
if (socket != null && socket.isConnected()) {
Log.d(CLASS_NAME,String.format("String_Node_Str",socket.getInetAddress().getHostAddress(),socket.getPort()));
socket.shutdownOutput();
socket.close();
setSocket(null);
publishProgress(IDLE.toString());
}
}
}
 catch (Exception e) {
e.printStackTrace();
result.exception=e;
}
return result;
}

Fixed version (ground truth):
@Override protected Result doInBackground(String... params){
  Op op=Op.valueOf(params[0]);
  Result result=new Result(op);
  try {
    Log.d(CLASS_NAME,String.format("String_Node_Str",op));
    int port;
    Socket newSocket;
switch (op) {
case CONNECT:
      String host=params[1];
    port=Integer.parseInt(params[2]);
  Log.d(CLASS_NAME,String.format("String_Node_Str",host,port));
newSocket=new Socket();
newSocket.connect(new InetSocketAddress(host,port),3000);
publishProgress(CONNECTED.toString());
result.object=newSocket;
break;
case LISTEN:
port=Integer.parseInt(params[1]);
serverChannel=ServerSocketChannel.open();
serverChannel.configureBlocking(false);
serverChannel.socket().bind(new InetSocketAddress(port));
Log.d(CLASS_NAME,String.format("String_Node_Str",port));
publishProgress(LISTENING.toString());
while (!task.isCancelled()) {
SocketChannel channel=serverChannel.accept();
Thread.sleep(100);
if (channel != null) {
result.object=channel.socket();
publishProgress(CONNECTED.toString());
break;
}
}
if (task.isCancelled()) {
serverChannel.close();
serverChannel=null;
Log.d(CLASS_NAME,String.format("String_Node_Str",port));
result.exception=new Exception("String_Node_Str");
}
break;
case RECEIVE:
if (socket != null && socket.isConnected()) {
Log.d(CLASS_NAME,String.format("String_Node_Str",socket.getInetAddress().getHostAddress(),socket.getPort()));
receiveFromSocket();
}
break;
case SEND:
if (socket != null && socket.isConnected()) {
Log.d(CLASS_NAME,String.format("String_Node_Str",socket.getInetAddress().getHostAddress(),socket.getPort()));
sendToSocket();
}
break;
case DISCONNECT:
if (socket != null && socket.isConnected()) {
Log.d(CLASS_NAME,String.format("String_Node_Str",socket.getInetAddress().getHostAddress(),socket.getPort()));
socket.shutdownOutput();
socket.close();
socket=null;
publishProgress(IDLE.toString());
}
}
}
 catch (Exception e) {
e.printStackTrace();
result.exception=e;
}
return result;
}