class101 opened a new issue, #1946:
URL: https://github.com/apache/logging-log4j2/issues/1946

   ## Description
   
   The following fix 
[LOG4J2-3660](https://issues.apache.org/jira/browse/LOG4J2-3660) is changing 
the behavior of %notEmpty and I'm wondering if this is intended or not, or if 
I'm using it the correct way to achieve the following behavior
   
   Up to **2.20.0**, I'm using the following template which is working 
perfectly :
   
   ```xml
   <Property 
name="USER_ID">%notEmpty{[%notEmpty{%X{codeEmploye}-}%notEmpty{%X{userId}-}%notEmpty{%X{sessionId}}]
 }</Property>
   ```
   
   The following expected results are generated:
   
   - When the MDC map has no **codeEmploye**, **userId** or **sessionId** keys 
nothing is printed
   
   But after upgrading to **2.21.0**+
   
   - When the MDC map has no **codeEmploye**, **userId** or **sessionId** keys 
, `[--]` is printed
   
   This happens before entering into my LoggingFilter, before touching the MDC 
map, straight from the Spring Boot application Startup
   
   ## Configuration
   
   **Version:** [Log4j version]
   
   - 2.20.0 OK - working as intended
   - 2.21.0 KO - no more working as intended
   
   **Operating system:** [OS and version]
   
   - Windows 10 (19043.2364)
   
   **JDK:** [JDK distribution and version]
   
   - OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
   
   ## Logs
   
   The following is a 2.20.0 startup Log working as intended showing 
"[admin-47D3117E24FD612CD8D6231549606BA5]"
   ```
    INFO 15540 - [           main] o.s.t.c.s.AbstractContextLoader          : 
Could not detect default resource locations for test class 
[fr.cl.extranet.it.config.ITApplication]: no resource found for suffixes 
{-context.xml, Context.groovy}.
    INFO 15540 - [           main] .b.t.c.SpringBootTestContextBootstrapper : 
Loaded default TestExecutionListener class names from location 
[META-INF/spring.factories]: 
[org.springframework.test.context.web.ServletTestExecutionListener, 
org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener,
 org.springframework.test.context.event.ApplicationEventsTestExecutionListener, 
org.springframework.test.context.support.DependencyInjectionTestExecutionListener,
 org.springframework.test.context.support.DirtiesContextTestExecutionListener, 
org.springframework.test.context.transaction.TransactionalTestExecutionListener,
 org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, 
org.springframework.test.context.event.EventPublishingTestExecutionListener, 
org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, 
org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, 
org.springframework.boot.test.autoconfigure.restdocs.
 RestDocsTestExecutionListener, 
org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener,
 
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener,
 
org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener,
 
org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener]
    INFO 15540 - [           main] .b.t.c.SpringBootTestContextBootstrapper : 
Using TestExecutionListeners: 
[org.springframework.test.context.web.ServletTestExecutionListener@68e7c8c3, 
org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@319c3a25,
 
org.springframework.test.context.event.ApplicationEventsTestExecutionListener@238bfd6c,
 
org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@ef1695a,
 
org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@58860997,
 
org.springframework.test.context.support.DirtiesContextTestExecutionListener@81b5db0,
 
org.springframework.test.context.transaction.TransactionalTestExecutionListener@7487b142,
 
org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@7139bd31, 
org.springframework.test.context.event.EventPublishingTestExecutionListener@199bc830,
 
org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@4b3fe06e,
 org.springfram
 ework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@27b45ea, 
org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@3e17a0a1,
 
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@790a251b,
 
org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@4d8286c4,
 
org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@150ede8b]
    INFO 15540 - [           main] f.c.e.c.u.CrelogInitUtils                : 
    INFO 15540 - [           main] f.c.e.c.u.CrelogInitUtils                :   
.   ____          _            __ _ _
    INFO 15540 - [           main] f.c.e.c.u.CrelogInitUtils                :  
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    INFO 15540 - [           main] f.c.e.c.u.CrelogInitUtils                : ( 
( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
    INFO 15540 - [           main] f.c.e.c.u.CrelogInitUtils                :  
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
    INFO 15540 - [           main] f.c.e.c.u.CrelogInitUtils                :   
'  |____| .__|_| |_|_| |_\__, | / / / /
    INFO 15540 - [           main] f.c.e.c.u.CrelogInitUtils                :  
=========|_|==============|___/=/_/_/_/
    INFO 15540 - [           main] f.c.e.c.u.CrelogInitUtils                :  
:: Spring Boot ::               (v2.7.17)
    INFO 15540 - [           main] f.c.e.c.u.CrelogInitUtils                : 
    INFO 15540 - [kground-preinit] o.h.v.i.u.Version                        : 
HV000001: Hibernate Validator 6.2.5.Final
    INFO 15540 - [           main] f.c.e.i.c.ITApplication                  : 
Starting ITApplication using Java 11.0.11 on w10vm015 with PID 15540 
(D:\sources\crelog_cl-extranet\cl-extranet-web\target\test-classes started by 
devado1 in D:\sources\crelog_cl-extranet\cl-extranet-web)
   DEBUG 15540 - [           main] f.c.e.i.c.ITApplication                  : 
Running with Spring Boot v2.7.17, Spring v5.3.30
    INFO 15540 - [           main] f.c.e.i.c.ITApplication                  : 
The following 1 profile is active: "devmock"
    INFO 22772 - [o-auto-1-exec-6] f.c.e.c.s.CLAuthenticationSuccessHandler : 
Droits : 
D,D_etendu,M,M_etendu,P,PPR,PPR_etendu,P_etendu,R,RDA,RDA_etendu,RSE,RSE_etendu,R_etendu,SE,SE_etendu,TA,TA_etendu,TB,TB_etendu,consultdos,consultdos_etendu,courriers,courriers_etendu,creersaisines,gcca,gci,gh,imprrecouvr,modifdos,statsrecouvr,tousdossrecouvr,vcca,vci,ROLE_ADMIN
   DEBUG 22772 - [-auto-1-exec-10] o.h.SQL                                  : 
[admin-47D3117E24FD612CD8D6231549606BA5] select reseaubanc0_.CD_SIGLE as 
cd_sigle1_185_, reseaubanc0_.CD_ACCES_NUIT as cd_acces2_185_, 
reseaubanc0_.CD_BQUE as cd_bque3_185_, reseaubanc0_.CD_TARIF as cd_tarif4_185_, 
reseaubanc0_.CD_COTE as cd_cote11_185_, reseaubanc0_.DT_DEB_TARIF as 
dt_deb_t5_185_, reseaubanc0_.DT_FIN_TARIF as dt_fin_t6_185_, 
reseaubanc0_.FL_IBAN as fl_iban7_185_, reseaubanc0_.LL_LOGO as ll_logo8_185_, 
reseaubanc0_.LL_RAISOC1 as ll_raiso9_185_, reseaubanc0_.LL_RAISOC2 as 
ll_rais10_185_ from TQQURESO reseaubanc0_ where reseaubanc0_.CD_SIGLE=?
   TRACE 22772 - [-auto-1-exec-10] o.h.t.d.s.BasicBinder                    : 
[admin-47D3117E24FD612CD8D6231549606BA5] binding parameter [1] as [VARCHAR] - 
[CL]
   DEBUG 22772 - [-auto-1-exec-10] o.h.SQL                                  : 
[admin-47D3117E24FD612CD8D6231549606BA5] select coteorgani0_.CD_COTE as 
cd_cote1_85_0_, coteorgani0_.LL_COTE as ll_cote2_85_0_ from TQQPCACT 
coteorgani0_ where coteorgani0_.CD_COTE=?
   TRACE 22772 - [-auto-1-exec-10] o.h.t.d.s.BasicBinder                    : 
[admin-47D3117E24FD612CD8D6231549606BA5] binding parameter [1] as [CHAR] - [7]
   DEBUG 22772 - [-auto-1-exec-10] o.h.SQL                                  : 
[admin-47D3117E24FD612CD8D6231549606BA5] select partenaire0_.CD_SIGLE as 
cd_sigle1_77_0_, partenaire0_.CD_PARTENAIRE as cd_parte2_77_0_, 
partenaire1_.CD_PARTENAIRE as cd_parte1_189_1_, partenaire1_.LL_LIBELLE as 
ll_libel2_189_1_, partenaire1_.FL_REPONSE_DIFFERE as fl_repon3_189_1_ from 
TQQLWSCP partenaire0_ inner join TQQWSCP partenaire1_ on 
partenaire0_.CD_PARTENAIRE=partenaire1_.CD_PARTENAIRE where 
partenaire0_.CD_SIGLE=?
   TRACE 22772 - [-auto-1-exec-10] o.h.t.d.s.BasicBinder                    : 
[admin-47D3117E24FD612CD8D6231549606BA5] binding parameter [1] as [VARCHAR] - 
[CL]
   DEBUG 22772 - [-auto-1-exec-10] o.h.SQL                                  : 
[admin-47D3117E24FD612CD8D6231549606BA5] select menu0_.ID_MENU as col_0_0_ from 
TQQNMENU menu0_ where menu0_.LL_NAME=?
   TRACE 22772 - [-auto-1-exec-10] o.h.t.d.s.BasicBinder                    : 
[admin-47D3117E24FD612CD8D6231549606BA5] binding parameter [1] as [VARCHAR] - 
[back]
   DEBUG 22772 - [-auto-1-exec-10] o.h.SQL                                  : 
[admin-47D3117E24FD612CD8D6231549606BA5] select menu0_.ID_MENU as id_menu1_83_, 
menu0_.CD_ACESS_P_CONSULT as cd_acess2_83_, menu0_.CD_ACESS_INTERNE as 
cd_acess3_83_, menu0_.CD_ACESS_P_PROD as cd_acess4_83_, 
menu0_.CD_ACESS_P_RECOUVREMENT as cd_acess5_83_, menu0_.LL_DONAME as 
ll_donam6_83_, menu0_.LL_URL as ll_url7_83_, menu0_.CD_SIGLE as cd_sigle8_83_, 
menu0_.ID_PARTNER as id_partn9_83_, menu0_.ID_PERE as id_pere10_83_, 
menu0_.CD_INITIO as cd_init11_83_, menu0_.CD_JOURNUIT as cd_jour12_83_, 
menu0_.LL_LEVEL as ll_leve13_83_, menu0_.LL_NAME as ll_name14_83_, 
menu0_.LL_MENU_DONAME as ll_menu15_83_, menu0_.LL_SHORTCUT as ll_shor16_83_, 
menu0_.ID_PAGE as id_page19_83_, menu0_.LL_TYPE as ll_type17_83_, 
menu0_.LL_MENU_URL as ll_menu18_83_ from TQQNMENU menu0_ where 
menu0_.CD_SIGLE=? and menu0_.ID_PERE=37 and (menu0_.CD_JOURNUIT=? or 
menu0_.CD_JOURNUIT=?) and (menu0_.CD_INITIO=? or menu0_.CD_INITIO=?) order by 
menu
 0_.ID_MENU asc
   TRACE 22772 - [-auto-1-exec-10] o.h.t.d.s.BasicBinder                    : 
[admin-47D3117E24FD612CD8D6231549606BA5] binding parameter [1] as [VARCHAR] - []
   TRACE 22772 - [-auto-1-exec-10] o.h.t.d.s.BasicBinder                    : 
[admin-47D3117E24FD612CD8D6231549606BA5] binding parameter [2] as [CHAR] - [J]
   ```
   
   The following is a 2.21.0 startup Log not working as intended showing [--] 
straight from Spring Boot startup and it is showing an extra - between admin 
and the sessionId
   
   ```
    INFO 27172 - [           main] o.s.t.c.s.AbstractContextLoader          : 
[--] Could not detect default resource locations for test class 
[fr.cl.extranet.it.config.ITApplication]: no resource found for suffixes 
{-context.xml, Context.groovy}.
    INFO 27172 - [           main] .b.t.c.SpringBootTestContextBootstrapper : 
[--] Loaded default TestExecutionListener class names from location 
[META-INF/spring.factories]: 
[org.springframework.test.context.web.ServletTestExecutionListener, 
org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener,
 org.springframework.test.context.event.ApplicationEventsTestExecutionListener, 
org.springframework.test.context.support.DependencyInjectionTestExecutionListener,
 org.springframework.test.context.support.DirtiesContextTestExecutionListener, 
org.springframework.test.context.transaction.TransactionalTestExecutionListener,
 org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, 
org.springframework.test.context.event.EventPublishingTestExecutionListener, 
org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, 
org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, 
org.springframework.boot.test.autoconfigure.rest
 docs.RestDocsTestExecutionListener, 
org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener,
 
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener,
 
org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener,
 
org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener]
    INFO 27172 - [           main] .b.t.c.SpringBootTestContextBootstrapper : 
[--] Using TestExecutionListeners: 
[org.springframework.test.context.web.ServletTestExecutionListener@bfc14b9, 
org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@fb6097b,
 
org.springframework.test.context.event.ApplicationEventsTestExecutionListener@2dfe5525,
 
org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@1290c49,
 
org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@6a9b9909,
 
org.springframework.test.context.support.DirtiesContextTestExecutionListener@55d9b8f0,
 
org.springframework.test.context.transaction.TransactionalTestExecutionListener@a518813,
 
org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@43d38654, 
org.springframework.test.context.event.EventPublishingTestExecutionListener@75361cf6,
 
org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@6d303498,
 org.springf
 
ramework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@6ba7383d,
 
org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@3419e23b,
 
org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@710d89e2,
 
org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@1d75e7af,
 
org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@4fc142ec]
    INFO 27172 - [           main] f.c.e.c.u.CrelogInitUtils                : 
[--] 
    INFO 27172 - [           main] f.c.e.c.u.CrelogInitUtils                : 
[--]   .   ____          _            __ _ _
    INFO 27172 - [           main] f.c.e.c.u.CrelogInitUtils                : 
[--]  /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
    INFO 27172 - [           main] f.c.e.c.u.CrelogInitUtils                : 
[--] ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
    INFO 27172 - [           main] f.c.e.c.u.CrelogInitUtils                : 
[--]  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
    INFO 27172 - [           main] f.c.e.c.u.CrelogInitUtils                : 
[--]   '  |____| .__|_| |_|_| |_\__, | / / / /
    INFO 27172 - [           main] f.c.e.c.u.CrelogInitUtils                : 
[--]  =========|_|==============|___/=/_/_/_/
    INFO 27172 - [           main] f.c.e.c.u.CrelogInitUtils                : 
[--]  :: Spring Boot ::               (v2.7.17)
    INFO 27172 - [           main] f.c.e.c.u.CrelogInitUtils                : 
[--] 
    INFO 27172 - [kground-preinit] o.h.v.i.u.Version                        : 
[--] HV000001: Hibernate Validator 6.2.5.Final
    INFO 27172 - [           main] f.c.e.i.c.ITApplication                  : 
[--] Starting ITApplication using Java 11.0.11 on w10vm015 with PID 27172 
(D:\sources\crelog_cl-extranet\cl-extranet-web\target\test-classes started by 
devado1 in D:\sources\crelog_cl-extranet\cl-extranet-web)
   DEBUG 27172 - [           main] f.c.e.i.c.ITApplication                  : 
[--] Running with Spring Boot v2.7.17, Spring v5.3.30
    INFO 27172 - [           main] f.c.e.i.c.ITApplication                  : 
[--] The following 1 profile is active: "devmock"
   TRACE 27172 - [o-auto-1-exec-2] o.h.t.d.s.BasicBinder                    : 
[--] binding parameter [3] as [VARCHAR] - [CL]
   TRACE 27172 - [o-auto-1-exec-2] o.h.t.d.s.BasicBinder                    : 
[--] binding parameter [4] as [TIMESTAMP] - [Mon Nov 06 12:03:09 CET 2023]
   TRACE 27172 - [o-auto-1-exec-2] o.h.t.d.s.BasicBinder                    : 
[--] binding parameter [5] as [VARCHAR] - [09750036]
   TRACE 27172 - [o-auto-1-exec-2] o.h.t.d.s.BasicBinder                    : 
[--] binding parameter [6] as [VARCHAR] - [Mozilla/5.0 (Windows NT 10.0; Win64; 
x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/119.0.6045.106 
Safari/537.36]
    INFO 27172 - [o-auto-1-exec-2] f.c.e.c.s.CLAuthenticationSuccessHandler : 
[--] Droits : 
D,D_etendu,M,M_etendu,P,PPR,PPR_etendu,P_etendu,R,RDA,RDA_etendu,RSE,RSE_etendu,R_etendu,SE,SE_etendu,TA,TA_etendu,TB,TB_etendu,consultdos,consultdos_etendu,courriers,courriers_etendu,creersaisines,gcca,gci,gh,imprrecouvr,modifdos,statsrecouvr,tousdossrecouvr,vcca,vci,ROLE_ADMIN
   DEBUG 27172 - [o-auto-1-exec-3] o.h.SQL                                  : 
[admin--82BC7FE11FBA418DE348B937A5939D79] select reseaubanc0_.CD_SIGLE as 
cd_sigle1_185_, reseaubanc0_.CD_ACCES_NUIT as cd_acces2_185_, 
reseaubanc0_.CD_BQUE as cd_bque3_185_, reseaubanc0_.CD_TARIF as cd_tarif4_185_, 
reseaubanc0_.CD_COTE as cd_cote11_185_, reseaubanc0_.DT_DEB_TARIF as 
dt_deb_t5_185_, reseaubanc0_.DT_FIN_TARIF as dt_fin_t6_185_, 
reseaubanc0_.FL_IBAN as fl_iban7_185_, reseaubanc0_.LL_LOGO as ll_logo8_185_, 
reseaubanc0_.LL_RAISOC1 as ll_raiso9_185_, reseaubanc0_.LL_RAISOC2 as 
ll_rais10_185_ from TQQURESO reseaubanc0_ where reseaubanc0_.CD_SIGLE=?
   TRACE 27172 - [o-auto-1-exec-3] o.h.t.d.s.BasicBinder                    : 
[admin--82BC7FE11FBA418DE348B937A5939D79] binding parameter [1] as [VARCHAR] - 
[CL]
   DEBUG 27172 - [o-auto-1-exec-3] o.h.SQL                                  : 
[admin--82BC7FE11FBA418DE348B937A5939D79] select coteorgani0_.CD_COTE as 
cd_cote1_85_0_, coteorgani0_.LL_COTE as ll_cote2_85_0_ from TQQPCACT 
coteorgani0_ where coteorgani0_.CD_COTE=?
   ```
   ## Reproduction
   
   I'm attaching log4j2.xml and LogFilter.java
   
   
   (To note that the issue is shown before reaching LogFilter.java)
   
   [An isolated test reproducing the test.
   JUnit tests similar to the ones in the code base are extremely appreciated.]
   


-- 
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]

Reply via email to