Source:
protected String replaceSystemProperty(String text) { String[] sysRefs = StringUtils.substringsBetween(text, SYS_PROPERTY_PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX); String[] envRefs = StringUtils.substringsBetween(text, ENV_VAR_PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX); if (sysRefs != null) { for (String ref : sysRefs) { String property = System.getProperty(ref); if (StringUtils.isNotEmpty(property)) { text = text.replaceAll(Pattern.quote(SYS_PROPERTY_PLACEHOLDER_PREFIX + ref + PLACEHOLDER_SUFFIX), property); } else { throw new RuntimeException("Error while retrieving " + ref + " system property"); } } return text; } if (envRefs != null) { for (String ref : envRefs) { String resolvedValue = System.getenv(ref); if (StringUtils.isNotEmpty(resolvedValue)) { text = text.replaceAll(Pattern.quote(ENV_VAR_PLACEHOLDER_PREFIX + ref + PLACEHOLDER_SUFFIX), resolvedValue); } else { throw new RuntimeException("Error while retrieving " + ref + " environment variable"); } } return text; } int indexOfStartingChars = -1; int indexOfClosingBrace; while (indexOfStartingChars < text.indexOf(PROPERTY_PLACEHOLDER_PREFIX) && (indexOfStartingChars = text.indexOf(PROPERTY_PLACEHOLDER_PREFIX)) != -1 && (indexOfClosingBrace = text.indexOf(PLACEHOLDER_SUFFIX)) != -1) { String sysProp = text.substring(indexOfStartingChars + 2, indexOfClosingBrace); String propValue = System.getProperty(sysProp); if (propValue == null) { propValue = System.getenv(sysProp); } if (propValue != null) { text = text.substring(0, indexOfStartingChars) + propValue + text.substring(indexOfClosingBrace + 1); } if (sysProp.equals("carbon.home") && propValue != null && propValue.equals(".")) { text = new File(".").getAbsolutePath() + File.separator + text; } } return text; }

Target:
protected String replaceSystemProperty(String text) { String sysRefs = StringUtils.substringBetween(text, SYS_PROPERTY_PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX); String envRefs = StringUtils.substringBetween(text, ENV_VAR_PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX); if (sysRefs != null) { String property = System.getProperty(sysRefs); if (StringUtils.isNotEmpty(property)) { text = text.replaceAll(Pattern.quote(SYS_PROPERTY_PLACEHOLDER_PREFIX + sysRefs + PLACEHOLDER_SUFFIX), property); } else { log.error("System property is not available for " + sysRefs); } return text; } if (envRefs != null) { String resolvedValue = System.getenv(envRefs); if (StringUtils.isNotEmpty(resolvedValue)) { text = text.replaceAll(Pattern.quote(ENV_VAR_PLACEHOLDER_PREFIX + envRefs + PLACEHOLDER_SUFFIX), resolvedValue); } else { log.error("Environment variable is not available for " + envRefs); } return text; } int indexOfStartingChars = -1; int indexOfClosingBrace; while (indexOfStartingChars < text.indexOf(DYNAMIC_PROPERTY_PLACEHOLDER_PREFIX) && (indexOfStartingChars = text.indexOf(DYNAMIC_PROPERTY_PLACEHOLDER_PREFIX)) != -1 && (indexOfClosingBrace = text.indexOf(PLACEHOLDER_SUFFIX)) != -1) { String sysProp = text.substring(indexOfStartingChars + 2, indexOfClosingBrace); String propValue = System.getProperty(sysProp); if (propValue == null) { propValue = System.getenv(sysProp); } if (propValue != null) { text = text.substring(0, indexOfStartingChars) + propValue + text.substring(indexOfClosingBrace + 1); } if (sysProp.equals("carbon.home") && propValue != null && propValue.equals(".")) { text = new File(".").getAbsolutePath() + File.separator + text; } } return text; }