Skip to content

Bug Report: Connection proxy returned by unwrap() throws UndeclaredThrowableException instead of SQLException #8487

Open

Description

@Timmeeeey

Brief Summary

The InvocationHandler in ConnectionHolder40.getProxyObject doesn't unwrap InvocationTargetException:

return method.invoke(actualObject, args);

As a result, every SQLException thrown by a method on the connection returned by unwrap(OracleConnection.class) (or any other vendor interface) arrives as an UndeclaredThrowableException, so catch (SQLException e) doesn't catch it.

This is the same bug as #216, which was fixed only in ProfiledConnectionWrapper40.

Expected Outcome

The driver's SQLException is rethrown unchanged:

try {
    return method.invoke(actualObject, args);
} catch (InvocationTargetException e) {
    throw e.getCause();
}

Current Outcome

An UndeclaredThrowableException is thrown, wrapping an InvocationTargetException that wraps the original SQLException.

Reproducer

Oracle pool, ojdbc17 23.26.2.0.0:

try (Connection con = dataSource.getConnection()) {
    OracleConnection ora = con.unwrap(OracleConnection.class);
    ora.setTransactionIsolation(12345); // expected: SQLException ORA-17030, actual: UndeclaredThrowableException
}

Operating System

Windows 11 Pro

JDK Version

Adoptium jdk-21.0.8.9-hotspot

Payara Distribution

Payara Server Full Profile

Activity

  1. added
    Type: BugLabel issue as a bug defect
    Status: OpenIssue has been triaged by the front-line engineers and is being worked on verification
    on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Status: OpenIssue has been triaged by the front-line engineers and is being worked on verificationType: BugLabel issue as a bug defect

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions