Allow default constructor for seed providers
--------------------------------------------

                 Key: CASSANDRA-3866
                 URL: https://issues.apache.org/jira/browse/CASSANDRA-3866
             Project: Cassandra
          Issue Type: Improvement
          Components: Core
    Affects Versions: 1.0.7
            Reporter: Chris Lohfink
            Priority: Trivial
         Attachments: DnsSeedProvider.java, patch.txt

Would be nice for cases where you do not have any parameters.  ie if you have a 
simple custom seed provider.  In that scenario you will not provide a 
parameters argument to the seed_provider (since using default constructor):

{code}
seed_provider:
    - class_name: foo.bar.DnsSeedProvider
{code}

This causes an exception

{code:java}ERROR 11:57:06,744 Fatal configuration error error 
Can't construct a java object for 
tag:yaml.org,2002:org.apache.cassandra.config.Config; exception=Cannot create 
property=seed_provider for JavaBean=org.apache.cassandra.config.Config@3c50507; 
java.lang.reflect.InvocationTargetException 
in "<reader>", line 10, column 1: 
cluster_name: 'Test Cluster' 
^

at 
org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:372)
 
at 
org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:177)
 
at 
org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:136)
 
at 
org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:122)
 
at org.yaml.snakeyaml.Loader.load(Loader.java:52) 
at org.yaml.snakeyaml.Yaml.load(Yaml.java:166) 
at 
org.apache.cassandra.config.DatabaseDescriptor.<clinit>(DatabaseDescriptor.java:133)
 
at 
org.apache.cassandra.service.AbstractCassandraDaemon.setup(AbstractCassandraDaemon.java:125)
 
at com.datastax.bdp.server.DseDaemon.setup(DseDaemon.java:89) 
at 
org.apache.cassandra.service.AbstractCassandraDaemon.init(AbstractCassandraDaemon.java:238)
 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 
at java.lang.reflect.Method.invoke(Method.java:597) 
at org.apache.commons.daemon.support.DaemonLoader.load(DaemonLoader.java:212) 
Caused by: org.yaml.snakeyaml.error.YAMLException: Cannot create 
property=seed_provider for JavaBean=org.apache.cassandra.config.Config@3c50507; 
java.lang.reflect.InvocationTargetException 
at 
org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:305)
 
at 
org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.construct(Constructor.java:184)
 
at 
org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:370)
 
... 14 more 
Caused by: org.yaml.snakeyaml.error.YAMLException: 
java.lang.reflect.InvocationTargetException 
at 
org.yaml.snakeyaml.constructor.Constructor$ConstructSequence.construct(Constructor.java:589)
 
at 
org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:177)
 
at 
org.yaml.snakeyaml.constructor.Constructor$ConstructMapping.constructJavaBean2ndStep(Constructor.java:298)
 
... 16 more 
Caused by: java.lang.reflect.InvocationTargetException 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
 
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
 
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
at 
org.yaml.snakeyaml.constructor.Constructor$ConstructSequence.construct(Constructor.java:587)
 
... 18 more 
Caused by: java.lang.NullPointerException 
at org.apache.cassandra.config.SeedProviderDef.<init>(SeedProviderDef.java:34) 
... 23 more
{code}

If you then add parameters you get a java.lang.NoSuchMethodException.  The 
workaround being you create a constructor that takes a Map argument, set the 
parameters to anything and ignore them, which is fine but then has to be 
documented as they are options that do not mean anything.  Would be nice to 
make the parameters optional.  I attached a very simple example and a patch 
that I think would work.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to