opensearch-project / opensearch-project/sql-jdbc

[BUG] Unable to set a custom AWSCredentialsProvider instance

Open
#122 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
28
Forks
39
PR merge metrics
No merged PRs in 30d

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:

  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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in org.opensearch.jdbc.config.ConnectionConfig.Builder.setProperties, focusing on how the awsCredentialsProvider property is retrieved and validated. Reproduce the documented custom AWSCredentialsProvider example with DriverManager.getConnection. Done means the provider instance is passed through without a NullPointerException or ConnectionPropertyException.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.