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

yangbowen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 29d31a278c4 [fix](restore) avoid NPE for restore job (#36395)
29d31a278c4 is described below

commit 29d31a278c4365bd1cd7ec627c2f5ac98de95666
Author: Xujian Duan <50550370+darvend...@users.noreply.github.com>
AuthorDate: Thu Jun 27 20:15:40 2024 +0800

    [fix](restore) avoid NPE for restore job (#36395)
    
    ## Proposed changes
    
    Issue Number: close #36440
    The indexes of OlapTable may not be assigned in method `readFields`:
    ```
    @Override
    public void readFields(DataInput in) throws IOException {
        ...
        // read indexes
        if (in.readBoolean()) {
            this.indexes = TableIndexes.read(in);
        }
        ...
    }
    ```
    So indexes may be null.
    <!--Describe your changes.-->
---
 .../src/main/java/org/apache/doris/catalog/OlapTable.java  | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
index 490e8a7b3a5..b0103e0d68b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
@@ -743,12 +743,14 @@ public class OlapTable extends Table implements 
MTMVRelatedTableIf, GsonPostProc
         }
 
         // reset the indexes and update the indexes in materialized index meta 
too.
-        List<Index> indexes = this.indexes.getIndexes();
-        for (Index idx : indexes) {
-            idx.setIndexId(env.getNextId());
-        }
-        for (Map.Entry<Long, MaterializedIndexMeta> entry : 
indexIdToMeta.entrySet()) {
-            entry.getValue().setIndexes(indexes);
+        if (this.indexes != null) {
+            List<Index> indexes = this.indexes.getIndexes();
+            for (Index idx : indexes) {
+                idx.setIndexId(env.getNextId());
+            }
+            for (Map.Entry<Long, MaterializedIndexMeta> entry : 
indexIdToMeta.entrySet()) {
+                entry.getValue().setIndexes(indexes);
+            }
         }
 
         return Status.OK;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to