There is a difference between mariadb and mysql concerning session state tracking.
MySQL OK_Packet server_status flag may have value SERVER_SESSION_STATE_CHANGED set *ONLY * when client has set capability CLIENT_SESSION_TRACK.
MariaDB may set value SERVER_SESSION_STATE_CHANGED whatever client CLIENT_SESSION_TRACK capability has been set.
This difference has impacts: Recent version of mysql java connector rely only on server status flag value SERVER_SESSION_STATE_CHANGED to read session state additional bytes. Connector then try to read bytes that doesn't exist in packet when a session state change (only workaround is to enable mysql connector option `trackSessionState`).
proposed patch joined (tested)