ramanathan1504 commented on code in PR #4304: URL: https://github.com/apache/logging-log4j2/pull/4304#discussion_r4082064659
########## src/changelog/.2.x.x/4304_fix_smtp_appender_create_appender.xml: ########## @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<entry xmlns="https://logging.apache.org/xml/ns" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + https://logging.apache.org/xml/ns + https://logging.apache.org/xml/ns/log4j-changelog-0.xsd" + type="fixed"> + <issue id="4304" link="https://github.com/apache/logging-log4j2/pull/4304"/> + <description format="asciidoc"> + Fix the deprecated `SmtpAppender.createAppender()` factory method, which threw a `NullPointerException` instead of returning an appender, because it forwarded neither the appender name nor the mail attributes to the builder. Review Comment: ```suggestion Fix `NullPointerException` in the deprecated SmtpAppender.createAppender() factory method. ``` ########## log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SmtpAppenderTest.java: ########## @@ -108,6 +109,59 @@ void testMessageFactorySetSubject() throws MessagingException { assertEquals(subject, builder.build().getSubject()); } + @Test + @SuppressWarnings("deprecation") + void testCreateAppenderForwardsMailAttributes() throws Exception { + final SmtpAppender appender = SmtpAppender.createAppender( + new DefaultConfiguration(), + "Test", + "[email protected]", + "[email protected]", + "[email protected]", + "[email protected]", + "[email protected]", + "Subject Pattern %m", + "smtps", + HOST, + "4711", + "username", + "password", + "false", + "3", + null, + null, + null); + assertNotNull(appender); + assertEquals("Test", appender.getName()); + + // `MailManager` names encode every mail attribute except the password, which is checked on the session below. Review Comment: ```suggestion ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
