Skip to content

[BUG] Unable to set a custom AWSCredentialsProvider instance #122

Open
@SamuelKinnettNC

Description

@SamuelKinnettNC

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:

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions