Git Product home page Git Product logo

Comments (8)

danielnaber avatar danielnaber commented on August 20, 2024

I guess this could be fixed by using this code in UnifierConfiguration?

equivalenceTypes = Collections.synchronizedMap(new HashMap<EquivalenceTypeLocator, Element>());
equivalenceFeatures = Collections.synchronizedMap(new HashMap<String, List<String>>());

from languagetool.

milekpl avatar milekpl commented on August 20, 2024

Hm, seems sensible to me. Did you try it?

from languagetool.

danielnaber avatar danielnaber commented on August 20, 2024

I cannot reproduce the bug, so there's not much I can try (except running the tests and that works).

from languagetool.

slotties avatar slotties commented on August 20, 2024

Urg, that sure is a problem. The UnifierConfiguration was supposed to be
immutable once the language is completely initialized while the Unifier
(created by a UnifierConfiguration) is stateful. A synchronized map (or
java.util.ConcurrentHashMap) is a temporary workaround, but I'd prefer them
to be cached somehow to improve the speed of creating a JLanguageTool.

I think we should use a ConcurrentHashMap for now, because at least
Unifier.startNextToken uses the keySet() of
UnifierConfiguration.equivalenceFeatures and a Collections.synchronizedMap
is supposed to be synchronized externally in such cases:
--- snip ---
It is imperative that the user manually synchronize on the returned map
when iterating over any of its collection views:
[...]
--- snip ---

btw, I guess it's a good time to share my thoughts on how I wanted to
improve rule loading anyway. The idea is to move loaded rules to either an
own structure or to the language. In both cases the rules are then provided
to the JLanguageTool rather than being loaded by the JLanguageTool itself.
This change allows the (API-)user to cache/hold the rules and set up a
JLanguageTool very fast (in case he uses rules). But I don't know when I
actually start working on it (maybe in the next days, because it's a long
weekend), so I'm fine with implementing a workaround for now, as mentioned
above.

On Tue, Oct 1, 2013 at 8:55 PM, Daniel Naber [email protected]:

I guess this could be fixed by using this code in UnifierConfiguration?

equivalenceTypes = Collections.synchronizedMap(new HashMap<EquivalenceTypeLocator, Element>());
equivalenceFeatures = Collections.synchronizedMap(new HashMap<String, List>());


Reply to this email directly or view it on GitHubhttps://github.com//issues/13#issuecomment-25477608
.

from languagetool.

slotties avatar slotties commented on August 20, 2024

I just committed a fix that seems to work. Well, I could reproduce the problem a few times with the FrenchConcurrencyTest. The HashMaps has been replaced by ConcurrentHashMaps and the ArrayList stored as value in the equivalenceFeatures has been replaced by a CopyOnWriteArrayList. The later change is 'just in case'.

I was not able to reproduce the bug in the HTTPServerLoadTest, so I'm keen to see if you can still reproduce the bug.

from languagetool.

danielnaber avatar danielnaber commented on August 20, 2024

I could never reproduce it, it only happened once (but I didn't try running the test for hours...). Could you please document your fix in CHANGES.txt?

from languagetool.

slotties avatar slotties commented on August 20, 2024

Done.

from languagetool.

slotties avatar slotties commented on August 20, 2024

I'll close this issue as it should've been fixed now. Issue #14 might change something on this fix, hopefully the removal of the concurrent collections that were implemented as workaround.

from languagetool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.