package com.github.sparkcaller.variantdiscovery;

import com.github.sparkcaller.BaseGATKProgram;
import com.github.sparkcaller.Utils;
import org.apache.spark.api.java.function.Function;

import java.io.File;

public class HaplotypeCaller extends BaseGATKProgram implements Function<File, File> {

    public HaplotypeCaller(String pathToReference, String extraArgsString) {
        super("HaplotypeCaller", extraArgsString);
        setReference(pathToReference);
    }

    public File call(File bamFile) throws Exception {
        String outputFilename = Utils.removeExtenstion(bamFile.getPath(), "bam")  + ".vcf";
        setInputFile(bamFile.getAbsolutePath());
        setOutputFile(outputFilename);

        executeProgram();
        return bamFile;
    }
}

@@ -740,23 +740,40 @@
  return 
-bamFile
+new File(outputFilename)
 ;%0A    %7D%0A

Make sure that the file returned by the HaplotypeCaller is actually the same as the one it created.