This is an automated email from the ASF dual-hosted git repository. tarmstrong pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/impala.git
commit 8de7bf773ded7e6db9a0463222e7f552fd20735f Author: Zoltan Borok-Nagy <borokna...@cloudera.com> AuthorDate: Wed Dec 16 15:01:35 2020 +0100 IMPALA-10398: Altering an Iceberg table might throw NullPointerException IcebergSchemaConverter has a static thread local member which might not have a value in the current thread when nextId() is invoked. In that case the thread local integer's get() method returns a null and we get a NullPointerException when we want to convert it to a builtin int. This patch initializes the thread local variable with an anonymous subclass of ThreadLocal that overrides the 'initialValue()' method which returns 0 instead of null. Testing * tested manually by restarting the impala cluster and issuing ALTER TABLE .. ADD COLUMNS <columns with complex types> * looped test_alter_iceberg_tables for a while Change-Id: I4e8b7c655558898bd13c5288b466d5bf3d258392 Reviewed-on: http://gerrit.cloudera.org:8080/16882 Reviewed-by: Gabor Kaszab <gaborkas...@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com> --- .../main/java/org/apache/impala/util/IcebergSchemaConverter.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fe/src/main/java/org/apache/impala/util/IcebergSchemaConverter.java b/fe/src/main/java/org/apache/impala/util/IcebergSchemaConverter.java index 763c4fb..736a265 100644 --- a/fe/src/main/java/org/apache/impala/util/IcebergSchemaConverter.java +++ b/fe/src/main/java/org/apache/impala/util/IcebergSchemaConverter.java @@ -42,7 +42,12 @@ public class IcebergSchemaConverter { // them from multiple threads. Hence we use this thread-local integer to generate // unique field ids for each schema element. Please note that Iceberg only care about // the uniqueness of the field ids, but they will be reassigned by Iceberg. - private static ThreadLocal<Integer> iThreadLocal = new ThreadLocal<>(); + private static ThreadLocal<Integer> iThreadLocal = new ThreadLocal<Integer>() { + @Override + public Integer initialValue() { + return 0; + } + }; /** * Transform iceberg type to impala type