Luca Burgazzoli created CAMEL-13860:
---------------------------------------

             Summary: camel-properties: get[Inital|Override]Properties should 
never return null
                 Key: CAMEL-13860
                 URL: https://issues.apache.org/jira/browse/CAMEL-13860
             Project: Camel
          Issue Type: Improvement
          Components: camel-properties
            Reporter: Luca Burgazzoli
            Assignee: Luca Burgazzoli
             Fix For: 3.0.0, 3.0.0.RC1


The properties component allow to set initial and override properties but as 
the methods to access such properties can return null, used may end up writing 
things like:

{code:java}
@Override
    public void addProperties(Properties properties) {
        PropertiesComponent pc = context.getComponent("properties", 
PropertiesComponent.class);
        Properties props = pc.getInitialProperties();

        if (props == null) {
            props = new Properties();

            pc.setInitialProperties(props);
        } else {
            props.putAll(properties);
        }
    }

    @Override
    public void addProperty(String key, Object value) {
        PropertiesComponent pc = context.getComponent("properties", 
PropertiesComponent.class);
        Properties props = pc.getInitialProperties();

        if (props == null) {
            props = new Properties();
            props.put(key, value);

            pc.setInitialProperties(props);
        } else {
            props.put(key, value);
        }
    }
{code}

We can implement such lazy initialization logic in the component property 
itself.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Reply via email to