Program: 79379
Project: 79379
Buggy source:
public static boolean isPortAvailable(InetAddress localAddress,int port){
  if (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER) {
    throw new IllegalArgumentException("String_Node_Str" + port);
  }
  InetAddress localAddressNotAny=(localAddress == null || ANY_NIC.equals(localAddress)) ? LOOPBACK : localAddress;
  Stopwatch watch=Stopwatch.createStarted();
  try {
    ServerSocket ss=null;
    DatagramSocket ds=null;
    try {
      ss=new ServerSocket();
      ss.setSoTimeout(250);
      ss.setReuseAddress(true);
      ss.bind(new InetSocketAddress(localAddress,port));
      ds=new DatagramSocket(null);
      ds.setSoTimeout(250);
      ds.setReuseAddress(true);
      ds.bind(new InetSocketAddress(localAddress,port));
    }
 catch (    IOException e) {
      return false;
    }
 finally {
      if (ds != null) {
        ds.close();
      }
      if (ss != null) {
        try {
          ss.close();
        }
 catch (        IOException e) {
        }
      }
    }
    if (localAddress == null || ANY_NIC.equals(localAddress)) {
      Enumeration<NetworkInterface> nis=null;
      try {
        nis=NetworkInterface.getNetworkInterfaces();
      }
 catch (      SocketException e) {
        throw Exceptions.propagate(e);
      }
      while (nis.hasMoreElements()) {
        NetworkInterface ni=nis.nextElement();
        Enumeration<InetAddress> as=ni.getInetAddresses();
        while (as.hasMoreElements()) {
          InetAddress a=as.nextElement();
          if (!isPortAvailable(a,port))           return false;
        }
      }
    }
    return true;
  }
  finally {
    if (log.isTraceEnabled())     log.trace("String_Node_Str",new Object[]{Time.makeTimeString(watch.elapsed(TimeUnit.MILLISECONDS),true),localAddress,port});
  }
}

Fixed version (ground truth):
public static boolean isPortAvailable(InetAddress localAddress,int port){
  if (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER) {
    throw new IllegalArgumentException("String_Node_Str" + port);
  }
  Stopwatch watch=Stopwatch.createStarted();
  try {
    ServerSocket ss=null;
    DatagramSocket ds=null;
    try {
      ss=new ServerSocket();
      ss.setSoTimeout(250);
      ss.setReuseAddress(true);
      ss.bind(new InetSocketAddress(localAddress,port));
      ds=new DatagramSocket(null);
      ds.setSoTimeout(250);
      ds.setReuseAddress(true);
      ds.bind(new InetSocketAddress(localAddress,port));
    }
 catch (    IOException e) {
      if (log.isTraceEnabled())       log.trace("String_Node_Str" + localAddress + "String_Node_Str"+ port,e);
      return false;
    }
 finally {
      closeQuietly(ds);
      closeQuietly(ss);
    }
    if (localAddress == null || ANY_NIC.equals(localAddress)) {
      Enumeration<NetworkInterface> nis=null;
      try {
        nis=NetworkInterface.getNetworkInterfaces();
      }
 catch (      SocketException e) {
        throw Exceptions.propagate(e);
      }
      boolean foundAvailableInterface=false;
      while (nis.hasMoreElements()) {
        NetworkInterface ni=nis.nextElement();
        Enumeration<InetAddress> as=ni.getInetAddresses();
        while (as.hasMoreElements()) {
          InetAddress a=as.nextElement();
          if (!isPortAvailable(a,port)) {
            if (isAddressValid(a)) {
              if (log.isTraceEnabled())               log.trace("String_Node_Str",new Object[]{a,port,nis});
              return false;
            }
          }
 else {
            foundAvailableInterface=true;
          }
        }
      }
      if (!foundAvailableInterface) {
        throw new RuntimeException("String_Node_Str" + localAddress + "String_Node_Str"+ port+ "String_Node_Str");
      }
    }
    return true;
  }
  finally {
    long elapsed=watch.elapsed(TimeUnit.SECONDS);
    boolean isDelayed=(elapsed >= 1);
    boolean isDelayedByMuch=(elapsed >= 30);
    if (isDelayed || log.isTraceEnabled()) {
      String msg="String_Node_Str";
      Object[] args=new Object[]{Time.makeTimeString(watch.elapsed(TimeUnit.MILLISECONDS),true),localAddress,port};
      if (isDelayedByMuch) {
        log.warn(msg,args);
      }
 else       if (isDelayed) {
        log.debug(msg,args);
      }
 else {
        log.trace(msg,args);
      }
    }
  }
}