Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Converter registered for interface java.util.Map #8017

Closed
ecmrauh opened this issue Mar 20, 2020 · 6 comments
Closed

No Converter registered for interface java.util.Map #8017

ecmrauh opened this issue Mar 20, 2020 · 6 comments
Labels
area/config kind/bug Something isn't working triage/invalid This doesn't seem right

Comments

@ecmrauh
Copy link

ecmrauh commented Mar 20, 2020

Describe the bug
I don't know if it is a bug or a missing feature (or just my fault). I try to use a Map<String, String> as configuration value. I created a custom converter as described here. The example with the int works, using a Map fails.

Expected behavior
It should possible to use a Map as configuration value.

Actual behavior
An exception is thrown (java.lang.IllegalArgumentException: No Converter registered for interface java.util.Map).

But the converter is present and it is used with e.g. ints and doubles.

To Reproduce
Steps to reproduce the behavior:

  1. Setup a minimal example like this one and change int to Map<String, String>.
  2. Inject the config and try to use the value.

Configuration

My final goal is to use something like:

config.global.setting = value
config.tenant-map.param1 = xxx
config.tenant-map.param1 = yyy

Environment (please complete the following information):

  • Output of uname -a:
    Linux debian 5.4.0-0.bpo.3-amd64 Switch to the Maven distributed copy of the SubstrateVM annotations #1 SMP Debian 5.4.13-1~bpo10+1 (2020-02-07) x86_64 GNU/Linux

  • Output of java -version:
    openjdk version "11.0.6" 2020-01-14
    OpenJDK Runtime Environment (build 11.0.6+10-post-Debian-1deb10u1)
    OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Debian-1deb10u1, mixed mode, sharing)

  • Quarkus version: 1.2.1-Final and 1.3.0-Final

  • Build tool (mvn --version):
    Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
    Java version: 11.0.6, vendor: Debian, runtime: /usr/lib/jvm/java-11-openjdk-amd64
    Default locale: de_DE, platform encoding: UTF-8
    OS name: "linux", version: "5.4.0-0.bpo.3-amd64", arch: "amd64", family: "unix"

Additional context

The example descriped here works, but changing Double to Map<String, String> fails.

This issue might be similar to #7856.

@ecmrauh ecmrauh added the kind/bug Something isn't working label Mar 20, 2020
@geoand
Copy link
Contributor

geoand commented Mar 20, 2020

I think this behavior is by design, but I am not 100% sure, so let's ask the expert @dmlloyd

@dmlloyd
Copy link
Member

dmlloyd commented Mar 20, 2020

You're essentially hitting two different problems here. One is that MicroProfile Config does not support generic converter types; Map is a generic type, having two type parameters. The other is that converters only apply to single string values - they cannot be used to aggregate values from multiple properties without special support from the runtime.

@geoand
Copy link
Contributor

geoand commented Mar 20, 2020

I'm going to close this as invalid. Feel free to reopen if you feel it's not been adequately covered

@geoand geoand closed this as completed Mar 20, 2020
@geoand geoand added the triage/invalid This doesn't seem right label Mar 20, 2020
@ecmrauh
Copy link
Author

ecmrauh commented Mar 20, 2020

Thanks for your quick response! I wasn't aware of that. After reading issues like e.g. this one, I thought it would be possible somehow. If not, I will have to live with that... 😕

@dmlloyd
Copy link
Member

dmlloyd commented Mar 20, 2020

We have special support for it within our Quarkus configuration code, which is separate from the standard CDI-based stuff. Really I think the MP Config spec needs a bit of a rethink in this area though. My first step in this direction is eclipse/microprofile-config#545.

@ecmrauh
Copy link
Author

ecmrauh commented Mar 20, 2020

Thanks for the clarification and your efforts!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config kind/bug Something isn't working triage/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants