You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "Rastislav Papp (Jira)" <ji...@apache.org> on 2021/06/24 12:30:00 UTC

[jira] [Updated] (KARAF-7187) cfg file layout is destoyed when reinstalling existing feature

     [ https://issues.apache.org/jira/browse/KARAF-7187?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rastislav Papp updated KARAF-7187:
----------------------------------
    Description: 
Let's say we have a cfg file, which is part of a feature (via {{<config external="true" override="true">}}). 
 When we install the feature installed for the first time, this file is created under /etc directory. When I uninstall the feature, the file is kept, and when I install it again, the file gets broken - it's layout is destroyed and all property placeholders inside are replaced with actual values - which could be a problem (i.e. when updating the value of the placeholder).

To illustrate, let's say we have this cfg file:
{code:java}
property1=value1
property2=\
   xxx${property1}yyy\
   continuing the value on another line
{code}
After uninstalling and reinstalling a feature which overwrites this file, the result is:
{code:java}
property1=value1
property2=xxxvalue1continuing the value on another line
{code}
which is not at all good:
 * when updating value of property1, and expecting that property2 will change accordingly
 * multiline formatting is lost

The culprint is {{org.apache.karaf.features.internal.service.FeatureConfigInstaller#updateExistingConfig}}, line:
{code:java}
properties.put(key, comments, value);
{code}
which eventually calls {{org.apache.felix.utils.properties.Properties#put(java.lang.String, java.util.List<java.lang.String>, java.lang.String)}}, causing the original {{Layout}} to be lost:
{code:java}
this.layout.put(key, new Layout(commentLines, null));
{code}

  was:
Let's say we have a cfg file, which is part of a feature (via <config external="true" override="true">. 
When we install the feature installed for the first time, this file is created under /etc directory. When I uninstall the feature, the file is kept, and when I install it again, the file gets broken - it's layout is destroyed and all property placeholders inside are replaced with actual values - which could be a problem (i.e. when updating the value of the placeholder). 

To illustrate, let's say we have this cfg file:
{code}
property1=value1
property2=\
   xxx${property1}yyy\
   continuing the value on another line
{code}

After uninstalling and reinstalling a feature which overwrites this file, the result is:
{code}
property1=value1
property2=xxxvalue1continuing the value on another line
{code}
which is not at all good:
* when updating value of property1, and expecting that property2 will change accordingly
* multiline formatting is lost

The culprint is {{org.apache.karaf.features.internal.service.FeatureConfigInstaller#updateExistingConfig}}, line:
{code:java}
properties.put(key, comments, value);
{code}
which eventually calls {{org.apache.felix.utils.properties.Properties#put(java.lang.String, java.util.List<java.lang.String>, java.lang.String)}}, causing the original {{Layout}} to be lost:
{code:java}
this.layout.put(key, new Layout(commentLines, null));
{code}


> cfg file layout is destoyed when reinstalling existing feature
> --------------------------------------------------------------
>
>                 Key: KARAF-7187
>                 URL: https://issues.apache.org/jira/browse/KARAF-7187
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf
>    Affects Versions: 4.3.2
>            Reporter: Rastislav Papp
>            Priority: Major
>
> Let's say we have a cfg file, which is part of a feature (via {{<config external="true" override="true">}}). 
>  When we install the feature installed for the first time, this file is created under /etc directory. When I uninstall the feature, the file is kept, and when I install it again, the file gets broken - it's layout is destroyed and all property placeholders inside are replaced with actual values - which could be a problem (i.e. when updating the value of the placeholder).
> To illustrate, let's say we have this cfg file:
> {code:java}
> property1=value1
> property2=\
>    xxx${property1}yyy\
>    continuing the value on another line
> {code}
> After uninstalling and reinstalling a feature which overwrites this file, the result is:
> {code:java}
> property1=value1
> property2=xxxvalue1continuing the value on another line
> {code}
> which is not at all good:
>  * when updating value of property1, and expecting that property2 will change accordingly
>  * multiline formatting is lost
> The culprint is {{org.apache.karaf.features.internal.service.FeatureConfigInstaller#updateExistingConfig}}, line:
> {code:java}
> properties.put(key, comments, value);
> {code}
> which eventually calls {{org.apache.felix.utils.properties.Properties#put(java.lang.String, java.util.List<java.lang.String>, java.lang.String)}}, causing the original {{Layout}} to be lost:
> {code:java}
> this.layout.put(key, new Layout(commentLines, null));
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)