lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [Lucene.Net] svn commit: r1099189 - in /incubator/lucene.net/branches/Lucene.Net_2_9_4g: src/core/Index/Term.cs src/core/Search/NumericRangeQuery.cs src/core/Search/SortField.cs src/core/SupportClass.cs src/core/Util/Parameter.cs test/core/TestSupportClass.cs
Date Tue, 03 May 2011 18:57:35 GMT
Author: digy
Date: Tue May  3 18:57:34 2011
New Revision: 1099189

URL: http://svn.apache.org/viewvc?rev=1099189&view=rev
Log:
[LUCENENET-412] [LUCENENET-413] Medium trust security issue 

Modified:
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/Term.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/NumericRangeQuery.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/SortField.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Util/Parameter.cs
    incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/Term.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/Term.cs?rev=1099189&r1=1099188&r2=1099189&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/Term.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Index/Term.cs Tue May  3 18:57:34
2011
@@ -30,7 +30,7 @@ namespace Lucene.Net.Index
 	/// </summary>
 	
 	[Serializable]
-    public sealed class Term : System.IComparable, System.Runtime.Serialization.ISerializable,IEquatable<Term>
+    public sealed class Term : System.IComparable, IEquatable<Term>
 	{
 		internal System.String field;
 		internal System.String text;
@@ -170,16 +170,10 @@ namespace Lucene.Net.Index
 //			field = StringHelper.Intern(field);
 //		}
 
-        public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext
context)
+        [System.Runtime.Serialization.OnDeserialized]
+        internal void OnDeserialized(System.Runtime.Serialization.StreamingContext context)
         {
-            info.AddValue("text", text);
-            info.AddValue("field", field);
-        }
-
-        private Term(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext
context)
-        {
-            text = (string)info.GetValue("text", typeof(string));
-            field = StringHelper.Intern((string)info.GetValue("field", typeof(string)));
+            field = StringHelper.Intern(field);
         }
 
         public System.String text_ForNUnit

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/NumericRangeQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/NumericRangeQuery.cs?rev=1099189&r1=1099188&r2=1099189&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/NumericRangeQuery.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/NumericRangeQuery.cs Tue
May  3 18:57:34 2011
@@ -153,7 +153,7 @@ namespace Lucene.Net.Search
 	/// 
 	/// </since>
 	[Serializable]
-	public sealed class NumericRangeQuery:MultiTermQuery,System.Runtime.Serialization.ISerializable
+	public sealed class NumericRangeQuery:MultiTermQuery
 	{
 		
 		private NumericRangeQuery(System.String field, int precisionStep, int valSize, System.ValueType
min, System.ValueType max, bool minInclusive, bool maxInclusive)
@@ -365,38 +365,10 @@ namespace Lucene.Net.Search
         //}
 
 
-        /// <summary>
-        /// Lucene.Net specific. Needed for Serialization
-        /// </summary>
-        /// <param name="info"></param>
-        /// <param name="context"></param>
-        public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext
context)
+        [System.Runtime.Serialization.OnDeserialized]
+        internal void OnDeserialized(System.Runtime.Serialization.StreamingContext context)
         {
-            info.AddValue("precisionStep", precisionStep);
-            info.AddValue("valSize", valSize);
-            info.AddValue("min", min);
-            info.AddValue("max", max);
-            info.AddValue("minInclusive", minInclusive);
-            info.AddValue("maxInclusive", maxInclusive);
-
-            info.AddValue("field", field);
-        }
-
-        /// <summary>
-        /// Lucene.Net specific. Needed for deserialization
-        /// </summary>
-        /// <param name="info"></param>
-        /// <param name="context"></param>
-        private NumericRangeQuery(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext
context)
-        {
-            precisionStep   = (int)info.GetValue("precisionStep", typeof(int));
-            valSize         = (int)info.GetValue("valSize", typeof(int));
-            min             = (System.ValueType)info.GetValue("min", typeof(System.ValueType));
-            max             = (System.ValueType)info.GetValue("max", typeof(System.ValueType));
-            minInclusive    = (bool)info.GetValue("minInclusive", typeof(bool));
-            maxInclusive    = (bool)info.GetValue("maxInclusive", typeof(bool));
-            
-            field           = StringHelper.Intern((string)info.GetValue("field", typeof(string)));
+            field = StringHelper.Intern(field);
         }
 		
 		// members (package private, to be also fast accessible by NumericRangeTermEnum)

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/SortField.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/SortField.cs?rev=1099189&r1=1099188&r2=1099189&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/SortField.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Search/SortField.cs Tue May 
3 18:57:34 2011
@@ -39,7 +39,7 @@ namespace Lucene.Net.Search
 	/// <seealso cref="Sort">
 	/// </seealso>
 	[Serializable]
-	public class SortField: System.Runtime.Serialization.ISerializable
+	public class SortField
 	{
 		
 		/// <summary>Sort by document score (relevancy).  Sort values are Float and higher
@@ -561,44 +561,10 @@ namespace Lucene.Net.Search
        //    field = StringHelper.intern(field);
        // }
 
-        /// <summary>
-        /// Lucene.Net specific. Needed for Serialization
-        /// </summary>
-        /// <param name="info"></param>
-        /// <param name="context"></param>
-        public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext
context)
+        [System.Runtime.Serialization.OnDeserialized]
+        internal void OnDeserialized(System.Runtime.Serialization.StreamingContext context)
         {
-            //Should we add other fields as in NumericRangeQuery? {{DIGY}}
-
-            info.AddValue("type", type);
-            info.AddValue("useLegacy", useLegacy);
-            info.AddValue("reverse", reverse);
-            info.AddValue("locale", locale);
-            info.AddValue("comparatorSource", comparatorSource);
-            info.AddValue("factory", factory);
-            info.AddValue("parser", parser);
-                        
-            info.AddValue("field", field);
-        }
-
-        /// <summary>
-        /// Lucene.Net specific. Needed for deserialization
-        /// </summary>
-        /// <param name="info"></param>
-        /// <param name="context"></param>
-        protected SortField(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext
context)
-        {
-            //Should we add other fields as in NumericRangeQuery? {{DIGY}}
-
-            type        = (int)info.GetValue("type", typeof(int));
-            useLegacy   = (bool)info.GetValue("useLegacy", typeof(bool));
-            reverse     = (bool)info.GetValue("reverse", typeof(bool));
-            locale      = (System.Globalization.CultureInfo)info.GetValue("locale", typeof(System.Globalization.CultureInfo));
-            comparatorSource = (FieldComparatorSource)info.GetValue("comparatorSource", typeof(FieldComparatorSource));
-            factory          = (SortComparatorSource)info.GetValue("factory", typeof(FieldComparatorSource));
-            parser           = (Parser)info.GetValue("parser", typeof(Parser));
-                        
-            field       = StringHelper.Intern((string)info.GetValue("field", typeof(string)));
+            field = StringHelper.Intern(field);
         }
 		
 		/// <summary>Returns the {@link FieldComparator} to use for

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs?rev=1099189&r1=1099188&r2=1099189&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/SupportClass.cs Tue May  3 18:57:34
2011
@@ -478,29 +478,29 @@ public class SupportClass
 
 			fileStream.Flush();
 
-			if (OS.IsWindows)
-			{
-				if (!FlushFileBuffers(fileStream.Handle))
-					throw new System.IO.IOException();
-			}
-			else if (OS.IsUnix)
-			{
-				if (fsync(fileStream.Handle) != IntPtr.Zero)
-				throw new System.IO.IOException();
-			}
-			else
-			{
-				throw new NotImplementedException();
-			}
+            //if (OS.IsWindows)
+            //{
+            //    if (!FlushFileBuffers(fileStream.Handle))
+            //        throw new System.IO.IOException();
+            //}
+            //else if (OS.IsUnix)
+            //{
+            //    if (fsync(fileStream.Handle) != IntPtr.Zero)
+            //    throw new System.IO.IOException();
+            //}
+            //else
+            //{
+            //    throw new NotImplementedException();
+            //}
 		}
 
 #pragma warning restore 618
 
-		[System.Runtime.InteropServices.DllImport("libc")]
-		extern static IntPtr fsync(IntPtr fd);
+        //[System.Runtime.InteropServices.DllImport("libc")]
+        //extern static IntPtr fsync(IntPtr fd);
 
-		[System.Runtime.InteropServices.DllImport("kernel32.dll")]
-		extern static bool FlushFileBuffers(IntPtr hFile);
+        //[System.Runtime.InteropServices.DllImport("kernel32.dll")]
+        //extern static bool FlushFileBuffers(IntPtr hFile);
     }
 
     /// <summary>

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Util/Parameter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Util/Parameter.cs?rev=1099189&r1=1099188&r2=1099189&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Util/Parameter.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/src/core/Util/Parameter.cs Tue May  3
18:57:34 2011
@@ -16,15 +16,16 @@
  */
 
 using System;
+using System.Collections.Generic;
 
 namespace Lucene.Net.Util
 {
 	
 	/// <summary> A serializable Enum class.</summary>
 	[Serializable]
-    public abstract class Parameter : System.Runtime.Serialization.IObjectReference
+    public abstract class Parameter 
 	{
-		internal static System.Collections.IDictionary allParameters = new System.Collections.Hashtable();
+        internal static Dictionary<string, Parameter> allParameters = new Dictionary<string,
Parameter>();
 		
 		private System.String name;
 		
@@ -37,20 +38,20 @@ namespace Lucene.Net.Util
 		{
 			// typesafe enum pattern, no public constructor
 			this.name = name;
-			System.String key = MakeKey(name);
+			string key = MakeKey(name);
 			
-			if (allParameters.Contains(key))
+			if (allParameters.ContainsKey(key))
 				throw new System.ArgumentException("Parameter name " + key + " already used!");
 			
 			allParameters[key] = this;
 		}
 		
-		private System.String MakeKey(System.String name)
+		private string MakeKey(System.String name)
 		{
 			return GetType() + " " + name;
 		}
 		
-		public override System.String ToString()
+		public override string ToString()
 		{
 			return name;
 		}
@@ -62,20 +63,20 @@ namespace Lucene.Net.Util
 		/// <returns> a reference to Parameter as resolved in the local VM
 		/// </returns>
 		/// <throws>  ObjectStreamException </throws>
-		protected internal virtual System.Object ReadResolve()
-		{
-			System.Object par = allParameters[MakeKey(name)];
+        //protected internal virtual System.Object ReadResolve()
+        //{
+        //    System.Object par = allParameters[MakeKey(name)];
 			
-			if (par == null)
-				throw new System.IO.IOException("Unknown parameter value: " + name);
+        //    if (par == null)
+        //        throw new System.IO.IOException("Unknown parameter value: " + name);
 			
-			return par;
-		}
+        //    return par;
+        //}
 
-        // "ReadResolve"s equivalent for .NET
-        public Object GetRealObject(System.Runtime.Serialization.StreamingContext context)
+        public override bool Equals(object obj)
         {
-            return ReadResolve();
+            if (obj.GetType() != this.GetType()) return false;
+            return this.name.Equals((obj as Parameter).name);
         }
 	}
 }
\ No newline at end of file

Modified: incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs?rev=1099189&r1=1099188&r2=1099189&view=diff
==============================================================================
--- incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs (original)
+++ incubator/lucene.net/branches/Lucene.Net_2_9_4g/test/core/TestSupportClass.cs Tue May
 3 18:57:34 2011
@@ -881,6 +881,7 @@ namespace Lucene.Net._SupportClass
     }
 
     [TestFixture]
+    [Serializable]
     public class TestOldPatches
     {
         //-------------------------------------------



Mime
View raw message