Hi, 2015-11-14 6:41 GMT+02:00 Konstantin Kolinko <knst.koli...@gmail.com>: > > 2015-11-13 14:02 GMT+03:00 <violet...@apache.org>: > > Author: violetagg > > Date: Fri Nov 13 11:02:12 2015 > > New Revision: 1714185 > > > > URL: http://svn.apache.org/viewvc?rev=1714185&view=rev > > Log: > > Merged revision 1659184 from tomcat/trunk: > > Fix FindBugs warnings re possible Logger configuration loss > > > > Modified: > > tomcat/tc7.0.x/trunk/ (props changed) > > tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Tomcat.java > > > Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Tomcat.java > > URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Tomcat.java?rev=1714185&r1=1714184&r2=1714185&view=diff > > ============================================================================== > > --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Tomcat.java (original) > > +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/Tomcat.java Fri Nov 13 11:02:12 2015 > > @@ -24,8 +24,10 @@ import java.net.URL; > > import java.security.Principal; > > import java.util.ArrayList; > > import java.util.HashMap; > > +import java.util.HashSet; > > import java.util.List; > > import java.util.Map; > > +import java.util.Set; > > import java.util.Stack; > > import java.util.jar.JarEntry; > > import java.util.jar.JarFile; > > @@ -125,6 +127,13 @@ import org.apache.catalina.realm.RealmBa > > * @author Costin Manolache > > */ > > public class Tomcat { > > + // Some logging implementations use weak references for loggers so there is > > + // the possibility that logging configuration could be lost if GC runs just > > + // after Loggers are configured but before they are used. The purpose of > > + // this Sety is to retain strong references to explicitly configured loggers > > + // so that configuration is not lost. > > + private final Set<Logger> pinnedLoggers = new HashSet<Logger>(); > > + > > // Single engine, service, server, connector - few cases need more, > > // they can use server.xml > > protected Server server; > > @@ -679,16 +688,20 @@ public class Tomcat { > > */ > > public void setSilent(boolean silent) { > > for (String s : silences) { > > + Logger logger = Logger.getLogger(s); > > + pinnedLoggers.add(logger); > > if (silent) { > > - Logger.getLogger(s).setLevel(Level.WARNING); > > + logger.setLevel(Level.WARNING); > > } else { > > - Logger.getLogger(s).setLevel(Level.INFO); > > + logger.setLevel(Level.INFO); > > } > > } > > } > > > > private void silence(Host host, String ctx) { > > - Logger.getLogger(getLoggerName(host, ctx)).setLevel(Level.WARNING); > > + Logger logger = Logger.getLogger(getLoggerName(host, ctx)); > > + pinnedLoggers.add(logger); > > + logger.setLevel(Level.WARNING); > > } > > > > private String getLoggerName(Host host, String ctx) { > > > I think it would be better for "pinnedLoggers" to be a Map<String, Logger>. > > My concern is that Logger.equals() is essentially Object.equals(). As > such, there is no easy way to remove/replace a logger once it has been > added to that set. > > On another hand, loggers are keyed by a string name, so I think that > name can be used as a key.
Thanks for the review. I changes the structure to Map<String, Logger>. Regards, Violeta > Best regards, > Konstantin Kolinko > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org >