From 2391a834c8d6a992adcc9fe74c34e95cdad18c81 Mon Sep 17 00:00:00 2001 From: Steve Lord Date: Thu, 16 May 2024 16:17:11 -0700 Subject: [PATCH] GH 41262:[Java][FlightSQL] Implement stateless prepared statement Attempt to get TempDir clean up --- .../org/apache/arrow/flight/sql/example/FlightSqlExample.java | 4 ++-- .../arrow/flight/sql/example/FlightSqlStatelessExample.java | 2 +- .../java/org/apache/arrow/flight/sql/test/TestFlightSql.java | 3 ++- .../apache/arrow/flight/sql/test/TestFlightSqlStateless.java | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/example/FlightSqlExample.java b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/example/FlightSqlExample.java index 77862ceb25a91..01f163b935bac 100644 --- a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/example/FlightSqlExample.java +++ b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/example/FlightSqlExample.java @@ -158,7 +158,7 @@ public class FlightSqlExample implements FlightSqlProducer, AutoCloseable { private static final Logger LOGGER = getLogger(FlightSqlExample.class); protected static final Calendar DEFAULT_CALENDAR = JdbcToArrowUtils.getUtcCalendar(); - public static final Path DB_PATH = Paths.get("target", "derbyDB"); + public static final Path DB_PATH = Paths.get("target", "tmp"); private final String databaseUri; // ARROW-15315: Use ExecutorService to simulate an async scenario private final ExecutorService executorService = Executors.newFixedThreadPool(10); @@ -195,7 +195,7 @@ private String toUri(Path path) { public FlightSqlExample(final Location location, final Path dbName) { // TODO Constructor should not be doing work. - final String derbyDatabaseUri = toUri(dbName); + final String derbyDatabaseUri = toUri(dbName) + "/derbyDB"; databaseUri = "jdbc:derby:" + derbyDatabaseUri; checkState( populateDerbyDatabase(databaseUri), diff --git a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/example/FlightSqlStatelessExample.java b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/example/FlightSqlStatelessExample.java index e7f49ea2ee509..560cecd3f05a0 100644 --- a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/example/FlightSqlStatelessExample.java +++ b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/example/FlightSqlStatelessExample.java @@ -68,7 +68,7 @@ */ public class FlightSqlStatelessExample extends FlightSqlExample { private static final Logger LOGGER = getLogger(FlightSqlStatelessExample.class); - public static final Path DB_PATH = Paths.get("target", "derbyStatelessDB"); + public static final Path DB_PATH = Paths.get("target", "tmpStateless"); public FlightSqlStatelessExample(final Location location, final Path dbPath) { diff --git a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/test/TestFlightSql.java b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/test/TestFlightSql.java index 573695c01c408..3dd18a8335e51 100644 --- a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/test/TestFlightSql.java +++ b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/test/TestFlightSql.java @@ -28,6 +28,7 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.io.CleanupMode.ALWAYS; import java.nio.file.Path; import java.sql.SQLException; @@ -98,7 +99,7 @@ public class TestFlightSql { protected static FlightSqlClient sqlClient; @TempDir - private static Path dbPath = FlightSqlExample.DB_PATH; + static Path dbPath; @BeforeAll public static void setUp() throws Exception { diff --git a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/test/TestFlightSqlStateless.java b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/test/TestFlightSqlStateless.java index 33e3a3c881bfe..49c33873cfcbf 100644 --- a/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/test/TestFlightSqlStateless.java +++ b/java/flight/flight-sql/src/test/java/org/apache/arrow/flight/sql/test/TestFlightSqlStateless.java @@ -20,6 +20,7 @@ import static org.apache.arrow.flight.sql.util.FlightStreamUtils.getResults; import static org.apache.arrow.util.AutoCloseables.close; import static org.hamcrest.CoreMatchers.*; +import static org.junit.jupiter.api.io.CleanupMode.ALWAYS; import java.nio.file.Path; @@ -48,7 +49,7 @@ */ public class TestFlightSqlStateless extends TestFlightSql { @TempDir - private static Path dbPath = FlightSqlStatelessExample.DB_PATH; + static Path dbPath; @BeforeAll