vert-x3 / vertx-config

Vert.x Configuration Service
Apache License 2.0
54 stars 64 forks source link

config().getString is not perfect #124

Closed sunqb closed 3 years ago

sunqb commented 3 years ago

Question

when i do not use "put("raw-data", true)" ,if my config is : password=123456

I get a value "123456.0" by this method config.getString("password");

but

when I use "put("raw-data", true)", this problem is ok ,but i have an other config port=80

I get an error when i use config.getInteger("port"),because it was not supported.

Version

4.0.2

the link is from https://github.com/eclipse-vertx/vert.x/issues/3816

vietj commented 3 years ago

can you provide an accurate reproducer ?

sunqb commented 3 years ago

can you provide an accurate reproducer ?

OK。like this:

config code :

private static ConfigRetrieverOptions initOptions() {

    ConfigRetrieverOptions options = new ConfigRetrieverOptions().setIncludeDefaultStores(true);

    options.setScanPeriod(-1);
    // raw-data
    options.addStore(new ConfigStoreOptions().setType("file").setFormat("properties").setOptional(true)
            .setConfig(new JsonObject().put("path", "conf/config.properties").put("raw-data", true)));

    options.getStores().forEach(store -> store.getConfig().put("cache", "false"));

    return options;
}

properties content:

web.mysql.host=10.10.14.59 web.mysql.port=3306 web.mysql.db=hq_usp_studyfun_bf_nh web.mysql.user=root web.mysql.password=123456

comment:

when i do not use put("raw-data", true) . i can't use config().getString("web.mysql.password"),because i get a value "123456.0" ,i expect to get "123456"

if i use ("raw-data", true) . i can only use config().getString("web.mysql.password"). i can't use config().getInteger("web.mysql.port").

sunqb commented 3 years ago

@vietj if I change config file from config.properties to config.json。it works well。so i think this may by a bug,when i use properties

vietj commented 3 years ago

can you find out what is the actual issue ?

sunqb commented 3 years ago

can you find out what is the actual issue ?

yes the problem is JsonObjectHelper.convert(String value) ,please look below ,and do you have any other considerations ????

image

image

sunqb commented 3 years ago

@vietj the function should give a chioce ,i think.

eg: store more data of this value, when i use getString ,return "123456" , when i use getDoule, return 123456.0 , when i use getInteger , return 123456

sunqb commented 3 years ago

@vietj i use spi to solve this problem , do you want to fix this problem at vertx 4.0.3 ?

vietj commented 3 years ago

yes we do.

On Thu, Feb 25, 2021 at 2:47 AM sunqb notifications@github.com wrote:

@vietj https://github.com/vietj i use spi to solve this problem , do you want to fix this problem at vertx 4.0.3 ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vert-x3/vertx-config/issues/124#issuecomment-785514976, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABXDCT7U3NRI7QCKYALEETTAWT4BANCNFSM4YAJFZXQ .