OIiveirra commented on code in PR #68811: URL: https://github.com/apache/doris/pull/68811#discussion_r4255499600
########## fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/client/JdbcDiagnosticException.java: ########## @@ -0,0 +1,42 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.connector.jdbc.client; + +import org.apache.doris.connector.spi.DiagnosticException; +import org.apache.doris.connector.spi.DorisConnectorException; +import org.apache.doris.jni.toolkit.jdbc.JdbcExceptionUtils; + +/** Connector-owned, sanitized JDBC diagnostics with the original driver cause retained. */ +public final class JdbcDiagnosticException extends DorisConnectorException implements DiagnosticException { + private final String[] sensitiveValues; + + public JdbcDiagnosticException(String context, Throwable cause, String... sensitiveValues) { + super(JdbcExceptionUtils.format(context, cause, sensitiveValues), cause); Review Comment: @924060929 Fixed in 4958931c95f. The shared FE ExceptionDiagnosticUtils now finds the connector-owned diagnostic policy through outer wrappers and renders the complete exception at the statement output boundary. StmtExecutor command and outer execution logs use it; ConnectContextUtil and catalog diagnostics share the same policy lookup. Ordinary exceptions keep the original Log4j Throwable handling. JdbcFinalOutputDiagnosticsTest executes SHOW DATABASES FROM a failing catalog and captures the actual command and Analyze failed logs with throwable expansion. It verifies retained SQLSTATE/vendor codes and cause-chain diagnostics, with the configured password and JDBC URL absent. A separate captured-log assertion verifies ordinary exception stack frames remain. Validation: standard personal run-fe-ut.sh, JDK 17, Maven Checkstyle and BUILD SUCCESS; 61 tests passed across JdbcFinalOutputDiagnosticsTest, JdbcCatalogDiagnosticsTest, JdbcLegacyDiagnosticsTest and DataSourceConfigValidatorTest. A follow-up spec/standards review found no remaining introduced issues after fixing the ordinary-Throwable formatting regression found during review. This change only affects diagnostics, not execution flow. ########## fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClientException.java: ########## @@ -50,17 +72,6 @@ private static Object[] escapePercentInArgs(Object... args) { } public static String getAllExceptionMessages(Throwable throwable) { - StringBuilder sb = new StringBuilder(); - while (throwable != null) { - String message = throwable.getMessage(); - if (message != null && !message.isEmpty()) { - if (sb.length() > 0) { - sb.append(" | Caused by: "); - } - sb.append(message); - } - throwable = throwable.getCause(); - } - return sb.toString(); + return JdbcExceptionUtils.format("", throwable); Review Comment: @924060929 Fixed in 4958931c95f. OceanBase validation now retains a JDBC diagnostic wrapper carrying the source password/URL policy in JobException. StreamingInsertJob.initSourceJob applies the same source policy at its final log boundary and propagates a sanitized diagnostic wrapper, including when validation throws a direct SQLException. The raw cause remains available for diagnostics but is rendered through the policy at this output boundary. JdbcFinalOutputDiagnosticsTest invokes the real initSourceJob path with an OceanBase connection whose createStatement throws a raw SQLException containing the password and JDBC URL. The captured StreamingInsertJob log and propagated exception preserve remote SQLSTATE/vendor codes and cause-chain diagnostics without either original sensitive value. The test also checks client cleanup. Validation: standard personal run-fe-ut.sh, JDK 17, Maven Checkstyle and BUILD SUCCESS; all 61 targeted tests passed. The final spec/standards review found no remaining introduced defects or scope expansion. Source execution and cleanup control flow are unchanged. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
