Skip to content

Commit

Permalink
ISPN-12087 Some tests are failing on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavolira authored and pruivo committed Jul 6, 2020
1 parent a29917f commit 2edbdda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Expand Up @@ -8,10 +8,12 @@
import org.infinispan.commons.configuration.elements.ElementDefinition;
import org.infinispan.configuration.parsing.Element;

import java.nio.file.Paths;

public class TemporaryGlobalStatePathConfiguration implements ConfigurationInfo {

public static final AttributeDefinition<String> PATH = AttributeDefinition.builder("path", null, String.class)
.initializer(() -> SecurityActions.getSystemProperty("java.io.tmpdir"))
.initializer(() -> Paths.get(SecurityActions.getSystemProperty("java.io.tmpdir")).toAbsolutePath().toString())
.immutable().build();

public static final AttributeDefinition<String> RELATIVE_TO = AttributeDefinition.builder("relativeTo", null, String.class).immutable().build();
Expand Down
Expand Up @@ -9,6 +9,7 @@
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -354,22 +355,22 @@ private void migrateFromV1() {
buf.flip();
}
}
} catch (IOException | ClassNotFoundException e) {
throw PERSISTENCE.persistedDataMigrationFailed(e);
}

try {

//close old file
channel.close();
//delete
Files.delete(file.toPath());
//rename new file
if (!newFile.renameTo(file)) {
throw new IOException(String.format("Unable to move file \"%s\" to \"%s\"",
newFile.getAbsolutePath(), file.getAbsolutePath()));
}
//replace old file with the new file
Files.move(newFile.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
//reopen the file
channel = new RandomAccessFile(file, "rw").getChannel();
//update file position
filePos = newFilePos;
PERSISTENCE.persistedDataSuccessfulMigrated();
} catch (IOException | ClassNotFoundException e) {
} catch (IOException e) {
throw PERSISTENCE.persistedDataMigrationFailed(e);
}
}
Expand Down

0 comments on commit 2edbdda

Please sign in to comment.