Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-552

Logic of isInstanceOf are not consistent in log4j-api's Log4jMarker and log4j-slf4j-impl's MarkerWrapper

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • 2.0-rc1
    • None
    • API, SLF4J Bridge
    • None

    Description

      The logic of isInstanceOf is not consistent for Marker implements in log4j-api's Log4jMarker and log4j-slf4j-iml's MarkerWrapper.
      In Log4jMarker
      ---------------------------------------------
      @Override
      public boolean isInstanceOf(final String name) {
      if (name == null)

      { throw new IllegalArgumentException("A marker name is required"); }

      Marker toTest = this;
      do {
      if (name.equals(toTest.getName()))

      { return true; }

      toTest = toTest.getParent();
      } while (toTest != null);
      return false;
      }
      ---------------------------------------------
      in MarkerWrapper
      ---------------------------------------------
      @Override
      public boolean isInstanceOf(final Marker marker) {
      if (marker == null)

      { throw new IllegalArgumentException("A marker parameter is required"); }

      if (marker instanceof MarkerWrapper)

      { return contains((MarkerWrapper) marker); }

      else

      { return contains(marker.getName()); }

      }

      @Override
      public boolean isInstanceOf(final String name) {
      if (name == null)

      { throw new IllegalArgumentException("A marker name is required"); }

      return contains(name);
      }
      -----------------------------------------

      in Log4jMarker, the isInstanceOf means the marker is instance of itself or its parent

      in MarkerWrapper, the isInstance of means the marker is instance of itself or its children

      Attachments

        Activity

          People

            Unassigned Unassigned
            rainj RainJ
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: