Patrick Rhomberg created GEODE-5719:
---------------------------------------

             Summary: Code Cleanup: Static members are accessed by instance 
reference
                 Key: GEODE-5719
                 URL: https://issues.apache.org/jira/browse/GEODE-5719
             Project: Geode
          Issue Type: Bug
            Reporter: Patrick Rhomberg


Most of these are innocuous and represent only a deviation from best practices.

Some invoke {{new SomeClass().staticMethod()}}, representing a trivial 
instantiation cost that is unlikely to be significant.

I am most concerned by the use in {{ThreadIdentifierJUnitTest}}, which includes 
the static-method {{matches}} in what appear to be misguided assertions.  For 
instance
{noformat}
{
  long real_tid_with_wan = ThreadIdentifier.getRealThreadIDIncludingWan(wan1);
  assertEquals(42, ThreadIdentifier.getRealThreadID(real_tid_with_wan));
  assertTrue(ThreadIdentifier.isParallelWANThreadID(real_tid_with_wan));
  assertTrue(WanType.PRIMARY.matches(real_tid_with_wan));
}
// ...
{
  long real_tid_with_wan = ThreadIdentifier.getRealThreadIDIncludingWan(wan3);
  assertEquals(42, ThreadIdentifier.getRealThreadID(real_tid_with_wan));
  assertTrue(ThreadIdentifier.isParallelWANThreadID(real_tid_with_wan));
  assertTrue(WanType.PARALLEL.matches(real_tid_with_wan));
}{noformat}
Because {{PRIMARY}} and {{PARALLEL}} are instantiated fields of {{WanType}}, 
and because {{matches}} is a static method, these assertions are equivalent, 
while at the same time the developer who wrote these likely believed these 
assertions were distinct.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to