In the Java directory layer, DirectoryLayer.exists returns true unconditionally when not passed a path. This is different than the other bindings, which run through the normal exists check, but which I believe will still ultimately return true. The major difference is that in Java, no read version is obtained, which can cause behavior differences in the binding tester. This adds a call to get the read version to the Java testers when processing the DIRECTORY_EXISTS instruction.

This commit is contained in:
A.J. Beamon 2018-05-30 15:38:50 -07:00
parent 69696051a0
commit 1dbe24a6e8
2 changed files with 9 additions and 1 deletions

View File

@ -170,7 +170,10 @@ class AsyncDirectoryExtension {
.thenAccept(children -> inst.push(Tuple.fromItems(children).pack()));
}
else if(op == DirectoryOperation.DIRECTORY_EXISTS) {
return inst.popParam()
// In Java, DirectoryLayer.exists can return true without doing any reads.
// Other bindings will always do a read, so we get a read version now to be compatible with that behavior.
return inst.readTcx.readAsync(tr -> tr.getReadVersion())
.thenComposeAsync(v -> inst.popParam())
.thenComposeAsync(count -> DirectoryUtil.popPaths(inst, StackUtils.getInt(count)))
.thenComposeAsync(path -> {
if(path.size() == 0)

View File

@ -160,6 +160,11 @@ class DirectoryExtension {
int count = StackUtils.getInt(inst.popParam().get());
List<List<String>> path = DirectoryUtil.popPaths(inst, count).get();
boolean exists;
// In Java, DirectoryLayer.exists can return true without doing any reads.
// Other bindings will always do a read, so we get a read version now to be compatible with that behavior.
inst.readTcx.read(tr -> tr.getReadVersion().join());
if(path.size() == 0)
exists = directory().exists(inst.readTcx).get();
else