Skip to content

[BUG] Driver.connect fails with "Multiple entries with same key" when a parameter is present in both the JDBC URL and Properties #1648

Description

@dgr-dbeaver

Describe the bug

Driver.connect(url, properties) throws java.lang.IllegalArgumentException: Multiple entries with same key
when any connection parameter (e.g. httpPath, PWD) is specified both in the JDBC URL and in the
Properties object — even if the values are identical.

Root cause: DatabricksConnectionContext.buildPropertiesMap puts URL parameters and Properties entries
into a single Guava ImmutableMap.Builder, and build() throws on any duplicate key instead of resolving
it. Most JDBC drivers (and the legacy Simba-based Databricks driver) resolve such duplicates with a defined
precedence instead of failing.

This breaks a common real-world flow: the user pastes a full JDBC URL (which already contains httpPath
and PWD) into a BI tool, and the tool's authentication form passes the same parameters via Properties.

To Reproduce

String url = "jdbc:databricks://test.com:443/default;transportMode=http;ssl=1;AuthMech=3;httpPath=/sql/1.0/warehouses/abc123def456;UID=token;PWD=pwd123";

Properties props = new Properties();
props.setProperty("httpPath", "/sql/1.0/warehouses/abc123def456"); // same value as in the URL
props.setProperty("PWD", "pwd123");                                // same value as in the URL

new com.databricks.client.jdbc.Driver().connect(url, props);

Expected behavior

The connection opens. Duplicated parameters are resolved with a documented precedence
(e.g. Properties override URL parameters, or vice versa) instead of throwing.
A one-line fix would be ImmutableMap.Builder#buildKeepingLast() in
DatabricksConnectionContext.buildPropertiesMap.

Client side logs

java.lang.IllegalArgumentException: Multiple entries with same key: pwd=pwd123 and pwd=pwd123
    at com.google.common.collect.ImmutableMap.conflictException(ImmutableMap.java:382)
    at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:376)
    at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:246)
    at com.google.common.collect.RegularImmutableMap.fromEntryArrayCheckingBucketOverflow(RegularImmutableMap.java:135)
    at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:97)
    at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:579)
    at com.google.common.collect.ImmutableMap$Builder.buildOrThrow(ImmutableMap.java:607)
    at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:594)
    at com.databricks.jdbc.api.impl.DatabricksConnectionContext.buildPropertiesMap(DatabricksConnectionContext.java:133)
    at com.databricks.jdbc.api.impl.DatabricksConnectionContext.parse(DatabricksConnectionContext.java:176)
    at com.databricks.jdbc.api.impl.DatabricksConnectionContextFactory.create(DatabricksConnectionContextFactory.java:20)
    at com.databricks.client.jdbc.Driver.connect(Driver.java:56)
...

Client Environment (please complete the following information):

  • OS: Linux
  • Java version: Java 21
  • Java vendor: OpenJDK
  • Driver Version: 3.4.1 (also reproducible with 3.4.2 — buildPropertiesMap is unchanged)

Additional context

The failure happens for any duplicated key, with identical values as well as different ones.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions