lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dawid Weiss <>
Subject Re: Odd test failures
Date Mon, 01 Sep 2014 20:50:28 GMT
Yes. It's hard to ban it completely; unless it's a constant primitive
an assignment to a field will be moved to a static initializer. I
would personally disallow it, but I can also feel the pain others must
feel when they're forced to @BeforeClass every single thing, however


On Mon, Sep 1, 2014 at 10:44 PM, Ramkumar R. Aiyengar
<> wrote:
> On Mon, Sep 1, 2014 at 8:54 PM, Dawid Weiss <>
> wrote:
>> To be honest you shouldn't have any static initializers at all,
>> including final fields (unless they're really immutable, simple data
>> types). The reason for this is that static initializers (including
>> those for final field assignments) are invoked when the class is
>> initialized and this may be happening outside of the scope of the test
>> runner. @BeforeClass or class rules are the way to "properly"
>> initialize before-test-suite things.
> I was trying to see if I hack something to see if this can be checked and
> realized there's a StaticFieldsInvariantRule set up in LuceneTestCase which
> was checking for memory leaks on exactly such fields. So I am guessing we
> are still using them a bit :) (and a quick grep confirms the same..)

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message