Uploaded image for project: 'Red Hat build of Keycloak'
  1. Red Hat build of Keycloak
  2. RHBK-2962

PersistenceExceptionConverter#convert NPE if SQLState is null [GHI#38467]

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False

      Before reporting an issue

      [x] I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

      Area

      storage

      Describe the bug

      The method org.keycloak.connections.jpa.PersistenceExceptionConverter#convert inspects Throwable objects in order to wrap the exception; one of the checks it does is

      throwable instanceof SQLException bue && bue.getSQLState().startsWith("23")
      

      I have observed during AWS MySQL RDS failovers that SQLException}}s can be throw that have a {{null response to getSQLState causing this method to throw an NPE rather than the expected model exception classes

      Version

      26.0.1

      Regression

      [ ] The issue is a regression

      Expected behavior

      a ModelException instance is thrown

      Actual behavior

      a NullPointerException instance is thrown

      How to Reproduce?

      I'm sure there is a simpler way, but the way I have reproduced the issue

      • create an AWS MySQL RDS instance across availability zones
      • deploy keycloak pointing at above RDS instance for database
      • log in to keycloak and click around admin console a bit to make sure some mysql connections are in the pool
      • use AWS RDS console to restart (with failover) the RDS instance

      Anything else?

      No response

              Unassigned Unassigned
              pvlha Pavel Vlha
              Keycloak Core (shared)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: