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

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


The following commit(s) were added to refs/heads/main by this push:
     new c65023b1e7 Hive: Avoid NPE on Throwables without error msg (#10069)
c65023b1e7 is described below

commit c65023b1e740280044da034150eacf745147e26a
Author: lurnagao-dahua <[email protected]>
AuthorDate: Wed Apr 3 21:27:39 2024 +0800

    Hive: Avoid NPE on Throwables without error msg (#10069)
---
 .../org/apache/iceberg/hive/HiveTableOperations.java   | 11 ++++++-----
 .../java/org/apache/iceberg/hive/TestHiveCommits.java  | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git 
a/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java 
b/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
index bae074d55d..75d59de75d 100644
--- 
a/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
+++ 
b/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
@@ -263,11 +263,12 @@ public class HiveTableOperations extends 
BaseMetastoreTableOperations
         throw e;
 
       } catch (Throwable e) {
-        if (e.getMessage()
-            .contains(
-                "The table has been modified. The parameter value for key '"
-                    + HiveTableOperations.METADATA_LOCATION_PROP
-                    + "' is")) {
+        if (e.getMessage() != null
+            && e.getMessage()
+                .contains(
+                    "The table has been modified. The parameter value for key 
'"
+                        + HiveTableOperations.METADATA_LOCATION_PROP
+                        + "' is")) {
           throw new CommitFailedException(
               e, "The table %s.%s has been modified concurrently", database, 
tableName);
         }
diff --git 
a/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCommits.java 
b/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCommits.java
index aaa6590421..acf4f8dc5c 100644
--- a/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCommits.java
+++ b/hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCommits.java
@@ -397,6 +397,24 @@ public class TestHiveCommits extends HiveTableBaseTest {
         .isTrue();
   }
 
+  @Test
+  public void testCommitExceptionWithoutMessage() throws TException, 
InterruptedException {
+    Table table = catalog.loadTable(TABLE_IDENTIFIER);
+    HiveTableOperations ops = (HiveTableOperations) ((HasTableOperations) 
table).operations();
+
+    TableMetadata metadataV1 = ops.current();
+    table.updateSchema().addColumn("n", Types.IntegerType.get()).commit();
+
+    ops.refresh();
+
+    HiveTableOperations spyOps = spy(ops);
+    doThrow(new RuntimeException()).when(spyOps).persistTable(any(), 
anyBoolean(), any());
+
+    assertThatThrownBy(() -> spyOps.commit(ops.current(), metadataV1))
+        .isInstanceOf(CommitStateUnknownException.class)
+        .hasMessageStartingWith("null\nCannot determine whether the commit was 
successful or not");
+  }
+
   private void commitAndThrowException(
       HiveTableOperations realOperations, HiveTableOperations spyOperations)
       throws TException, InterruptedException {

Reply via email to