archaius
archaius copied to clipboard
Can not address the Array in the configuration
Hi there, Using archaius-core version 0.7.3, I created a YAMLConfigurationSource myself to load the configuration from YAML file. In YAML, the List is support like this:
required:
- appId
- serviceName
- version
- status
It is OK to load these values into an List and get them in the fist time. However, I got error after a while:
[2017-03-28 15:11:22,691/GMT+08:00][pollingConfigurationSource][ERROR]Error occured applying properties com.netflix.config.AbstractPollingScheduler$1.run(AbstractPollingScheduler.java:174)
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String
at com.netflix.config.DynamicPropertyUpdater.addOrChangeProperty(DynamicPropertyUpdater.java:134)
at com.netflix.config.AbstractPollingScheduler.populateProperties(AbstractPollingScheduler.java:111)
at com.netflix.config.AbstractPollingScheduler$1.run(AbstractPollingScheduler.java:172)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
The reason is in the "DynamicPropertyUpdater.java", it is assumed the List is described in a String and trying to assemble the List by split that String:
if(e instanceof CopyOnWriteArrayList && AbstractConfiguration.getDefaultListDelimiter() != 0) {
newValueArray = new CopyOnWriteArrayList();
Iterable stringiterator = Splitter.on(AbstractConfiguration.getDefaultListDelimiter()).omitEmptyStrings().trimResults().split((String)newValue);
Iterator i$ = stringiterator.iterator();
So basically, the real List is not considered currently. Any idea how to make it supported?
I think it is always assumes a simple delimited string. There is some related discussion in #266 and #360.