Unabled to access Trino exception during tests

Hello, when running tests, it seems like exceptions are not properly handled due to errors like
cannot access a member of class io.trino.jdbc.$internal.client.FailureInfo$FailureException with modifiers "public"

It seems the test error handling may be trying to access a private inner class FailureException of FailureInfo. You can see the Trino class is here: https://github.com/trinodb/trino/blame/fe608f2723842037ff620d612a706900e79c52c8/client/trino-client/src/main/java/io/trino/client/FailureInfo.java#L48

This is happening for most of my tests. Any thoughts as to why this could be happening?

Full error stack trace below.

    ERROR in metabase.query-processor-test.timezones-test/result-rows-test (util.clj:366)
Uncaught exception, not in assertion.

      clojure.lang.ExceptionInfo: Error in with-temporary-setting-values: class clojure.core$bean$fn__7216$fn__7217 cannot access a member of class io.trino.jdbc.$internal.client.FailureInfo$FailureException with modifiers "public"
    location: metabase.driver/report-timezone
     setting: :report-timezone
       value: "UTC"
java.lang.IllegalAccessException: class clojure.core$bean$fn__7216$fn__7217 cannot access a member of class io.trino.jdbc.$internal.client.FailureInfo$FailureException with modifiers "public"
    jdk.internal.reflect.Reflection.newIllegalAccessException     Reflection.java:  361
                                      clojure.core/bean/fn/fn      core_proxy.clj:  408
                                          clojure.core/bean/v      core_proxy.clj:  414
                                  clojure.core/bean/thisfn/fn      core_proxy.clj:  422
                                            clojure.core/next            core.clj:   64
                                    clojure.core.protocols/fn       protocols.clj:  169
                                  clojure.core.protocols/fn/G       protocols.clj:   19
                            clojure.core.protocols/seq-reduce       protocols.clj:   31
                                    clojure.core.protocols/fn       protocols.clj:   75
                                  clojure.core.protocols/fn/G       protocols.clj:   13
                                          clojure.core/reduce            core.clj: 6830
                                io.aviso.exception/match-keys       exception.clj:   95
                          io.aviso.exception/expand-exception       exception.clj:  402
                         io.aviso.exception/analyze-exception       exception.clj:  437
                           io.aviso.exception/write-exception       exception.clj:  623
                                           clojure.core/apply            core.clj:  669
                                  io.aviso.writer/into-string          writer.clj:   60
                                  io.aviso.writer/into-string          writer.clj:   54
                          io.aviso.exception/format-exception       exception.clj:  630
                                io.aviso.repl/print-exception            repl.clj:   20
                       io.aviso.repl/pretty-print-stack-trace            repl.clj:   53
                        eftest.report.pretty/print-stacktrace          pretty.clj:   85
                         eftest.report.pretty/error-report/fn          pretty.clj:   93
                            eftest.report.pretty/error-report          pretty.clj:   93
                             eftest.report.pretty/eval3827/fn          pretty.clj:  134
                        eftest.report.progress/eval3928/fn/fn        progress.clj:   54
                           eftest.report.progress/eval3928/fn        progress.clj:   54
                   metabase.test-runner/reporter/handle-event     test_runner.clj:  142
                                 eftest.runner/synchronize/fn          runner.clj:   20
                                       clojure.test/do-report            test.clj:  357
     metabase.query-processor-test.timezones-test/fn/fn/fn/fn  timezones_test.clj:   56
           metabase.test.util/do-with-temporary-setting-value            util.clj:  364
        metabase.query-processor-test.timezones-test/fn/fn/fn  timezones_test.clj:   55
metabase.test.data.datasets/do-with-driver-when-testing/fn/fn        datasets.clj:   41
                               metabase.driver/do-with-driver          driver.clj:   75
   metabase.test.data.datasets/do-with-driver-when-testing/fn        datasets.clj:   40
           metabase.test.data.datasets/do-when-testing-driver        datasets.clj:   29
      metabase.test.data.datasets/do-with-driver-when-testing        datasets.clj:   39
           metabase.query-processor-test.timezones-test/fn/fn  timezones_test.clj:   51
                      metabase.test.data.impl/do-with-dataset            impl.clj:  346
              metabase.query-processor-test.timezones-test/fn  timezones_test.clj:   41
                                     clojure.test/test-var/fn            test.clj:  717
                                        clojure.test/test-var            test.clj:  717
                                metabase.test-runner/run-test     test_runner.clj:  129
                                eftest.runner/test-vars/fn/fn          runner.clj:  105
                                 clojure.test/default-fixture            test.clj:  687
                                   eftest.runner/test-vars/fn          runner.clj:   97
                        eftest.runner/wrap-test-with-timer/fn          runner.clj:   38
                                          clojure.core/map/fn            core.clj: 2757
                                             clojure.core/seq            core.clj:  139
                                           clojure.core/dorun            core.clj: 3121
                                   eftest.runner/test-vars/fn          runner.clj:  114
                                 clojure.test/default-fixture            test.clj:  687
                                      eftest.runner/test-vars          runner.clj:  111
                                        eftest.runner/test-ns          runner.clj:  124
                                  eftest.runner/test-all/f/fn          runner.clj:  139
                                          clojure.core/map/fn            core.clj: 2759
                                            clojure.core/next            core.clj:   64
                                         clojure.core/reduce1            core.clj:  946
                                         clojure.core/reduce1            core.clj:  936
                                      clojure.core/merge-with            core.clj: 3063
                                      clojure.core/merge-with            core.clj: 3055
                                           clojure.core/apply            core.clj:  669
                                     eftest.runner/test-all/f          runner.clj:  140
                                       eftest.runner/test-all          runner.clj:  143
                                   eftest.runner/run-tests/fn          runner.clj:  214
                                      eftest.runner/run-tests          runner.clj:  214
                                  metabase.test-runner/run/fn     test_runner.clj:  160
                                  clojure.core/with-redefs-fn            core.clj: 7516
                                           clojure.core/apply            core.clj:  667
                      metabase.test.redefs/new-with-redefs-fn          redefs.clj:   43
                      metabase.test.redefs/new-with-redefs-fn          redefs.clj:   41
                                     metabase.test-runner/run     test_runner.clj:  157
                               metabase.test-runner/run-tests     test_runner.clj:  178
                                           clojure.core/apply            core.clj:  667
                                        clojure.run.exec/exec            exec.clj:   48
                                        clojure.run.exec/exec            exec.clj:   39
                                    clojure.run.exec/-main/fn            exec.clj:  180
                                       clojure.run.exec/-main            exec.clj:  176
                                       clojure.run.exec/-main            exec.clj:  139
                                           clojure.core/apply            core.clj:  667
                                        clojure.main/main-opt            main.clj:  514
                                            clojure.main/main            main.clj:  664
                                            clojure.main/main            main.clj:  616
                                            clojure.main.main           main.java:   40

Hi @adibs6
I'm guessing that you are working in this repo?

Which driver are you basing this off? The old Presto driver or the new PrestoDB JDBC driver?

It looks like it's caused by the driver returning something Clojure thinks is Java Bean.
We encountered same problem during the PrestoDB JDBC driver, so if you built from that, then it should work.

My parent driver is presto-jdbc, so I believe the answer here is, the new PrestoDB JDBC driver.

I have only overridden certain date methods. Can you point me to the fix that was put in place for the presto driver? If it was fixed for Presto, I would assume it should work for Trino as well because both exception classes look very similar beyond being in different Java packages.

I believe this might be a problem with the Trino JDBC driver. FailureException extends RuntimeException which implements Serializable. However, FailureException itself is not actually Serializable. So because it's incorrectly advertised as serializable Clojure tries to pretty-print it when you encounter itand runs into an error doing so. I'd suggest opening an upstream bug with the Trino JDBC driver authors.

See also this thread on the Clojurians Slack https://clojurians-log.clojureverse.org/sql/2019-05-12/1557660307.183300 -- someone suggested using reflection to make that member public to work around the upstream bug

Thanks for the info. I will look into that fix.

Furthermore, are the Presto tests working? If so, I assume this reflection hack was already implemented for Presto, but I couldn't find it. If you have any code pointers to that fix, let me know.

Presto tests are working. I think we worked around that issue in some other way or waited for Facebook to fix it upstream. I can't find code related to it either, I know we ran into it some point but I'm not sure what we did to work around it.

1 Like