"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java" between
apache-log4j-2.11.1-src.tar.gz and apache-log4j-2.11.2-src.tar.gz

About: Apache Log4j 2 is a logging library for Java. Source distribution (Java).

MapLookup.java  (apache-log4j-2.11.1-src):MapLookup.java  (apache-log4j-2.11.2-src)
skipping to change at line 25 skipping to change at line 25
* limitations under the license. * limitations under the license.
*/ */
package org.apache.logging.log4j.core.lookup; package org.apache.logging.log4j.core.lookup;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.plugins.Plugin; import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.message.StringMapMessage; import org.apache.logging.log4j.message.MapMessage;
/** /**
* A map-based lookup. * A map-based lookup.
*/ */
@Plugin(name = "map", category = StrLookup.CATEGORY) @Plugin(name = "map", category = StrLookup.CATEGORY)
public class MapLookup implements StrLookup { public class MapLookup implements StrLookup {
/** /**
* Map keys are variable names and value. * Map keys are variable names and value.
*/ */
skipping to change at line 121 skipping to change at line 121
} }
return initMap(args, newMap(args.length)); return initMap(args, newMap(args.length));
} }
protected Map<String, String> getMap() { protected Map<String, String> getMap() {
return map; return map;
} }
@Override @Override
public String lookup(final LogEvent event, final String key) { public String lookup(final LogEvent event, final String key) {
final boolean isMapMessage = event != null && event.getMessage() instanc eof StringMapMessage; final boolean isMapMessage = event != null && event.getMessage() instanc eof MapMessage;
if (map == null && !isMapMessage) { if (map == null && !isMapMessage) {
return null; return null;
} }
if (map != null && map.containsKey(key)) { if (map != null && map.containsKey(key)) {
final String obj = map.get(key); final String obj = map.get(key);
if (obj != null) { if (obj != null) {
return obj; return obj;
} }
} }
if (isMapMessage) { if (isMapMessage) {
return ((StringMapMessage) event.getMessage()).get(key); return ((MapMessage) event.getMessage()).get(key);
} }
return null; return null;
} }
/** /**
* Looks up a String key to a String value using the map. * Looks up a String key to a String value using the map.
* <p> * <p>
* If the map is null, then null is returned. The map result object is conve rted to a string using toString(). * If the map is null, then null is returned. The map result object is conve rted to a string using toString().
* </p> * </p>
* *
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)