zabetak commented on code in PR #5872: URL: https://github.com/apache/hive/pull/5872#discussion_r2152044245
########## ql/src/java/org/apache/hadoop/hive/ql/exec/ExplainTask.java: ########## @@ -1003,6 +1003,9 @@ public JSONObject outputPlan(Object work, PrintStream out, Operator<? extends OperatorDesc> operator = (Operator<? extends OperatorDesc>) work; final int visitCnt = operatorVisits.merge(operator, 1, Integer::sum); + if (conf == null && this.work != null && this.work.getFetchTask() != null) { + conf = this.work.getFetchTask().getConf(); + } Review Comment: The initial NPE may be avoided but it is not guaranteed that `this.work.getFetchTask().getConf()` will be not null so technically the code could still hit NPE. Furthermore, I see at least 9 references to `conf` inside this class that do not account for the nullability of the field so fixing one of those seems somewhat incomplete. Moreover, this kind of fallback strategy to obtain a conf object from the internal fetch task else does not seem to be a widespread pattern so not sure what's the reasoning behind it. Since the problem seems to be triggered mainly by `HiveProtoLoggingHook` I was wondering if we should rather ensure that the respective class passes a non-null configuration object even if that is the default one (`new HiveConf()`). Another alternative would be to do something like the following: ```java final int limit = conf == null ? ConfVars.HIVE_EXPLAIN_NODE_VISIT_LIMIT.defaultIntVal : conf.getIntVar(ConfVars.HIVE_EXPLAIN_NODE_VISIT_LIMIT); ``` that definitely prevents the NPE no matter what, but it is still a localized fix. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org