Fix regression in the ReadOnlyPropertiesDictionary (fixes LOG4NET-581)

The patch moves the null check condition to a better place and now prevents
NullReferenceException's to be thrown. Thanks go to Vlad Lee who kindly
provided the patch.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4net/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4net/commit/68aaff9a
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4net/tree/68aaff9a
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4net/diff/68aaff9a

Branch: refs/heads/feature/cd-pipeline
Commit: 68aaff9a4cd8ad69480a673ba639557078961165
Parents: 33d0749
Author: Dominik Psenner <dpsen...@apache.org>
Authored: Thu Nov 9 18:19:42 2017 +0100
Committer: Dominik Psenner <dpsen...@apache.org>
Committed: Thu Nov 9 18:19:42 2017 +0100

----------------------------------------------------------------------
 src/Util/ReadOnlyPropertiesDictionary.cs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/68aaff9a/src/Util/ReadOnlyPropertiesDictionary.cs
----------------------------------------------------------------------
diff --git a/src/Util/ReadOnlyPropertiesDictionary.cs 
b/src/Util/ReadOnlyPropertiesDictionary.cs
index e7e0fe1..3efa0a9 100644
--- a/src/Util/ReadOnlyPropertiesDictionary.cs
+++ b/src/Util/ReadOnlyPropertiesDictionary.cs
@@ -216,13 +216,18 @@ namespace log4net.Util
                                string entryKey = entry.Key as string;
                                object entryValue = entry.Value;
 
+                               if (entryKey == null || entryValue == null)
+                               {
+                                       continue;
+                               }
+
                                // 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)
+                               if (isSerializable)
                                {
                                        // Store the keys as an Xml encoded 
local name as it may contain colons (':')
                                        // which are NOT escaped by the Xml 
Serialization framework.

Reply via email to