Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8265231: (fc) ReadDirect and WriteDirect tests fail after fix for JDK…
…-8264821

Reviewed-by: phh
Backport-of: d1b28e7
  • Loading branch information
zhengyu123 committed Jun 3, 2021
1 parent 2d76828 commit 09d3082
Showing 1 changed file with 5 additions and 6 deletions.
Expand Up @@ -48,9 +48,8 @@
public class DirectIOTest {

private static final int BASE_SIZE = 4096;
private static long blockSize;

private static int testWrite(Path p) throws Exception {
private static int testWrite(Path p, long blockSize) throws Exception {
try (FileChannel fc = FileChannel.open(p, StandardOpenOption.WRITE,
ExtendedOpenOption.DIRECT)) {
int bs = (int)blockSize;
Expand All @@ -68,7 +67,7 @@ private static int testWrite(Path p) throws Exception {
}
}

private static int testRead(Path p) throws Exception {
private static int testRead(Path p, long blockSize) throws Exception {
try (FileChannel fc = FileChannel.open(p, ExtendedOpenOption.DIRECT)) {
int bs = (int)blockSize;
int size = Math.max(BASE_SIZE, bs);
Expand Down Expand Up @@ -109,7 +108,7 @@ private static boolean isFileInCache(int size, Path p) {

public static void main(String[] args) throws Exception {
Path p = createTempFile();
blockSize = Files.getFileStore(p).getBlockSize();
long blockSize = Files.getFileStore(p).getBlockSize();

if (!isDirectIOSupportedByFS(p)) {
Files.delete(p);
Expand All @@ -119,12 +118,12 @@ public static void main(String[] args) throws Exception {
System.loadLibrary("DirectIO");

try {
int size = testWrite(p);
int size = testWrite(p, blockSize);
if (isFileInCache(size, p)) {
throw new RuntimeException("DirectIO is not working properly with "
+ "write. File still exists in cache!");
}
size = testRead(p);
size = testRead(p, blockSize);
if (isFileInCache(size, p)) {
throw new RuntimeException("DirectIO is not working properly with "
+ "read. File still exists in cache!");
Expand Down

1 comment on commit 09d3082

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.