r2dbc-proxy
r2dbc-proxy copied to clipboard
`DefaultConnectionInfo.getConnectionId()` can return `null`
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()