[
https://issues.apache.org/jira/browse/LOG4NET-591?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Stefan Bodewig resolved LOG4NET-591.
------------------------------------
Resolution: Duplicate
Fix Version/s: 2.0.9
Thank you.
This is already fixed in the develop branch and will be fixed with the next
release. See git commit 68aaff9a
https://git-wip-us.apache.org/repos/asf?p=logging-log4net.git;a=commitdiff;h=68aaff9a4cd8ad69480a673ba639557078961165
> Serializing LoggingEvent with null entries in Properties throws exception
> -------------------------------------------------------------------------
>
> Key: LOG4NET-591
> URL: https://issues.apache.org/jira/browse/LOG4NET-591
> Project: Log4net
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.0.8
> Reporter: Morten Overgaard
> Priority: Critical
> Labels: easyfix
> Fix For: 2.0.9
>
>
> When serializing a PropertiesDictionary (as part of LoggingEvent) having null
> values --> NullReference exception occurs
>
> This happens because of:
> {code:java}
> public virtual void GetObjectData(SerializationInfo info, StreamingContext
> context)
> {
> foreach (DictionaryEntry dictionaryEntry in this.InnerHashtable.Clone() as
> IDictionary)
> {
> string key = dictionaryEntry.Key as string;
> object obj = dictionaryEntry.Value; // When dictionaryEntry.Value is null
> bool isSerializable = obj.GetType().IsSerializable; // NullReferenceException
> if (key != null && obj != null && isSerializable)
> info.AddValue(XmlConvert.EncodeLocalName(key), obj);
> }
> }{code}
> Suggestion (Not tested) :
> {code:java}
> public virtual void GetObjectData(SerializationInfo info, StreamingContext
> context)
> {
> foreach (DictionaryEntry dictionaryEntry in this.InnerHashtable.Clone() as
> IDictionary)
> {
> string key = dictionaryEntry.Key as string;
> object obj = dictionaryEntry.Value;
> bool isSerializable = obj == null ? false : obj.GetType().IsSerializable;
> if (key != null && obj != null && isSerializable)
> info.AddValue(XmlConvert.EncodeLocalName(key), obj);
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)