import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import org.simantics.databoard.binding.mutable.MutableVariant;
import org.simantics.databoard.serialization.Serializer;
import org.simantics.databoard.util.binary.BinaryMemory;
public class HeadState {
import org.simantics.databoard.binding.mutable.MutableVariant;
import org.simantics.databoard.serialization.Serializer;
import org.simantics.databoard.util.binary.BinaryMemory;
public class HeadState {
public int headChangeSetId = 0;
public long transactionId = 1;
public long reservedIds = 3;
public int headChangeSetId = 0;
public long transactionId = 1;
public long reservedIds = 3;
public ArrayList<String> cs = new ArrayList<>();
// public ArrayList<String> ccs = new ArrayList<String>();
public ArrayList<String> cs = new ArrayList<>();
// public ArrayList<String> ccs = new ArrayList<String>();
int digestLength = sha1.getDigestLength();
sha1.update(bytes, digestLength, bytes.length - digestLength);
int digestLength = sha1.getDigestLength();
sha1.update(bytes, digestLength, bytes.length - digestLength);
"Checksum " + Arrays.toString(newChecksum) + " does not match excpected "
+ Arrays.toString(Arrays.copyOfRange(bytes, 0, digestLength)) + " for " + f.toAbsolutePath());
}
"Checksum " + Arrays.toString(newChecksum) + " does not match excpected "
+ Arrays.toString(Arrays.copyOfRange(bytes, 0, digestLength)) + " for " + f.toAbsolutePath());
}
-
- HeadState object = (HeadState) org.simantics.databoard.Files.readFile(new ByteArrayInputStream(bytes, digestLength, bytes.length - digestLength), Bindings.getBindingUnchecked(HeadState.class));
- return object;
-
+ try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes, digestLength, bytes.length - digestLength)) {
+ HeadState object = (HeadState) org.simantics.databoard.Files.readFile(bais, Bindings.getBindingUnchecked(HeadState.class));
+ return object;
+ }
public static void validateHeadStateIntegrity(Path headState) throws InvalidHeadStateException, IOException {
try {
byte[] bytes = Files.readAllBytes(headState);
public static void validateHeadStateIntegrity(Path headState) throws InvalidHeadStateException, IOException {
try {
byte[] bytes = Files.readAllBytes(headState);
int digestLength = sha1.getDigestLength();
sha1.update(bytes, digestLength, bytes.length - digestLength);
byte[] newChecksum = sha1.digest();
int digestLength = sha1.getDigestLength();
sha1.update(bytes, digestLength, bytes.length - digestLength);
byte[] newChecksum = sha1.digest();