Skip to content

Instantly share code, notes, and snippets.

@marchof
Created August 24, 2017 14:15
Show Gist options
  • Save marchof/19aebb567ca4598c77b391460da39376 to your computer and use it in GitHub Desktop.
Save marchof/19aebb567ca4598c77b391460da39376 to your computer and use it in GitHub Desktop.
Fixing truncated JaCoCo exec files
package org.jacoco.examples;
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import org.jacoco.core.tools.ExecFileLoader;
/**
* Loads whatever is available in a truncated JaCoCo exec file and writes it to
* a new file. This might be used as a workaround to to get as much information
* as possible from broken exec files. Note that your coverage report will be
* incomplete in this case.
*/
public class ExecFix {
public static void main(final String[] args) throws IOException {
final ExecFileLoader loader = new ExecFileLoader();
try {
loader.load(new File("broken.exec"));
} catch (final EOFException e) {
// ignore truncated files
}
loader.save(new File("fixed.exec"), false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment