我正在尝试从Jooq异常处理程序中删除或隐藏敏感数据,我尝试实现监听器来处理异常,但我意识到包含敏感数据的查询(例如绑定值)来自java.sql.BatchUpdateException,它不属于Jooq而属于java.sql。
因此,我的问题是,如何在异常中隐藏敏感数据而不丢失完整的异常信息?
以下是一个示例:
因此,我的问题是,如何在异常中隐藏敏感数据而不丢失完整的异常信息?
以下是一个示例:
Caused by: org.jooq.exception.DataAccessException: SQL [insert into "public"."table" ("id", "sensitvefield") values (?, ) on conflict ("id", "sensitvefield") do update set "id" = ?, "sensitvefield" = ? where ("public"."mytable"."id" = ? and "public"."mytable"."sensitvefield" = ?)]; Batch entry 0 insert into "public"."mytable" ("id","sensitvefield"]") values (2653933, sensitivefielddata) was aborted: ERROR: value too long for type character varying(50) Call getNextException to see other errors in the batch.
at org.jooq_3.14.15.POSTGRES.debug(Unknown Source)
at org.jooq.impl.Tools.translate(Tools.java:2903)
at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:757)
at org.jooq.impl.BatchSingle.executePrepared(BatchSingle.java:254)
at org.jooq.impl.BatchSingle.execute(BatchSingle.java:170)
at org.jooq.impl.BatchCRUD.executePrepared(BatchCRUD.java:148)
at org.jooq.impl.BatchCRUD.execute(BatchCRUD.java:91)
at com.myservice(ServiceRepository.kt:49)
... 41 common frames omitted
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into "public"."mytable" ("id", "sensitivefield",) values (2653933, sensitivefielddata) was aborted: ERROR: value too long for type character varying(50) Call getNextException to see other errors in the batch.
at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:171)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2298)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:520)
at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:878)
at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:901)
at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1644)
at com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:127)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeBatch(HikariProxyPreparedStatement.java)
at org.jooq.tools.jdbc.DefaultStatement.executeBatch(DefaultStatement.java:112)
at org.jooq.impl.BatchSingle.executePrepared(BatchSingle.java:234)
... 45 common frames omitted
Caused by: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(50)
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2565)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2297)
... 53 common frames omitted
例如,在这里,如果我替换所有原因,我将丢失消息“ERROR:value too long for type character varying(50)”,该消息提供了很多信息,但是,正如您所看到的,有敏感信息,如sensitvefield和sensitivedata。
有人知道任何解决方法吗?