-
Notifications
You must be signed in to change notification settings - Fork 31
[BUG] Unable to set a custom AWSCredentialsProvider instance #122
Description
What is the bug?
In the examples, the following code is given to illustrate using a custom AWSCredentialsProvider instance with the driver:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
String url = "jdbc:opensearch://https://remote-host-name";
Properties properties = new Properties();
properties.put("awsCredentialsProvider", new EnvironmentVariableCredentialsProvider());
Connection con = DriverManager.getConnection(url, properties);
Statement st = con.createStatement();
// use the connection
// close connection
con.close();However, in practice this causes a null pointer exception in the setProperties function of the org.opensearch.jdbc.config.ConnectionConfig.Builder class because the getProperty method is used, which returns null if the property value is not a string. If a string is specified instead, a org.opensearch.jdbc.config.ConnectionPropertyException exception is thrown because it's expecting an AWSCredentialsProvider instance and not a string.
How can one reproduce the bug?
Steps to reproduce the behavior:
- Implement the custom AWSCredentialsProvider example
What is the expected behavior?
The AWSCredentialsProvider instance should be correctly passed through to the driver.
What is your host/environment?
- OS: Manjaro Linux x86_64 (Kernel 6.1.71-1-MANJARO)
- JDK: 11