From 6c8d4631b697ecaddfac3000b3daea30ff22e1d7 Mon Sep 17 00:00:00 2001 From: wforget <643348094@qq.com> Date: Thu, 9 May 2024 08:44:34 -0700 Subject: [PATCH] [KYUUBI #6373] Avoid NPE in get operation log api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # :mag: Description ## Issue References ๐Ÿ”— This pull request fixes #6373 ## Describe Your Solution ๐Ÿ”ง `ThriftUtils#EMPTY_ROW_SET` is not suitable for OperationLog , so I add a new `LOG_EMPTY_ROW_SET` ## Types of changes :bookmark: - [X] Bugfix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Test Plan ๐Ÿงช #### Behavior Without This Pull Request :coffin: #### Behavior With This Pull Request :tada: #### Related Unit Tests --- # Checklist ๐Ÿ“ - [X] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes #6378 from wForget/KYUUBI-6373. Closes #6373 f25aa593f [wforget] revert ef87b3f4c [wforget] revert and fix npe 7219d35de [wforget] add test 06135fe0e [wforget] fix test c0bd29078 [wforget] [KYUUBI #6373] Add empty RowSet for OpertationLog Authored-by: wforget <643348094@qq.com> Signed-off-by: Wang, Fei (cherry picked from commit 5b6ab1af887daa09e0ea23ace21b2f0c1d2d887b) Signed-off-by: Wang, Fei --- .../apache/kyuubi/server/api/v1/OperationsResource.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala index e7a15ab92..224b34cf7 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala @@ -149,7 +149,11 @@ private[v1] class OperationsResource extends ApiRequestContext with Logging { FetchOrientation.withName(fetchOrientation), maxRows) val rowSet = fetchResultsResp.getResults - val logRowSet = rowSet.getColumns.get(0).getStringVal.getValues.asScala + val logRowSet = if (rowSet.getColumns != null) { + rowSet.getColumns.get(0).getStringVal.getValues.asScala + } else { + Seq.empty + } new OperationLog(logRowSet.asJava, logRowSet.size) } catch { case e: BadRequestException =>