efegokdemir commented on code in PR #4360:
URL: https://github.com/apache/logging-log4j2/pull/4360#discussion_r4149807251
##########
log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/HttpAppenderTest.java:
##########
@@ -271,6 +272,30 @@ void testAppendCustomHeader() throws Exception {
.withRequestBody(containing("\"message\" : \"" + LOG_MESSAGE +
"\"")));
}
+ @Test
+ void testAppendSkipsHeaderWithInvalidRuntimeValue() throws Exception {
+
WIRE_MOCK.stubFor(post(urlEqualTo("/test/log4j/")).willReturn(SUCCESS_RESPONSE));
+ ThreadContext.put("tenant", "tenant\nwith-line-break");
+ try {
+ final Appender appender = HttpAppender.newBuilder()
+ .setName("Http")
+ .setLayout(JsonLayout.createDefaultLayout())
+ .setConfiguration(CONFIGURATION)
+ .setIgnoreExceptions(false)
+ .setUrl(wireMockUrl("/test/log4j/", false, false))
+ .setHeaders(new Property[]
{Property.createProperty("X-Tenant", "${ctx:tenant}")})
+ .build();
+ appender.append(createLogEvent());
+ } finally {
+ ThreadContext.remove("tenant");
+ }
+
+ WIRE_MOCK.verify(postRequestedFor(urlEqualTo("/test/log4j/"))
+ .withoutHeader("X-Tenant")
+ .withHeader("Content-Type", containing("application/json"))
+ .withRequestBody(containing("\"message\" : \"" + LOG_MESSAGE +
"\"")));
Review Comment:
Implemented in the current HEAD . The regression test uses and asserts the
WARN status message contains , so removing the warning now fails the test. The
requested changelog entry for #4352 is also present. The other formatting
suggestion was applied in the same branch.
--
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]