You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by Kirk Lund <kl...@apache.org> on 2023/01/22 14:15:59 UTC

Bad Practice: Static constant values set by system properties

Sai and I worked together yesterday and fixed almost all of the failing
unit tests in the new build we're trying to set up. I think we have one
failure remaining. Most of the failures we fixed turned out to be caused by
new code that was committed to Geode in 2022 that causes values in static
constants that are set by system properties breaking later unit tests that
will only pass if the constant has the default value.

I want to point out that using system properties to set the values in a
static constant is definitely an anti-pattern or bad practice that should
be avoided going forward. It pollutes the JVM for later unit tests and
cannot be unset because constants are defined as final and static.

In the coming weeks, I plan to update the Apache Geode wiki to spell out
the anti-pattern bad practices that we need to avoid going forward and this
will definitely be one of them.

Thanks,
Kirk

Re: Bad Practice: Static constant values set by system properties

Posted by Mark Bretl <mb...@apache.org>.
Thank you for the effort Kirk and Sai!

--Mark

On Sun, Jan 22, 2023 at 7:16 AM Kirk Lund <kl...@apache.org> wrote:

> Sai and I worked together yesterday and fixed almost all of the failing
> unit tests in the new build we're trying to set up. I think we have one
> failure remaining. Most of the failures we fixed turned out to be caused by
> new code that was committed to Geode in 2022 that causes values in static
> constants that are set by system properties breaking later unit tests that
> will only pass if the constant has the default value.
>
> I want to point out that using system properties to set the values in a
> static constant is definitely an anti-pattern or bad practice that should
> be avoided going forward. It pollutes the JVM for later unit tests and
> cannot be unset because constants are defined as final and static.
>
> In the coming weeks, I plan to update the Apache Geode wiki to spell out
> the anti-pattern bad practices that we need to avoid going forward and this
> will definitely be one of them.
>
> Thanks,
> Kirk
>