yu created SLF4J-469: ------------------------ Summary: 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: SLF4J developers list Priority: Critical *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) _______________________________________________ slf4j-dev mailing list slf4j-dev@qos.ch http://mailman.qos.ch/mailman/listinfo/slf4j-dev