You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by Itamar Syn-Hershko <it...@code972.com> on 2012/08/21 00:19:27 UTC

Re: svn commit: r1375282 - /incubator/lucene.net/trunk/src/core/Util/Parameter.cs

This will probably require releasing the core again as well as a new RC...

The spatial module was updated, still doing some integration tests, will
send more updates soon

On Tue, Aug 21, 2012 at 1:14 AM, <sy...@apache.org> wrote:

> Author: synhershko
> Date: Mon Aug 20 22:14:01 2012
> New Revision: 1375282
>
> URL: http://svn.apache.org/viewvc?rev=1375282&view=rev
> Log:
> Fixing a possible NRE which can be thrown during a race condition on
> accessing allParameters
>
> This is not an air-tight solution, as an ArgumentException can still be
> thrown. I don't care much about doing this within a lock as it will never
> be a bottleneck.
>
>
> https://groups.google.com/group/ravendb/browse_thread/thread/a5cf07e80f70c856
>
> Modified:
>     incubator/lucene.net/trunk/src/core/Util/Parameter.cs
>
> Modified: incubator/lucene.net/trunk/src/core/Util/Parameter.cs
> URL:
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Util/Parameter.cs?rev=1375282&r1=1375281&r2=1375282&view=diff
>
> ==============================================================================
> --- incubator/lucene.net/trunk/src/core/Util/Parameter.cs (original)
> +++ incubator/lucene.net/trunk/src/core/Util/Parameter.cs Mon Aug 20 22:14:01
> 2012
> @@ -39,11 +39,13 @@ namespace Lucene.Net.Util
>                         // typesafe enum pattern, no public constructor
>                         this.name = name;
>                         string key = MakeKey(name);
> -
> -                       if (allParameters.ContainsKey(key))
> -                               throw new
> System.ArgumentException("Parameter name " + key + " already used!");
> -
> -                       allParameters[key] = this;
> +
> +                       lock (allParameters)
> +                       {
> +                               if (allParameters.ContainsKey(key))
> +                                       throw new
> System.ArgumentException("Parameter name " + key + " already used!");
> +                               allParameters[key] = this;
> +                       }
>                 }
>
>                 private string MakeKey(string name)
>
>
>
>

RE: svn commit: r1375282 - /incubator/lucene.net/trunk/src/core/Util/Parameter.cs

Posted by Prescott Nasser <ge...@hotmail.com>.
Itamar, when you're happy with the tests and code, let me know, I'll re-cut the RC for core and contrib
 > Date: Tue, 21 Aug 2012 02:05:39 +0300
> Subject: Re: svn commit: r1375282 - /incubator/lucene.net/trunk/src/core/Util/Parameter.cs
> From: itamar@code972.com
> To: lucene-net-dev@lucene.apache.org
> 
> That won't work, the Occur flags need to be statically and publicly
> available
> 
> Since the entire point of that Parameter class is to make the enum
> serializable, which is infact the case with C# (while it is not in Java 5),
> I just removed it and made Occur a native enum again
> 
> All core tests pass (aside from 2 in TestOpenBitSet and
> TestWeakDictionaryBehavior, but they aren't related to this change).
> 
> Commit details: http://svn.apache.org/viewvc?view=revision&revision=1375296
> 
> On Tue, Aug 21, 2012 at 1:21 AM, Oren Eini (Ayende Rahien) <
> ayende@ayende.com> wrote:
> 
> > Instead of doing it this way, do NOT create Occur using separate static
> > fields.
> > Merge Parameter into Occur (only used there) and create the entire
> > dictionary once.
> > Otherwise, you run into risk of the ArgumentException.
> > If that happens, because this is raised from the static ctor, you'll have
> > killed the entire app domain.
> >
> > On Tue, Aug 21, 2012 at 1:19 AM, Itamar Syn-Hershko <itamar@code972.com
> > >wrote:
> >
> > > This will probably require releasing the core again as well as a new
> > RC...
> > >
> > > The spatial module was updated, still doing some integration tests, will
> > > send more updates soon
> > >
> > > On Tue, Aug 21, 2012 at 1:14 AM, <sy...@apache.org> wrote:
> > >
> > > > Author: synhershko
> > > > Date: Mon Aug 20 22:14:01 2012
> > > > New Revision: 1375282
> > > >
> > > > URL: http://svn.apache.org/viewvc?rev=1375282&view=rev
> > > > Log:
> > > > Fixing a possible NRE which can be thrown during a race condition on
> > > > accessing allParameters
> > > >
> > > > This is not an air-tight solution, as an ArgumentException can still be
> > > > thrown. I don't care much about doing this within a lock as it will
> > never
> > > > be a bottleneck.
> > > >
> > > >
> > > >
> > >
> > https://groups.google.com/group/ravendb/browse_thread/thread/a5cf07e80f70c856
> > > >
> > > > Modified:
> > > >     incubator/lucene.net/trunk/src/core/Util/Parameter.cs
> > > >
> > > > Modified: incubator/lucene.net/trunk/src/core/Util/Parameter.cs
> > > > URL:
> > > >
> > >
> > http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Util/Parameter.cs?rev=1375282&r1=1375281&r2=1375282&view=diff
> > > >
> > > >
> > >
> > ==============================================================================
> > > > --- incubator/lucene.net/trunk/src/core/Util/Parameter.cs (original)
> > > > +++ incubator/lucene.net/trunk/src/core/Util/Parameter.cs Mon Aug 20
> > 22
> > > :14:01
> > > > 2012
> > > > @@ -39,11 +39,13 @@ namespace Lucene.Net.Util
> > > >                         // typesafe enum pattern, no public constructor
> > > >                         this.name = name;
> > > >                         string key = MakeKey(name);
> > > > -
> > > > -                       if (allParameters.ContainsKey(key))
> > > > -                               throw new
> > > > System.ArgumentException("Parameter name " + key + " already used!");
> > > > -
> > > > -                       allParameters[key] = this;
> > > > +
> > > > +                       lock (allParameters)
> > > > +                       {
> > > > +                               if (allParameters.ContainsKey(key))
> > > > +                                       throw new
> > > > System.ArgumentException("Parameter name " + key + " already used!");
> > > > +                               allParameters[key] = this;
> > > > +                       }
> > > >                 }
> > > >
> > > >                 private string MakeKey(string name)
> > > >
> > > >
> > > >
> > > >
> > >
> >
 		 	   		  

Re: svn commit: r1375282 - /incubator/lucene.net/trunk/src/core/Util/Parameter.cs

Posted by Itamar Syn-Hershko <it...@code972.com>.
That won't work, the Occur flags need to be statically and publicly
available

Since the entire point of that Parameter class is to make the enum
serializable, which is infact the case with C# (while it is not in Java 5),
I just removed it and made Occur a native enum again

All core tests pass (aside from 2 in TestOpenBitSet and
TestWeakDictionaryBehavior, but they aren't related to this change).

Commit details: http://svn.apache.org/viewvc?view=revision&revision=1375296

On Tue, Aug 21, 2012 at 1:21 AM, Oren Eini (Ayende Rahien) <
ayende@ayende.com> wrote:

> Instead of doing it this way, do NOT create Occur using separate static
> fields.
> Merge Parameter into Occur (only used there) and create the entire
> dictionary once.
> Otherwise, you run into risk of the ArgumentException.
> If that happens, because this is raised from the static ctor, you'll have
> killed the entire app domain.
>
> On Tue, Aug 21, 2012 at 1:19 AM, Itamar Syn-Hershko <itamar@code972.com
> >wrote:
>
> > This will probably require releasing the core again as well as a new
> RC...
> >
> > The spatial module was updated, still doing some integration tests, will
> > send more updates soon
> >
> > On Tue, Aug 21, 2012 at 1:14 AM, <sy...@apache.org> wrote:
> >
> > > Author: synhershko
> > > Date: Mon Aug 20 22:14:01 2012
> > > New Revision: 1375282
> > >
> > > URL: http://svn.apache.org/viewvc?rev=1375282&view=rev
> > > Log:
> > > Fixing a possible NRE which can be thrown during a race condition on
> > > accessing allParameters
> > >
> > > This is not an air-tight solution, as an ArgumentException can still be
> > > thrown. I don't care much about doing this within a lock as it will
> never
> > > be a bottleneck.
> > >
> > >
> > >
> >
> https://groups.google.com/group/ravendb/browse_thread/thread/a5cf07e80f70c856
> > >
> > > Modified:
> > >     incubator/lucene.net/trunk/src/core/Util/Parameter.cs
> > >
> > > Modified: incubator/lucene.net/trunk/src/core/Util/Parameter.cs
> > > URL:
> > >
> >
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Util/Parameter.cs?rev=1375282&r1=1375281&r2=1375282&view=diff
> > >
> > >
> >
> ==============================================================================
> > > --- incubator/lucene.net/trunk/src/core/Util/Parameter.cs (original)
> > > +++ incubator/lucene.net/trunk/src/core/Util/Parameter.cs Mon Aug 20
> 22
> > :14:01
> > > 2012
> > > @@ -39,11 +39,13 @@ namespace Lucene.Net.Util
> > >                         // typesafe enum pattern, no public constructor
> > >                         this.name = name;
> > >                         string key = MakeKey(name);
> > > -
> > > -                       if (allParameters.ContainsKey(key))
> > > -                               throw new
> > > System.ArgumentException("Parameter name " + key + " already used!");
> > > -
> > > -                       allParameters[key] = this;
> > > +
> > > +                       lock (allParameters)
> > > +                       {
> > > +                               if (allParameters.ContainsKey(key))
> > > +                                       throw new
> > > System.ArgumentException("Parameter name " + key + " already used!");
> > > +                               allParameters[key] = this;
> > > +                       }
> > >                 }
> > >
> > >                 private string MakeKey(string name)
> > >
> > >
> > >
> > >
> >
>

Re: svn commit: r1375282 - /incubator/lucene.net/trunk/src/core/Util/Parameter.cs

Posted by "Oren Eini (Ayende Rahien)" <ay...@ayende.com>.
Instead of doing it this way, do NOT create Occur using separate static
fields.
Merge Parameter into Occur (only used there) and create the entire
dictionary once.
Otherwise, you run into risk of the ArgumentException.
If that happens, because this is raised from the static ctor, you'll have
killed the entire app domain.

On Tue, Aug 21, 2012 at 1:19 AM, Itamar Syn-Hershko <it...@code972.com>wrote:

> This will probably require releasing the core again as well as a new RC...
>
> The spatial module was updated, still doing some integration tests, will
> send more updates soon
>
> On Tue, Aug 21, 2012 at 1:14 AM, <sy...@apache.org> wrote:
>
> > Author: synhershko
> > Date: Mon Aug 20 22:14:01 2012
> > New Revision: 1375282
> >
> > URL: http://svn.apache.org/viewvc?rev=1375282&view=rev
> > Log:
> > Fixing a possible NRE which can be thrown during a race condition on
> > accessing allParameters
> >
> > This is not an air-tight solution, as an ArgumentException can still be
> > thrown. I don't care much about doing this within a lock as it will never
> > be a bottleneck.
> >
> >
> >
> https://groups.google.com/group/ravendb/browse_thread/thread/a5cf07e80f70c856
> >
> > Modified:
> >     incubator/lucene.net/trunk/src/core/Util/Parameter.cs
> >
> > Modified: incubator/lucene.net/trunk/src/core/Util/Parameter.cs
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Util/Parameter.cs?rev=1375282&r1=1375281&r2=1375282&view=diff
> >
> >
> ==============================================================================
> > --- incubator/lucene.net/trunk/src/core/Util/Parameter.cs (original)
> > +++ incubator/lucene.net/trunk/src/core/Util/Parameter.cs Mon Aug 20 22
> :14:01
> > 2012
> > @@ -39,11 +39,13 @@ namespace Lucene.Net.Util
> >                         // typesafe enum pattern, no public constructor
> >                         this.name = name;
> >                         string key = MakeKey(name);
> > -
> > -                       if (allParameters.ContainsKey(key))
> > -                               throw new
> > System.ArgumentException("Parameter name " + key + " already used!");
> > -
> > -                       allParameters[key] = this;
> > +
> > +                       lock (allParameters)
> > +                       {
> > +                               if (allParameters.ContainsKey(key))
> > +                                       throw new
> > System.ArgumentException("Parameter name " + key + " already used!");
> > +                               allParameters[key] = this;
> > +                       }
> >                 }
> >
> >                 private string MakeKey(string name)
> >
> >
> >
> >
>