[slf4j-dev] [JIRA] (SLF4J-469) Potential memory leaks if there is no underlying implementation
QOS.CH (JIRA)
noreply-jira at qos.ch
Tue Dec 10 08:50:00 CET 2019
[ https://jira.qos.ch/browse/SLF4J-469?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=19994#comment-19994 ]
Ceki Gülcü commented on SLF4J-469:
----------------------------------
[PR 228| https://github.com/qos-ch/slf4j/pull/228] looks very good.
> Potential memory leaks if there is no underlying implementation
> ---------------------------------------------------------------
>
> Key: SLF4J-469
> URL: https://jira.qos.ch/browse/SLF4J-469
> Project: SLF4J
> Issue Type: Bug
> Affects Versions: 1.7.26
> Environment: java 8
> slf4j 1.7.26
>
> Reporter: yu
> Assignee: Ceki Gülcü
> Priority: Critical
> Labels: logging, substitution
> Fix For: 2.0.0-alpha2, 1.7.29
>
>
>
> *If I don't have 'logback' 'log4j'...... Implementation class*
> The problem lies in the method
> *public static ILoggerFactory getILoggerFactory()*
> first Thread1:
> {code:java}
> if (INITIALIZATION_STATE == UNINITIALIZED) {
> init.....
> }
> {code}
> secode Thread2:
> {code:java}
> case ONGOING_INITIALIZATION:
> return SUBST_FACTORY;{code}
> obtained "SUBST_FACTORY",
> and obtained "SubstituteLogger"
>
> third:
> Thread1:
> {code:java}
> //init failed cache "NoClassDefFoundError"
> INITIALIZATION_STATE = NOP_FALLBACK_INITIALIZATION;
> {code}
> *The SubstituteLogger obtained by Thread2 will always output the log to the queue until the memory overflows.*
> {code:java}
> // code placeholder
> synchronized public Logger getLogger(String name) {
> SubstituteLogger logger = loggers.get(name);
> if (logger == null) {
> logger = new SubstituteLogger(name, eventQueue, postInitialization);
> loggers.put(name, logger);
> }
> return logger;
> }
> public void info(String msg) {
> delegate().info(msg);
> }
> Logger delegate() {
> if(_delegate != null) { //_delegate== null forever
> return _delegate;
> }
> if(createdPostInitialization) { createdPostInitialization == false forever
> return NOPLogger.NOP_LOGGER;
> } else {
> return getEventRecordingLogger();
> }
> }
> {code}
>
>
>
>
--
This message was sent by Atlassian JIRA
(v7.3.1#73012)
More information about the slf4j-dev
mailing list