Uploaded image for project: 'Geode'
  1. Geode
  2. GEODE-5719

Code Cleanup: Static members are accessed by instance reference

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • tests, wan
    • None

    Description

      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

      {
        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));
      }

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            prhomberg Patrick Rhomberg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: