yongchristophertang / guiceberry

Automatically exported from code.google.com/p/guiceberry
Apache License 2.0
2 stars 1 forks source link

Document the synchronization guiceberry does #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a synchronized static method in your test that calls guiceberry's
setup method.  (Maybe because you need to do some other, non-guiceable
setup in a synchronized manner, and added GuiceBerry setup to that)
2. Have multiple tests in your TestCase class run in parallel
3. Experience deadlocks.

Guiceberry should document that the guiceberry static setup and teardown
methods *should not* be called from inside a static synchronized method on
the test class, or, if they are, that *both* the setup and the teardown
methods need to be called from a statically synchronized method. (in which
case the TestCase class should probably not extend TearDownTestCase)  The
issue is that Guiceberry, in both setup and teardown, examines the
annotations on the TestCase class.

Examining annotations locks the class.  Synchronized static methods also
lock the class.  If the Guiceberry setup method is called from a
synchronized static method but the teardown is not, we have that setup
locks classes in the order (TestCase, GuiceBerry) but teardown locks them
in the order (GuiceBerry, TestCase).

This situation could be mitigated if guiceberry stored enough information
inside GuiceBerryStuff to not need to read the TestCase's annotations
during teardown.

Original issue reported on code.google.com by d...@google.com on 21 Jul 2008 at 1:03

GoogleCodeExporter commented 9 years ago
Daniel, sorry for taking this long to reply. I missed this message til today.

Wow, what an interesting corner case.

I recently changed the way GB tear down is structured, and it will be simple to 
make
it not read the annotation in the case where one uses the "TearDownTestCase"
paradigm. I'll also javadoc tearDown to talk about this (for those brave/fool 
enough
to not use TDTC).

Original comment by zorze...@gmail.com on 16 Sep 2008 at 3:16

GoogleCodeExporter commented 9 years ago
Rev #71 fixes this bug.

Original comment by zorze...@gmail.com on 16 Sep 2008 at 10:31