@SuppressWarnings("unchecked") @Override public <V> void forEach(final BiConsumer<String, ? super V> action) { iterating = true; try { for (int i = 0; i < size; i++) { action.accept(keys[i], (V) values[i]); } } finally { iterating = false; } }
@Override public void forEach(final BiConsumer<String, String> action) { for (final Map.Entry<Object, Object> entry : properties.entrySet()) { action.accept(((String) entry.getKey()), ((String) entry.getValue())); } }
@Override public <V> void forEach(final BiConsumer<String, ? super V> action) { final Map<String, String> map = localMap.get(); if (map == null) { return; } for (final Map.Entry<String, String> entry : map.entrySet()) { //BiConsumer should be able to handle values of any type V. In our case the values are of type String. @SuppressWarnings("unchecked") V value = (V) entry.getValue(); action.accept(entry.getKey(), value); } }
@Override public void forEach(final BiConsumer<String, String> action) { Properties properties; try { properties = System.getProperties(); } catch (final SecurityException e) { // (1) There is no status logger. // (2) LowLevelLogUtil also consults system properties ("line.separator") to // open a BufferedWriter, so this may fail as well. Just having a hard reference // in this code to LowLevelLogUtil would cause a problem. // (3) We could log to System.err (nah) or just be quiet as we do now. return; } // Lock properties only long enough to get a thread-safe SAFE snapshot of its // current keys, an array. final Object[] keySet; synchronized (properties) { keySet = properties.keySet().toArray(); } // Then traverse for an unknown amount of time. // Some keys may now be absent, in which case, the value is null. for (final Object key : keySet) { final String keyStr = Objects.toString(key, null); action.accept(keyStr, properties.getProperty(keyStr)); } }
@Override public void forEach(final BiConsumer<String, String> action) { final Map<String, String> getenv; try { getenv = System.getenv(); } catch (final SecurityException e) { // There is no status logger yet. LowLevelLogUtil.logException( "The system environment variables are not available to Log4j due to security restrictions: " + e, e); return; } for (final Map.Entry<String, String> entry : getenv.entrySet()) { final String key = entry.getKey(); if (key.startsWith(PREFIX)) { action.accept(key.substring(PREFIX.length()), entry.getValue()); } } }
@SuppressWarnings("unchecked") @Override public <V> void forEach(final BiConsumer<String, ? super V> action) { iterating = true; try { for (int i = 0; i < size; i++) { action.accept(keys[i], (V) values[i]); } } finally { iterating = false; } }
@Override public void forEach(BiConsumer<String, String> action) { action.accept("log4j.isThreadContextMapInheritable", "true"); }
@Override public <V> void forEach(final BiConsumer<String, ? super V> action) { final Map<String, String> map = localMap.get(); if (map == null) { return; } for (final Map.Entry<String, String> entry : map.entrySet()) { action.accept(entry.getKey(), (V) entry.getValue()); } }
@SuppressWarnings("unchecked") @Override public <V> void forEach(final BiConsumer<String, ? super V> action) { final String[] keys = getSortedKeys(); for (int i = 0; i < keys.length; i++) { action.accept(keys[i], (V) map.get(keys[i])); } }