@Test public void testIsValueNeedsLookup() { assertTrue("with ${ as value", Property.createProperty("", "${").isValueNeedsLookup()); assertTrue("with ${ in value", Property.createProperty("", "blah${blah").isValueNeedsLookup()); assertFalse("empty value", Property.createProperty("", "").isValueNeedsLookup()); assertFalse("without ${ in value", Property.createProperty("", "blahblah").isValueNeedsLookup()); assertFalse("without $ in value", Property.createProperty("", "blahb{sys:lah").isValueNeedsLookup()); assertFalse("without { in value", Property.createProperty("", "blahb$sys:lah").isValueNeedsLookup()); } }
private static boolean containsPropertyRequiringLookup(final Property[] properties) { if (properties == null) { return false; } for (int i = 0; i < properties.length; i++) { if (properties[i].isValueNeedsLookup()) { return true; } } return false; }
/** * Returns an unmodifiable map with the configuration properties, or {@code null} if this {@code LoggerConfig} does * not have any configuration properties. * <p> * For each {@code Property} key in the map, the value is {@code true} if the property value has a variable that * needs to be substituted. * * @return an unmodifiable map with the configuration properties, or {@code null} * @see Configuration#getStrSubstitutor() * @see StrSubstitutor * @deprecated use {@link #getPropertyList()} instead */ // LOG4J2-157 @Deprecated public Map<Property, Boolean> getProperties() { if (properties == null) { return null; } if (propertiesMap == null) { // lazily initialize: only used by user custom code, not by Log4j any more final Map<Property, Boolean> result = new HashMap<>(properties.size() * 2); for (int i = 0; i < properties.size(); i++) { result.put(properties.get(i), Boolean.valueOf(properties.get(i).isValueNeedsLookup())); } propertiesMap = Collections.unmodifiableMap(result); } return propertiesMap; }
urlConnection.setRequestProperty( header.getName(), header.isValueNeedsLookup() ? getConfiguration().getStrSubstitutor().replace(event, header.getValue()) : header.getValue());
for (int i = 0; i < properties.size(); i++) { final Property prop = properties.get(i); final String value = prop.isValueNeedsLookup() // since LOG4J2-1575
continue; // contextMap overrides config properties final String value = prop.isValueNeedsLookup() //