This is an automated email from the ASF dual-hosted git repository.

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 07420b0c56 GH-43869: [Java][CI] Flight related failure in the AMD64 
Windows Server 2022 Java JDK 11 CI (#43850)
07420b0c56 is described below

commit 07420b0c56066326bd409e9537ee3d43ab6b1a51
Author: Vibhatha Lakmal Abeykoon <[email protected]>
AuthorDate: Fri Aug 30 07:50:53 2024 +0530

    GH-43869: [Java][CI] Flight related failure in the AMD64 Windows Server 
2022 Java JDK 11 CI (#43850)
    
    ### Rationale for this change
    
    CIs have been consistently failing on windows recently due to an issue with 
derby configuration. This PR investigates a solution for this.
    
    ### What changes are included in this PR?
    
    Changing the flow of the exception handling and state return.
    
    ### Are these changes tested?
    
    Via existing test cases.
    
    ### Are there any user-facing changes?
    
    No
    * GitHub Issue: #43869
    
    Authored-by: Vibhatha Lakmal Abeykoon <[email protected]>
    Signed-off-by: David Li <[email protected]>
---
 .../arrow/flight/sql/example/FlightSqlExample.java | 26 ++++++++++------------
 1 file changed, 12 insertions(+), 14 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 e7127faf97..67bfc85c48 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
@@ -181,9 +181,8 @@ public class FlightSqlExample implements FlightSqlProducer, 
AutoCloseable {
 
   public FlightSqlExample(final Location location, final String dbName) {
     // TODO Constructor should not be doing work.
-    checkState(
-        removeDerbyDatabaseIfExists(dbName) && populateDerbyDatabase(dbName),
-        "Failed to reset Derby database!");
+    checkState(removeDerbyDatabaseIfExists(dbName), "Failed to clear Derby 
database!");
+    checkState(populateDerbyDatabase(dbName), "Failed to populate Derby 
database!");
     databaseUri = "jdbc:derby:target/" + dbName;
     final ConnectionFactory connectionFactory =
         new DriverManagerConnectionFactory(databaseUri, new Properties());
@@ -253,36 +252,35 @@ public class FlightSqlExample implements 
FlightSqlProducer, AutoCloseable {
   }
 
   public static boolean removeDerbyDatabaseIfExists(final String dbName) {
-    boolean wasSuccess;
     final Path path = Paths.get("target" + File.separator + dbName);
 
     try (final Stream<Path> walk = Files.walk(path)) {
       /*
        * Iterate over all paths to delete, mapping each path to the outcome of 
its own
-       * deletion as a boolean representing whether or not each individual 
operation was
-       * successful; then reduce all booleans into a single answer, and store 
that into
-       * `wasSuccess`, which will later be returned by this method.
+       * deletion as a boolean representing whether each individual operation 
was
+       * successful; then reduce all booleans into a single answer.
        * If for whatever reason the resulting `Stream<Boolean>` is empty, 
throw an `IOException`;
        * this not expected.
        */
-      wasSuccess =
+      boolean unused =
           walk.sorted(Comparator.reverseOrder())
               .map(Path::toFile)
               .map(File::delete)
               .reduce(Boolean::logicalAnd)
               .orElseThrow(IOException::new);
-    } catch (IOException e) {
+    } catch (NoSuchFileException e) {
       /*
        * The only acceptable scenario for an `IOException` to be thrown here 
is if
        * an attempt to delete an non-existing file takes place -- which should 
be
        * alright, since they would be deleted anyway.
        */
-      if (!(wasSuccess = e instanceof NoSuchFileException)) {
-        LOGGER.error(format("Failed attempt to clear DerbyDB: <%s>", 
e.getMessage()), e);
-      }
+      LOGGER.error(format("No existing Derby database to delete.: <%s>", 
e.getMessage()), e);
+      return true;
+    } catch (Exception e) {
+      LOGGER.error(format("Failed attempt to clear DerbyDB.: <%s>", 
e.getMessage()), e);
+      return false;
     }
-
-    return wasSuccess;
+    return true;
   }
 
   private static boolean populateDerbyDatabase(final String dbName) {

Reply via email to