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

larsh pushed a commit to branch 4.x-HBase-1.5
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.x-HBase-1.5 by this push:
     new 0b9a039  PHOENIX-5533 Creating a view or index with a 4.14 client and 
4.15.0 server fails with a NullPointerException.
0b9a039 is described below

commit 0b9a0395554dcf72ece54c131fb628e7c3329902
Author: Lars Hofhansl <la...@apache.org>
AuthorDate: Thu Oct 24 08:47:44 2019 -0700

    PHOENIX-5533 Creating a view or index with a 4.14 client and 4.15.0 server 
fails with a NullPointerException.
---
 .../phoenix/coprocessor/MetaDataEndpointImpl.java  | 46 ++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index 6df5bf8..7558b8d 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -1730,6 +1730,45 @@ public class MetaDataEndpointImpl extends 
MetaDataProtocol implements Coprocesso
                 byte[][] parentPhysicalSchemaTableNames = new byte[3][];
                 getParentAndPhysicalNames(tableMetadata, 
parentSchemaTableNames, parentPhysicalSchemaTableNames);
                 if (parentPhysicalSchemaTableNames[2] != null) {
+                    if (parentTable == null) {
+                        // This is needed when we connect with a 4.14 client to
+                        // a 4.15.0+ server.
+                        // In that case we need to resolve the parent table on
+                        // the server.
+                        parentTable = doGetTable(ByteUtil.EMPTY_BYTE_ARRAY,
+                                parentPhysicalSchemaTableNames[1],
+                                parentPhysicalSchemaTableNames[2], 
clientTimeStamp, clientVersion);
+                        if (parentTable == null) {
+                            builder.setReturnCode(
+                                    
MetaDataProtos.MutationCode.PARENT_TABLE_NOT_FOUND);
+                            
builder.setMutationTime(EnvironmentEdgeManager.currentTimeMillis());
+                            done.run(builder.build());
+                            return;
+                        }
+                        if (parentSchemaTableNames[2] != null
+                                && Bytes.compareTo(parentSchemaTableNames[2],
+                                        parentPhysicalSchemaTableNames[2]) != 
0) {
+                            // if view is created on view
+                            byte[] tenantId = parentSchemaTableNames[0] == null
+                                    ? ByteUtil.EMPTY_BYTE_ARRAY
+                                    : parentSchemaTableNames[0];
+                            parentTable = doGetTable(tenantId, 
parentSchemaTableNames[1],
+                                    parentSchemaTableNames[2], 
clientTimeStamp, clientVersion);
+                            if (parentTable == null) {
+                                // it could be a global view
+                                parentTable = 
doGetTable(ByteUtil.EMPTY_BYTE_ARRAY,
+                                        parentSchemaTableNames[1], 
parentSchemaTableNames[2],
+                                        clientTimeStamp, clientVersion);
+                            }
+                        }
+                        if (parentTable == null) {
+                            builder.setReturnCode(
+                                    
MetaDataProtos.MutationCode.PARENT_TABLE_NOT_FOUND);
+                            
builder.setMutationTime(EnvironmentEdgeManager.currentTimeMillis());
+                            done.run(builder.build());
+                            return;
+                        }
+                    }
                     parentTableKey = 
SchemaUtil.getTableKey(ByteUtil.EMPTY_BYTE_ARRAY,
                             parentPhysicalSchemaTableNames[1], 
parentPhysicalSchemaTableNames[2]);
                     cParentPhysicalName = 
parentTable.getPhysicalName().getBytes();
@@ -1752,6 +1791,13 @@ public class MetaDataEndpointImpl extends 
MetaDataProtocol implements Coprocesso
                  */
                 parentTableName = 
MetaDataUtil.getParentTableName(tableMetadata);
                 parentTableKey = SchemaUtil.getTableKey(tenantIdBytes, 
parentSchemaName, parentTableName);
+                if (parentTable == null) {
+                    // This is needed when we connect with a 4.14 client to a 
4.15.0+ server.
+                    // In that case we need to resolve the parent table on the 
server.
+                    parentTable =
+                            doGetTable(tenantIdBytes, parentSchemaName, 
parentTableName, clientTimeStamp, null,
+                                    request.getClientVersion());
+                }
                 if (IndexType.LOCAL == indexType) {
                     cPhysicalName = parentTable.getPhysicalName().getBytes();
                     cParentPhysicalName = 
parentTable.getPhysicalName().getBytes();

Reply via email to