[ 
https://issues.apache.org/jira/browse/LOG4NET-614?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dominik Psenner closed LOG4NET-614.
-----------------------------------
       Resolution: Duplicate
         Assignee: Dominik Psenner
    Fix Version/s: 2.1.0

Thanks Ilya for reporting this. I'm closing this issue because it is a 
duplicate. It has already been fixed both in develop and the release branch for 
2.1.0. log4net depends on the community that drives the project. Currently this 
project needs help from the community that uses the logging framework. We are 
in need for additional human resources. If you would like to contribute some of 
your valuable time please join us in the [developers mailing 
list|http://logging.apache.org/log4net/mail-lists.html].

> If LogicalThreadContext has a property with NULL value it causes an exception
> -----------------------------------------------------------------------------
>
>                 Key: LOG4NET-614
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-614
>             Project: Log4net
>          Issue Type: Bug
>    Affects Versions: 2.0.8
>            Reporter: Ilya Badaev
>            Assignee: Dominik Psenner
>            Priority: Major
>             Fix For: 2.1.0
>
>
> I used to have the following inside the code:
> {code:java}
> log4net.LogicalThreadContext.Properties["EventID"] = (int)idEvent;
> log.WarnFormat(format, p);
> log4net.LogicalThreadContext.Properties["EventID"] = null;
> {code}
> It causes an exception in ReadOnlyPropertiesDictionary.GetObjectData(..)
> in the following code:
> {code:java}
>                     // If value is serializable then we add it to the list
> #if NETSTANDARD1_3
>                 bool isSerializable = 
> entryValue.GetType().GetTypeInfo().IsSerializable;
> #else
>                     bool isSerializable = entryValue.GetType().IsSerializable;
> #endif
>                     if (entryKey != null && entryValue != null && 
> isSerializable)
>                     {
>                         // Store the keys as an Xml encoded local name as it 
> may contain colons (':') 
>                         // which are NOT escaped by the Xml Serialization 
> framework.
>                         // This must be a bug in the serialization framework 
> as we cannot be expected
>                         // to know the implementation details of all the 
> possible transport layers.
>                         info.AddValue(XmlConvert.EncodeLocalName(entryKey), 
> entryValue);
>                     }
>                 }
> {code}
> The source of the problem is clear : the check for entryValue != null should 
> be done before isSerializable is initiated.
>  
> As a workaround I changed my original code to be the following:
> {code:java}
> log4net.LogicalThreadContext.Properties["EventID"] = (int)idEvent;
> log.WarnFormat(format, p);
> log4net.LogicalThreadContext.Properties.Remove("EventID");{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to