smallrye-config icon indicating copy to clipboard operation
smallrye-config copied to clipboard

Add AtomicInteger and AtomicLong converter

Open Emily-Jiang opened this issue 4 years ago • 7 comments

As a developer, I would like to have the out of box converters for AtomicInteger and AtomicLong so that I can directly convert a string to these types. I can do the following without doing anything else.

config.getValue("atomic.integer.prop", AtomicInteger.class) config.getValue("atomic.long.prop", AtomicLong.class)

Emily-Jiang avatar Sep 30 '20 10:09 Emily-Jiang

Is this a real-world requirement or an idea? I think normally we'd want to discourage conversion to classes expressly designed for concurrent mutability.

dmlloyd avatar Sep 30 '20 12:09 dmlloyd

In Open Liberty, we have some apps using this and we offer our end users in our own implementation in the past. From now on, we plan to consume SmallRye Config and would like to maintain the capabilities. Besides, I don't see the drawback you mentioned as the type clearly specify the type though. By the way, Archaius Config supports this converter as well.

Emily-Jiang avatar Sep 30 '20 12:09 Emily-Jiang

I'm wondering if we should try to keep the core "clean" with just the most common converters and add another module with other type of converters.

We already have a submodule for this reason and the truth is that the great majority of users probably won't use these type of converters. For Liberty, you could just add the extra dependency.

radcortez avatar Sep 30 '20 18:09 radcortez

Sounds good! Which submodule are you referring to? I am thinking about SPI so that the consumer can provide more converters if they need.

Emily-Jiang avatar Sep 30 '20 22:09 Emily-Jiang

In here: https://github.com/smallrye/smallrye-config/tree/master/converters

Anyway, as you remember, I was trying to work on an external Converters project, to maybe even propose as spec, so this may be one more reason to separate the code.

radcortez avatar Oct 01 '20 11:10 radcortez

ah, I see. These converters will be like application provided converters and use service loader patter to be loaded.

Emily-Jiang avatar Oct 02 '20 16:10 Emily-Jiang

Yes :)

radcortez avatar Oct 06 '20 11:10 radcortez