Author: vhalbert(a)redhat.com
Date: 2009-12-16 17:25:58 -0500 (Wed, 16 Dec 2009)
New Revision: 1677
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java
Log:
Teiid-909 - added logic to check for the case when the key is also in the value as
${key}. If found, then bypass resolving this property.
Modified: trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
===================================================================
---
trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-12-16
21:23:17 UTC (rev 1676)
+++
trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-12-16
22:25:58 UTC (rev 1677)
@@ -820,12 +820,22 @@
String nestedkey = value.substring(start+2, end);
String nestedvalue = original.getProperty(nestedkey);
- // this will handle case where we did not resolve, mark it blank
- if (nestedvalue == null) {
- throw new
MetaMatrixRuntimeException(CorePlugin.Util.getString("PropertiesUtils.failed_to_resolve_property",
nestedkey)); //$NON-NLS-1$
- }
- value = value.substring(0,start)+nestedvalue+value.substring(end+1);
- modified = true;
+ // in cases where the key and the nestedkey are the same, this has to
be bypassed
+ // because it will cause an infinite loop, and because there will be
no value
+ // for the nestedkey that doesnt contain ${..} in the value
+ if (key.equals(nestedkey)) {
+ matched = false;
+
+ } else {
+
+
+ // this will handle case where we did not resolve, mark it blank
+ if (nestedvalue == null) {
+ throw new
MetaMatrixRuntimeException(CorePlugin.Util.getString("PropertiesUtils.failed_to_resolve_property",
nestedkey)); //$NON-NLS-1$
+ }
+ value =
value.substring(0,start)+nestedvalue+value.substring(end+1);
+ modified = true;
+ }
}
}
if(modified) {
Modified:
trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java
===================================================================
---
trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java 2009-12-16
21:23:17 UTC (rev 1676)
+++
trunk/common-core/src/test/java/com/metamatrix/common/util/TestPropertiesUtils.java 2009-12-16
22:25:58 UTC (rev 1677)
@@ -651,6 +651,15 @@
} catch(RuntimeException e) {
// pass
}
+
+
+ // JIRA: TEIID-909 - The resolveNestedProperties logic goes in a loop when the
key is also in the value as ${key}.
+ Properties dups = new Properties();
+ dups.setProperty("usethis", "${usethis}");
+
+ dups = PropertiesUtils.resolveNestedProperties(dups);
+
+
}
Show replies by date