Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Datasource binging in VCAP_SERVICES result in multiple DataSources

Open
#103 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java, mysql
Domain
backend, databases

Research direction

Start by inspecting the stack-trace locations in CfJdbcUrlCreator.java and CfJdbcEnv.java, then reproduce the issue with the VCAP_SERVICES example containing the oracle-mysql label and vmaasBrokerMySql name. Done means the binding no longer produces duplicate database services and the resulting datasource selection is covered by a regression test.

Written by the indexing model from the issue text.

Description

bug

So far we are using the Spring Cloud Connector with a datasource in VCAP_SERVICES like this:

  "oracle-mysql": [
    {
      "label": "oracle-mysql",
      "provider": null,
      "plan": "production",
      "name": "vmaasBrokerMySql",
      "tags": [
        "database",
        "mysql"
      ],
      "instance_name": "vmaasBrokerMySql",
      "binding_name": null,
      "credentials": {
        "hostname": "xx.xx.xx.xx",
        "password": "password",
        "readonly": false,
        "port": 38010,
        "dbschema-name": "db_name",
        "uri": "mysql://username:[email protected]:38010/db_name?connectTimeout=20000&useSSL=true&verifyServerCertificate=false",
        "username": "username"
      },
      "syslog_drain_url": null,
      "volume_mounts": []
    }
  ]

With Spring Cloud Connector this has worked the way that one DataSource was returned by the CloudConfig. When we try to switch to java-cfenv this doesn't work any more as the datasource binding end up with two datasources, one based on the label and one based on the name. At the end we receive an exception as below:

2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] Caused by: java.lang.IllegalArgumentException: No unique database service found. Found database service names [vmaasBrokerMySql, vmaasBrokerMySql]
2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] at io.pivotal.cfenv.jdbc.CfJdbcUrlCreator.throwExceptionIfMultipleMatches(CfJdbcUrlCreator.java:97)
2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] at io.pivotal.cfenv.jdbc.CfJdbcUrlCreator.findJdbcService(CfJdbcUrlCreator.java:87)
2020-10-21T14:35:51.564+02:00 [APP/PROC/WEB/0] [OUT] at io.pivotal.cfenv.jdbc.CfJdbcEnv.findJdbcService(CfJdbcEnv.java:46)

From my perspective either the first datasource created should be returned (then it would need a order which defines the preference) or the decision is not made based on name/labels, but the URI itself, as this would clearly distinguish between Oracle and MySQL.

Dominant language
Java
Stars
97
Forks
64
Avg merge
6h 36m
Merged PRs (30d)
6

Getting set up

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.

More from pivotal-cf/java-cfenv

All issues in pivotal-cf/java-cfenv

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.