Return-Path: X-Original-To: apmail-felix-users-archive@minotaur.apache.org Delivered-To: apmail-felix-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 80BEC10F6B for ; Tue, 26 Nov 2013 10:53:02 +0000 (UTC) Received: (qmail 63339 invoked by uid 500); 26 Nov 2013 10:53:00 -0000 Delivered-To: apmail-felix-users-archive@felix.apache.org Received: (qmail 63064 invoked by uid 500); 26 Nov 2013 10:52:56 -0000 Mailing-List: contact users-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@felix.apache.org Delivered-To: mailing list users@felix.apache.org Received: (qmail 63056 invoked by uid 99); 26 Nov 2013 10:52:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Nov 2013 10:52:55 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bengt.rodehav@gmail.com designates 209.85.160.41 as permitted sender) Received: from [209.85.160.41] (HELO mail-pb0-f41.google.com) (209.85.160.41) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Nov 2013 10:52:50 +0000 Received: by mail-pb0-f41.google.com with SMTP id jt11so7817054pbb.28 for ; Tue, 26 Nov 2013 02:52:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=GHZaIfzsQ2NX3ztIda4xP4Sjfy5CRgkn3VD4IZ9wKUA=; b=Y88R+IsoPfNYzJ06L1o3UzFaxSc/M4Uxe8RiECNbtQICQFlmRjP38HewGimD5jpOVC nDEIjznQZhdXVoguwGZ3skXkQmhbSzp0K++Px44kL+LRt14sphZBv8n+ti1ggN6k9fsN 9Hup5GF3A/m7JR6ycKnLkNZCIEWthd7yRRK1nkjrqhBdlFTQmIVMjx+QeKmfLE3Ha9tb nwJk2jQhiKeRMTUr1A+c5NS2ncJ6KKZ/CjP+/8bDhq3KmkudXlNTkW85lrVcjW7qbTVI hByg8k53u2aGQCkC1X9I9meLnjT1g+bt6csfD8sGarEWOF/UVC04cEWseUpw5CA4KBZ0 ccEA== MIME-Version: 1.0 X-Received: by 10.66.118.204 with SMTP id ko12mr2926945pab.184.1385463149582; Tue, 26 Nov 2013 02:52:29 -0800 (PST) Sender: bengt.rodehav@gmail.com Received: by 10.70.55.196 with HTTP; Tue, 26 Nov 2013 02:52:29 -0800 (PST) Date: Tue, 26 Nov 2013 11:52:29 +0100 X-Google-Sender-Auth: wnyIfMIY-Fda4phCeMEDNkY54lo Message-ID: Subject: Fileinstall, problems with variable substitution and write back From: Bengt Rodehav To: "users@felix.apache.org" Content-Type: multipart/alternative; boundary=e89a8ffbaa2be15cb504ec1246ff X-Virus-Checked: Checked by ClamAV on apache.org --e89a8ffbaa2be15cb504ec1246ff Content-Type: text/plain; charset=ISO-8859-1 I'm using Apache Karaf 2.3.3 which comes with FileInstall 3.2.6. I have set the felix.fileinstall.enableConfigSave property to true in order to have FileInstall write back configuration changes to the file. Normally all configuration changes are done by editing the configuration file but there is one property that I change programmatically using ConfigAdmin (an "enable" property to start/stop my service). I am dependent on that property being persisted in the configuration file which is why I set the enableConfigSave property to true. When configuring FileInstall to write back configuration changes to the configuration file, it is important that variables are not substituted for the evaluated value. This normally works since FileInstall evalutates the property in the configuration file and compares it with the configuration admin's value. If they are the same, the value in the configuration file is kept unchanged. However, when using the escape character this is broken. In my case I'm using Apache Camel underneath. When configuring routes via the config admin, I sometimes need to set a value to "${expression-to-be-evaluated-by-camel}". I therefore escape the "{" and "}" to stop FileInstall from trying to evaluate the expression. Like this: $\\{expression-to-be-evaluated-by-camel\\} This also normally works but not when I have an indirection. E g when specifying the following: a=$\\{var} ab=${a}b FileInstall will change the configuration file to: a=$\\{var} ab = ${var}b Note that the variable "ab" has now been expanded and written back to the configuration file even if neither of the variables "a" and "ab" have been changed. I think this is because FileInstall does the following: 1. Calculates the value of "a" to "$\{var} 2. Calculates the value of "b" to "${var}b Note that every evaluation will perform "unescaping". This means that an extra "unescaping" will be done for every indirection which fools FileInstall into thinking that the property has been changed. I'm not exactly sure how this should be fixed in FileInstall. One idea is to never "unescape" already evaluated variables. Actually I think this is probably what would fix this... Does anybody have any ideas about this? Should I create a JIRA? /Bengt --e89a8ffbaa2be15cb504ec1246ff--