diff --git a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java index b1520d0d2d..b8134b9a18 100644 --- a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java +++ b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioFile.java @@ -22,7 +22,7 @@ import java.nio.ByteBuffer; /** * This is an extension to use libaio. */ -public final class LibaioFile { +public final class LibaioFile implements AutoCloseable { protected boolean open; /** diff --git a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java index 71f7516fba..fec742c680 100644 --- a/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java +++ b/artemis-native/src/test/java/org/apache/activemq/artemis/jlibaio/test/LibaioTest.java @@ -46,6 +46,28 @@ public class LibaioTest { @BeforeClass public static void testAIO() { Assume.assumeTrue(LibaioContext.isLoaded()); + + File parent = new File("./target"); + File file = new File(parent, "testFile"); + + try { + parent.mkdirs(); + + + boolean failed = false; + try (LibaioContext control = new LibaioContext<>(1, true); LibaioFile fileDescriptor = control.openFile(file, true)) { + fileDescriptor.fallocate(4 * 1024); + } + catch (Exception e) { + e.printStackTrace(); + failed = true; + } + + Assume.assumeFalse("There is not enough support to libaio", failed); + } + finally { + file.delete(); + } } /**