Program: 22764
Project: 22764
Buggy source:
/** 
 * Update features with current list in a multi-thread fashion
 */
public void updateFeaturesMT(){
  wholeStack=new ImageStack(width,height);
  wholeStack.addSlice("String_Node_Str",originalImage.getProcessor().duplicate());
  final ExecutorService exe=Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  final ArrayList<Future<ImagePlus>> futures=new ArrayList<Future<ImagePlus>>();
  try {
    if (enableFeatures[ANISOTROPIC_DIFFUSION]) {
      for (float i=minimumSigma; i <= maximumSigma; i*=2)       for (float j=0.10f; j < 0.5f; j+=0.25f)       futures.add(exe.submit(getAnisotropicDiffusion(originalImage,20,20,(int)i,j,0.9f,(float)membraneSize)));
    }
    if (enableFeatures[BILATERAL]) {
      for (double i=5; i < 20; i*=2)       for (double j=50; j <= 100; j*=2)       futures.add(exe.submit(getBilateralFilter(originalImage,i,j)));
    }
    if (enableFeatures[LIPSCHITZ]) {
      for (double i=5; i < 30; i+=5)       futures.add(exe.submit(getLipschitzFilter(originalImage,true,true,i)));
    }
    if (enableFeatures[KUWAHARA]) {
      for (int i=0; i < 3; i++)       futures.add(exe.submit(getKuwaharaFeatures(originalImage,membranePatchSize,nAngles,i)));
    }
    if (enableFeatures[GABOR]) {
      for (int i=0; i < 3; i++)       for (double gamma=1; gamma >= 0.25; gamma/=2)       for (int frequency=2; frequency <= 3; frequency++) {
        final double psi=Math.PI / 4 * i;
        futures.add(exe.submit(getGabor(originalImage,1.0,gamma,psi,frequency,nAngles)));
      }
      for (int i=0; i < 3; i++)       for (double sigma=2.0; sigma <= 4.0; sigma*=2)       for (double gamma=1.0; gamma <= 2.0; gamma*=2)       for (int frequency=2; frequency <= 3; frequency++) {
        final double psi=Math.PI / 4 * i;
        futures.add(exe.submit(getGabor(originalImage,sigma,gamma,psi,frequency,nAngles)));
      }
    }
    if (enableFeatures[SOBEL]) {
      futures.add(exe.submit(getGradient(originalImage,0)));
    }
    if (enableFeatures[HESSIAN]) {
      futures.add(exe.submit(getHessian(originalImage,0)));
    }
    for (float i=minimumSigma; i <= maximumSigma; i*=2) {
      if (enableFeatures[GAUSSIAN]) {
        futures.add(exe.submit(getGaussianBlur(originalImage,i)));
      }
      if (enableFeatures[SOBEL]) {
        futures.add(exe.submit(getGradient(originalImage,i)));
      }
      if (enableFeatures[HESSIAN]) {
        futures.add(exe.submit(getHessian(originalImage,i)));
      }
      if (enableFeatures[DOG]) {
        for (float j=minimumSigma; j < i; j*=2) {
          futures.add(exe.submit(getDoG(originalImage,i,j)));
        }
      }
      if (enableFeatures[VARIANCE]) {
        futures.add(exe.submit(getVariance(originalImage,i)));
      }
      if (enableFeatures[MEAN]) {
        futures.add(exe.submit(getMean(originalImage,i)));
      }
      if (enableFeatures[MINIMUM]) {
        futures.add(exe.submit(getMin(originalImage,i)));
      }
      if (enableFeatures[MAXIMUM]) {
        futures.add(exe.submit(getMax(originalImage,i)));
      }
    }
    if (enableFeatures[MEMBRANE])     futures.add(exe.submit(getMembraneFeatures(originalImage,membranePatchSize,membraneSize)));
    for (    Future<ImagePlus> f : futures) {
      final ImagePlus res=f.get();
      if (res.getImageStackSize() == 1) {
        this.wholeStack.addSlice(res.getTitle(),res.getProcessor());
      }
 else {
        final ImageStack slices=res.getImageStack();
        for (int i=1; i <= slices.getSize(); i++)         this.wholeStack.addSlice(slices.getSliceLabel(i),slices.getProcessor(i));
      }
    }
  }
 catch (  Exception ex) {
    IJ.log("String_Node_Str");
    ex.printStackTrace();
  }
 finally {
    exe.shutdown();
  }
  IJ.showProgress(1.0);
  IJ.showStatus("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Update features with current list in a multi-thread fashion
 */
public void updateFeaturesMT(){
  wholeStack=new ImageStack(width,height);
  wholeStack.addSlice("String_Node_Str",originalImage.getProcessor().duplicate());
  final ExecutorService exe=Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  final ArrayList<Future<ImagePlus>> futures=new ArrayList<Future<ImagePlus>>();
  try {
    if (enableFeatures[ANISOTROPIC_DIFFUSION]) {
      for (float i=minimumSigma; i <= maximumSigma; i*=2)       for (float j=0.10f; j < 0.5f; j+=0.25f)       futures.add(exe.submit(getAnisotropicDiffusion(originalImage,20,20,(int)i,j,0.9f,(float)membraneSize)));
    }
    if (enableFeatures[BILATERAL]) {
      for (double i=5; i < 20; i*=2)       for (double j=50; j <= 100; j*=2)       futures.add(exe.submit(getBilateralFilter(originalImage,i,j)));
    }
    if (enableFeatures[LIPSCHITZ]) {
      for (double i=5; i < 30; i+=5)       futures.add(exe.submit(getLipschitzFilter(originalImage,true,true,i)));
    }
    if (enableFeatures[KUWAHARA]) {
      for (int i=0; i < 3; i++)       futures.add(exe.submit(getKuwaharaFeatures(originalImage,membranePatchSize,nAngles,i)));
    }
    if (enableFeatures[GABOR]) {
      for (int i=0; i < 3; i++)       for (double gamma=1; gamma >= 0.25; gamma/=2)       for (int frequency=2; frequency <= 3; frequency++) {
        final double psi=Math.PI / 4 * i;
        futures.add(exe.submit(getGabor(originalImage,1.0,gamma,psi,frequency,nAngles)));
      }
      for (int i=0; i < 3; i++)       for (double sigma=2.0; sigma <= 4.0; sigma*=2)       for (double gamma=1.0; gamma <= 2.0; gamma*=2)       for (int frequency=2; frequency <= 3; frequency++) {
        final double psi=Math.PI / 4 * i;
        futures.add(exe.submit(getGabor(originalImage,sigma,gamma,psi,frequency,nAngles)));
      }
    }
    if (enableFeatures[SOBEL]) {
      futures.add(exe.submit(getGradient(originalImage,0)));
    }
    if (enableFeatures[HESSIAN]) {
      futures.add(exe.submit(getHessian(originalImage,0)));
    }
    for (float i=minimumSigma; i <= maximumSigma; i*=2) {
      if (enableFeatures[GAUSSIAN]) {
        futures.add(exe.submit(getGaussianBlur(originalImage,i)));
      }
      if (enableFeatures[SOBEL]) {
        futures.add(exe.submit(getGradient(originalImage,i)));
      }
      if (enableFeatures[HESSIAN]) {
        futures.add(exe.submit(getHessian(originalImage,i)));
      }
      if (enableFeatures[DOG]) {
        for (float j=minimumSigma; j < i; j*=2) {
          futures.add(exe.submit(getDoG(originalImage,i,j)));
        }
      }
      if (enableFeatures[VARIANCE]) {
        futures.add(exe.submit(getVariance(originalImage,i)));
      }
      if (enableFeatures[MEAN]) {
        futures.add(exe.submit(getMean(originalImage,i)));
      }
      if (enableFeatures[MINIMUM]) {
        futures.add(exe.submit(getMin(originalImage,i)));
      }
      if (enableFeatures[MAXIMUM]) {
        futures.add(exe.submit(getMax(originalImage,i)));
      }
      if (enableFeatures[MEDIAN]) {
        futures.add(exe.submit(getMedian(originalImage,i)));
      }
    }
    if (enableFeatures[MEMBRANE])     futures.add(exe.submit(getMembraneFeatures(originalImage,membranePatchSize,membraneSize)));
    for (    Future<ImagePlus> f : futures) {
      final ImagePlus res=f.get();
      if (res.getImageStackSize() == 1) {
        this.wholeStack.addSlice(res.getTitle(),res.getProcessor());
      }
 else {
        final ImageStack slices=res.getImageStack();
        for (int i=1; i <= slices.getSize(); i++)         this.wholeStack.addSlice(slices.getSliceLabel(i),slices.getProcessor(i));
      }
    }
  }
 catch (  Exception ex) {
    IJ.log("String_Node_Str");
    ex.printStackTrace();
  }
 finally {
    exe.shutdown();
  }
  IJ.showProgress(1.0);
  IJ.showStatus("String_Node_Str");
}