nsabiyera / Oak

Frictionless development for ASP.NET MVC single page web apps. Prototypical and dynamic capabilities brought to C#.
http://amirrajan.github.com/Oak
MIT License
6 stars 7 forks source link

Gemini is not ThreadSafe #32

Closed davidpodhola closed 10 years ago

davidpodhola commented 10 years ago
System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at Oak.Gemini.AutoProperties() in Oak\Gemini.cs:line 291
   at Oak.Gemini.ApplyValuesToWritableProperties() in del\Oak\Gemini.cs:line 270
   at Oak.Gemini..ctor(Object dto) in Oak\Gemini.cs:line 210
   at Oak.DynamicModel..ctor(Object dto) in Oak\DynamicModel.cs:line 22
davidpodhola commented 10 years ago

suggested fix:

        private Dictionary<string, PropertyInfo> AutoProperties()
        {
            lock (typeof(Gemini))
            {
                if (!PropertyCache.ContainsKey(GetType()))
                {
                    PropertyCache.Add(
                        GetType(),
                        PropertiesExcludingPrototype().ToDictionary(s => s.Name));
                }

                return PropertyCache[GetType()];
            }
        }
amirrajan commented 10 years ago

I'll get a patch out today. Good find.

Sent from my iPhone

On Oct 16, 2013, at 4:40 AM, David Podhola notifications@github.com wrote:

suggested fix:

    private Dictionary<string, PropertyInfo> AutoProperties()
    {
        lock (typeof(Gemini))
        {
            if (!PropertyCache.ContainsKey(GetType()))
            {
                PropertyCache.Add(
                    GetType(),
                    PropertiesExcludingPrototype().ToDictionary(s => s.Name));
            }

            return PropertyCache[GetType()];
        }
    }

— Reply to this email directly or view it on GitHub.

amirrajan commented 10 years ago

Done. Nuget packages pushed too. https://github.com/amirrajan/Oak/commit/9b489509878576572a8d7fdc6570e58baefbb756

On Wed, Oct 16, 2013 at 7:39 AM, Amir Rajan ar@amirrajan.net wrote:

I'll get a patch out today. Good find.

Sent from my iPhone

On Oct 16, 2013, at 4:40 AM, David Podhola notifications@github.com wrote:

suggested fix:

    private Dictionary<string, PropertyInfo> AutoProperties()
    {
        lock (typeof(Gemini))
        {
            if (!PropertyCache.ContainsKey(GetType()))
            {
                PropertyCache.Add(
                    GetType(),
                    PropertiesExcludingPrototype().ToDictionary(s => s.Name));
            }

            return PropertyCache[GetType()];
        }
    }

— Reply to this email directly or view it on GitHubhttps://github.com/amirrajan/Oak/issues/32#issuecomment-26404663 .

akornmeier commented 10 years ago

Just confirming... Is this issue closed now?

amirrajan commented 10 years ago

Yes :-)

Sent from my iPhone

On Nov 6, 2013, at 11:05 AM, Tony Kornmeier notifications@github.com wrote:

Just confirming... Is this issue closed now?

— Reply to this email directly or view it on GitHub.