chitralverma opened a new issue, #9312:
URL: https://github.com/apache/opendal/issues/9312
### OpenDAL version or commit
main (4ae8e6122)
### Affected service or component
bindings/java (generated `ServiceConfig`), checked with services/s3
### Describe the bug
`ServiceConfig.configMap()` merges the entries of map-valued fields into the
top-level config map with `map.putAll(...)`, which `make_populate_map` in
`dev/src/generate/java.rs` emits. Core therefore never receives
`assume_role_session_tags` or `options`. Each entry becomes a service option of
its own: the service ignores unknown keys, and a key that matches another
option after lowercasing, such as `Region`, competes with that option.
### Steps to Reproduce
```java
Map<String, String> tags = new HashMap<>();
tags.put("Region", "eu-west-1");
ServiceConfig.S3 cfg = ServiceConfig.S3.builder()
.bucket("b")
.region("us-east-1")
.accessKeyId("AKIDEXAMPLE")
.secretAccessKey("secret")
.disableConfigLoad(true)
.assumeRoleSessionTags(tags)
.build();
System.out.println(new TreeMap<>(cfg.configMap()));
for (int i = 0; i < 16; i++) {
try (AsyncOperator op = AsyncOperator.of(cfg)) {
// Print the region in the X-Amz-Credential scope of the presigned
URL.
System.out.println(op.presignRead("k",
Duration.ofSeconds(60)).join().getUri());
}
}
```
### Actual Behavior
- `configMap()` is `{Region=eu-west-1, access_key_id=AKIDEXAMPLE, bucket=b,
disable_config_load=true, region=us-east-1, secret_access_key=secret}`. It has
no `assume_role_session_tags` entry.
- Over 16 constructions in one JVM, 3 presigned URLs were signed for
`eu-west-1` and 13 for `us-east-1`. `Operator::via_iter` lowercases option keys
into a hash map, so whichever of `Region` and `region` comes last wins.
- `ServiceConfig.HdfsNative` with `options` = `{fs.defaultFS=hdfs://ns}`
gives `configMap()` = `{fs.defaultFS=hdfs://ns, name_node=default}`.
`hdfs-native` reads Hadoop settings only from `options`, so it ignores the
top-level `fs.defaultFS` key.
### Expected Behavior
Since #9262, core reads a map-valued option from a JSON object string.
`configMap()` should emit one entry per map field, for example
`assume_role_session_tags` = `{"Region":"eu-west-1"}`, and leave the other
options unchanged.
### Additional Context
- Follow-up to #9261 (closed) and #9262. #9261 listed the Java generator as
a follow-up. It said that a tag `Region` next to `region` fails with `duplicate
field`. That holds for `Configurator::from_iter`, but the Java binding builds
operators through `Operator::via_iter`, where one value silently wins.
- Proposed fix: `make_populate_map` emits `map.put("<key>", <JSON object of
the field>)` through a small package-private encoder. The binding has no
runtime dependencies, and the JDK has no JSON encoder. The `configMap()` output
changes for these two fields, so the PR will declare the change under "Breaking
changes" for `bindings/java`.
- Reproduced on macOS with JDK 21 and a local native build that left out
`services-etcd`, because `protoc` was not installed. The S3 path does not use
etcd.
- The default Java native library does not enable `services-hdfs-native`, so
the `HdfsNative` case is shown through `configMap()` only. S3 session tags were
not tested against AWS STS.
### Reproduction confirmation
- [x] I reproduced this issue against the affected component. For a
service-specific report, I used the actual service rather than only a mock,
emulator, or source-code analysis.
### Are you willing to submit a PR to fix this bug?
- [x] Yes, I would like to submit a PR.
*Drafted with AI assistance (Claude Code, Claude Opus 5.5) and reviewed by
the author.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]