<commit_before>
package eu.arkitech.logback.common;


import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;

import ch.qos.logback.classic.spi.ILoggingEvent;
import com.google.common.base.Objects;
import com.google.common.base.Strings;


public class DefaultLoggingEventMutator
		implements
			LoggingEventMutator
{
	public DefaultLoggingEventMutator ()
	{
		this.sequence = 0;
		this.application = null;
		this.component = null;
		this.node = null;
	}
	
	public String getApplication ()
	{
		return (this.application);
	}
	
	public String getComponent ()
	{
		return (this.component);
	}
	
	public String getNode ()
	{
		return (this.node);
	}
	
	public long getSequence ()
	{
		return (this.sequence);
	}
	
	@Override
	public void mutate (final ILoggingEvent event_)
	{
		final SLoggingEvent1 event = (SLoggingEvent1) event_;
		final String application = Strings.emptyToNull (Objects.firstNonNull (this.application, DefaultLoggingEventMutator.defaultApplication));
		final String component = Strings.emptyToNull (Objects.firstNonNull (this.component, DefaultLoggingEventMutator.defaultComponent));
		final String node = Strings.emptyToNull (Objects.firstNonNull (this.node, DefaultLoggingEventMutator.defaultNode));
		long sequence;
		synchronized (this) {
			sequence = this.sequence;
			this.sequence++;
		}
		if (event.mdcPropertyMap == null)
			event.mdcPropertyMap = new HashMap<String, String> (3);
		else
			event.mdcPropertyMap = new HashMap<String, String> (event.mdcPropertyMap);
		if ((application != null) && !event.mdcPropertyMap.containsKey (DefaultLoggingEventMutator.defaultApplicationMdcName))
			event.mdcPropertyMap.put (DefaultLoggingEventMutator.defaultApplicationMdcName, application);
		if ((component != null) && !event.mdcPropertyMap.containsKey (DefaultLoggingEventMutator.defaultComponentMdcName))
			event.mdcPropertyMap.put (DefaultLoggingEventMutator.defaultComponentMdcName, component);
		if ((node != null) && !event.mdcPropertyMap.containsKey (DefaultLoggingEventMutator.defaultNodeMdcName))
			event.mdcPropertyMap.put (DefaultLoggingEventMutator.defaultNodeMdcName, node);
		event.mdcPropertyMap.put (DefaultLoggingEventMutator.defaultSequenceMdcKey, Long.toString (sequence));
	}
	
	public void setApplication (final String application)
	{
		this.application = application;<commit_msg>Fixed a bug in which an argument of ILoggingEvent is an non-serializable object.<commit_after>
package eu.arkitech.logback.common;


import java.io.Serializable;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.LinkedList;

import ch.qos.logback.classic.spi.ILoggingEvent;
import com.google.common.base.Objects;
import com.google.common.base.Strings;


public class DefaultLoggingEventMutator
		implements
			LoggingEventMutator
{
	public DefaultLoggingEventMutator ()
	{
		this.sequence = 0;
		this.application = null;
		this.component = null;
		this.node = null;
	}
	
	public String getApplication ()
	{
		return (this.application);
	}
	
	public String getComponent ()
	{
		return (this.component);
	}
	
	public String getNode ()
	{
		return (this.node);
	}
	
	public long getSequence ()
	{
		return (this.sequence);
	}
	
	@Override
	public void mutate (final ILoggingEvent event_)
	{
		final SLoggingEvent1 event = (SLoggingEvent1) event_;
		final String application = Strings.emptyToNull (Objects.firstNonNull (this.application, DefaultLoggingEventMutator.defaultApplication));
		final String component = Strings.emptyToNull (Objects.firstNonNull (this.component, DefaultLoggingEventMutator.defaultComponent));
		final String node = Strings.emptyToNull (Objects.firstNonNull (this.node, DefaultLoggingEventMutator.defaultNode));
		long sequence;
		synchronized (this) {
			sequence = this.sequence;
			this.sequence++;
		}
		
		if (event.mdcPropertyMap == null)
			event.mdcPropertyMap = new HashMap<String, String> (3);
		else
			event.mdcPropertyMap = new HashMap<String, String> (event.mdcPropertyMap);
		if ((application != null) && !event.mdcPropertyMap.containsKey (DefaultLoggingEventMutator.defaultApplicationMdcName))
			event.mdcPropertyMap.put (DefaultLoggingEventMutator.defaultApplicationMdcName, application);
		if ((component != null) && !event.mdcPropertyMap.containsKey (DefaultLoggingEventMutator.defaultComponentMdcName))
			event.mdcPropertyMap.put (DefaultLoggingEventMutator.defaultComponentMdcName, component);
		if ((node != null) && !event.mdcPropertyMap.containsKey (DefaultLoggingEventMutator.defaultNodeMdcName))
			event.mdcPropertyMap.put (DefaultLoggingEventMutator.defaultNodeMdcName, node);
		event.mdcPropertyMap.put (DefaultLoggingEventMutator.defaultSequenceMdcKey, Long.toString (sequence));
		
		final LinkedList<String> mdcInvalidKeys = new LinkedList<String> ();
		for (final String mdcKey : event.mdcPropertyMap.keySet ()) {
			final Object mdcValue = event.mdcPropertyMap.get (mdcKey);
			if (!(mdcValue instanceof String))
				mdcInvalidKeys.add (mdcKey);
		}
		for (final String mdcInvalidKey : mdcInvalidKeys)
			event.mdcPropertyMap.remove (mdcInvalidKey);
		if (event.argumentArray != null)
			for (int index = 0; index < event.argumentArray.length; index++)
				if ((event.argumentArray[index] != null) && !(event.argumentArray[index] instanceof Serializable))
					event.argumentArray[index] = String.valueOf (event.argumentArray[index]);
	}
	
	public void setApplication (final String application)
	{
		this.application = application;
{'fraction_non_alphanumeric': 0.10215931772818, 'fraction_numerical': 0.001633097441480675, 'mean_word_length': 5.4392523364485985, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6545374', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1660, 'n_words': 342}