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

Remove deprecation on MessageSupplier lambda functions in Logger API

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.6
    • Fix Version/s: 2.8.1
    • Component/s: API
    • Labels:
      None

      Description

      The changes done in LOG4J2-1286 to deprecate MessageSupplier were not properly tested in practice. Using log4j-api ever since the deprecation, the following code causes deprecation warnings:

      logger.info(() -> new SimpleMessage("Hello, world!"));
      

      This is because the compiler interprets this as a MessageSupplier instead of the more generic Supplier<Message> version which is the intended API. Although manual use of MessageSupplier should be discouraged, users should not have to manually cast the above lambda just to prevent a deprecation warning:

      logger.info((Supplier<Message>) () -> new SimpleMessage("Hello, world!"));
      

      MessageSupplier should become a normal part of log4j-api with a note on both it and Supplier<T> that these interfaces would be removed in a log4j-api 3.0 release and replaced with the Java 8 version.

        Attachments

          Activity

            People

            • Assignee:
              jvz Matt Sicker
              Reporter:
              jvz Matt Sicker
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: