Skip to content

aws-xray-recorder-sdk-sql has incorrect implementations for isWrapperFor #130

Description

@chamsco-aws

In the merge #104 we added the TracingDataSource and the TracingConnection classes. In those classes the implementation of isWrapperFor and unwrap is flawed

https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-sql/src/main/java/com/amazonaws/xray/sql/TracingConnection.java#L309-L317

https://github.com/aws/aws-xray-sdk-java/blob/master/aws-xray-recorder-sdk-sql/src/main/java/com/amazonaws/xray/sql/TracingDataSource.java#L48-L56

Right now you can not test using those methods if the tracing connection or datasource was applied. The correct implementation would be

    @Override
    @SuppressWarnings("unchecked")
    public <T> T unwrap(Class<T> iface) throws SQLException {
        if (iface.isInstance(this)) {
            return (T) this;
        }
        return delegate.unwrap(iface);
    }

    @Override
    public boolean isWrapperFor(Class<?> iface) throws SQLException {
        return (iface.isInstance(this) || delegate.isWrapperFor(iface);
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions