amogh-jahagirdar commented on code in PR #14280:
URL: https://github.com/apache/iceberg/pull/14280#discussion_r2433938411


##########
spark/v4.0/spark/src/test/java/org/apache/iceberg/TestTableSerialization.java:
##########
@@ -158,6 +159,39 @@ public void 
testSerializableTransactionTableKryoSerialization() throws IOExcepti
         txnTable, KryoHelpers.roundTripSerialize(serializableTxnTable));
   }
 
+  @TestTemplate
+  public void testLocationProviderExceptionIsDeferred() {
+    Table spyTable = spy(table);
+    RuntimeException failure = new RuntimeException("location provider 
failure");
+    when(spyTable.locationProvider()).thenThrow(failure);
+
+    Table serializableTable = SerializableTableWithSize.copyOf(spyTable);
+    assertThat(serializableTable).isNotNull();
+
+    assertThatThrownBy(serializableTable::locationProvider).isSameAs(failure);
+    verify(spyTable, times(1)).locationProvider();
+  }
+
+  @TestTemplate
+  public void testLocationProviderExceptionSerializationRoundTrip()
+      throws IOException, ClassNotFoundException {
+    Table spyTable = spy(table);
+    RuntimeException failure = new RuntimeException("location provider 
failure");
+    when(spyTable.locationProvider()).thenThrow(failure);
+
+    Table serializableTable = SerializableTableWithSize.copyOf(spyTable);
+
+    Table javaDeserialized = TestHelpers.roundTripSerialize(serializableTable);
+    assertThatThrownBy(javaDeserialized::locationProvider)
+        .isInstanceOf(RuntimeException.class)
+        .hasMessage("location provider failure");
+
+    Table kryoDeserialized = KryoHelpers.roundTripSerialize(serializableTable);
+    assertThatThrownBy(kryoDeserialized::locationProvider)
+        .isInstanceOf(RuntimeException.class)
+        .hasMessage("location provider failure");

Review Comment:
   Could we have kryo test in a separate test? In case something breaks in the 
future it's easier to isolate if it's a kryo issue or not instead of having to 
poke into the tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to