Dominik P avatar Dominik P committed 1250c81

Implemented possible fix for LOG4NET-343

Comments (0)

Files changed (2)

+# HG changeset patch
+# Parent d6e8c2e881275dec3b2242ca41fae9c3fe7b7d6c
+Do not search for parents if the string is shorter than 2 characters. LOG4NET-343
+
+diff -r d6e8c2e88127 -r 2fafff5669aa src/Repository/Hierarchy/Hierarchy.cs
+--- a/src/Repository/Hierarchy/Hierarchy.cs	Fri May 25 21:48:29 2012 +0200
++++ b/src/Repository/Hierarchy/Hierarchy.cs	Sat May 26 16:07:55 2012 +0200
+@@ -832,41 +832,44 @@
+ 			int length = name.Length;
+ 			bool parentFound = false;
+ 	
+-			// if name = "w.x.y.z", loop through "w.x.y", "w.x" and "w", but not "w.x.y.z" 
+-			for(int i = name.LastIndexOf('.', length-1); i >= 0; i = name.LastIndexOf('.', i-1))  
+-			{
+-				string substr = name.Substring(0, i);
+-
+-				LoggerKey key = new LoggerKey(substr); // simple constructor
+-				Object node = m_ht[key];
+-				// Create a provision node for a future parent.
+-				if (node == null) 
+-				{
+-					ProvisionNode pn = new ProvisionNode(log);
+-					m_ht[key] = pn;
+-				} 
+-				else
+-				{
+-					Logger nodeLogger = node as Logger;
+-					if (nodeLogger != null)
+-					{
+-						parentFound = true;
+-						log.Parent = nodeLogger;
+-						break; // no need to update the ancestors of the closest ancestor
+-					}
+-					else
+-					{
+-						ProvisionNode nodeProvisionNode = node as ProvisionNode;
+-						if (nodeProvisionNode != null)
+-						{
+-							nodeProvisionNode.Add(log);
+-						}
+-						else
+-						{
+-							LogLog.Error(declaringType, "Unexpected object type ["+node.GetType()+"] in ht.", new LogException());
+-						}
+-					} 
+-				} 
++			// if name = "w.x.y.z", loop through "w.x.y", "w.x" and "w", but not "w.x.y.z" 
++			if (length > 1)
++			{
++				for (int i = name.LastIndexOf('.', length - 1); i >= 0; i = name.LastIndexOf('.', i - 1))
++				{
++					string substr = name.Substring(0, i);
++
++					LoggerKey key = new LoggerKey(substr); // simple constructor
++					Object node = m_ht[key];
++					// Create a provision node for a future parent.
++					if (node == null)
++					{
++						ProvisionNode pn = new ProvisionNode(log);
++						m_ht[key] = pn;
++					}
++					else
++					{
++						Logger nodeLogger = node as Logger;
++						if (nodeLogger != null)
++						{
++							parentFound = true;
++							log.Parent = nodeLogger;
++							break; // no need to update the ancestors of the closest ancestor
++						}
++						else
++						{
++							ProvisionNode nodeProvisionNode = node as ProvisionNode;
++							if (nodeProvisionNode != null)
++							{
++								nodeProvisionNode.Add(log);
++							}
++							else
++							{
++								LogLog.Error(declaringType, "Unexpected object type [" + node.GetType() + "] in ht.", new LogException());
++							}
++						}
++					}
++				}
+ 			}
+ 
+ 			// If we could not find any existing parents, then link with root.
 LOG4NET-341
+LOG4NET-343
 RFA-NG
 LOG4NET-190
 LOG4NET-108
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.