Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultConnectionInfo.getConnectionId() can return null #151

Open
gsson opened this issue Aug 5, 2024 · 0 comments
Open

DefaultConnectionInfo.getConnectionId() can return null #151

gsson opened this issue Aug 5, 2024 · 0 comments

Comments

@gsson
Copy link

gsson commented Aug 5, 2024

Bug Report

Versions

r2dbc-proxy 1.1.5

Current Behavior

When calling getConnectionInfo() in a ProxyExecutionListener#beforeMethod() when create() is called, a non-null DefaultConnectionInfo is returned containing a null connectionId.

This is confusing since it implements the ConnectionInfo interface and should be a @NonNullApi, and ConnectionInfo.getConnectionId() isn't marked with @Nullable.

Steps to reproduce

Input Code
public class ProxyExecutionListenerImpl implements ProxyExecutionListener {
  @Override
  public void beforeMethod(MethodExecutionInfo executionInfo) {
    var connectionInfo = executionInfo.getConnectionInfo();
    if (connectionInfo != null) {
      var connectionId = connectionInfo.getConnectionId();
      Objects.requireNonNull(connectionId);
    }
  }
}

Expected behavior/code

Either initialize the ConnectionInfo with a valid connectionId or a @Nullable annotation plus adjustments to the JavaDoc

Possible Solution

Create the connectionId earlier in ConnectionFactoryCallbackHandler#invoke()

@gsson gsson changed the title DefaultConnectionInfo.getConnectionId() can return null DefaultConnectionInfo.getConnectionId() can return null Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant