[ 
https://issues.apache.org/jira/browse/PHOENIX-7940?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrew Kyle Purtell resolved PHOENIX-7940.
------------------------------------------
    Fix Version/s:     (was: 5.4.0)
                       (was: 5.3.2)
       Resolution: Duplicate

> PhoenixConnection.getTable throws NullPointerException on a cache miss when 
> timestamp is null
> ---------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-7940
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-7940
>             Project: Phoenix
>          Issue Type: Bug
>          Components: core
>            Reporter: Andrew Kyle Purtell
>            Priority: Major
>
> {{PhoenixConnection.getTable(@Nullable String tenantId, String fullTableName, 
> @Nullable Long timestamp)}} promises that a {{null}} {{timestamp}} returns 
> the latest cached {{PTable}}, falling back to a server lookup on cache miss.
> However, when the cache is empty such as on the first call from a 
> {{PhoenixConnection}} freshly handed out by the pool and {{timestamp == 
> null}}, the JVM will try to auto-unbox the {{Timestamp}} parameter and this 
> will throw a NPE.
> The fix is trivial:
> {noformat}
> diff --git 
> a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
>  
> b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
> --- 
> a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
> +++ 
> b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
> @@ -640,7 +640,11 @@ public class PhoenixConnection
>          throw new TableNotFoundException(fullTableName);
>        }
>      } catch (TableNotFoundException e) {
> -      table = getTableNoCache(pTenantId, fullTableName, timestamp);
> +      if (timestamp == null) {
> +        table = getTableNoCache(pTenantId, fullTableName);
> +      } else {
> +        table = getTableNoCache(pTenantId, fullTableName, timestamp);
> +      }
>      }
>      return table;
>    }
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to