CompositeConfiguration doesn’t look correct to me. It makes sense for it to have a null source, but I’m not sure why it should have a null LoggerContext.I think it should be:
super(configurations.get(0).getLoggerContext(), ConfigurationSource.NULL_SOURCE); Either that or getLoggerContext() should do that. Ralph > On Aug 25, 2016, at 9:03 PM, Gary Gregory <garydgreg...@gmail.com> wrote: > > [oops, sent too soon] > > Hi All: > > I'd like to tie up a loose end with callers of > AbstractConfiguration.AbstractConfiguration(LoggerContext, > ConfigurationSource) > > There are four call sites that do this: > > super(null, ConfigurationSource.NULL_SOURCE); > > These are: > - > org.apache.logging.log4j.core.BasicConfigurationFactory.BasicConfiguration.BasicConfiguration() > - > org.apache.logging.log4j.core.config.DefaultConfiguration.DefaultConfiguration() > - org.apache.logging.log4j.core.config.NullConfiguration.NullConfiguration() > - > org.apache.logging.log4j.core.config.composite.CompositeConfiguration.CompositeConfiguration(List<? > extends AbstractConfiguration>) > > I am worried about this last one. > > So I cannot null check the logger context in the AbstractConfiguration ctor: > > protected AbstractConfiguration(LoggerContext loggerContext, final > ConfigurationSource configurationSource) { > this.loggerContext = new WeakReference<>(loggerContext); > // The loggerContext is null for the NullConfiguration class. > // this.loggerContext = new > WeakReference(Objects.requireNonNull(loggerContext, "loggerContext is null")); > this.configurationSource = > Objects.requireNonNull(configurationSource, "configurationSource is null"); > ... > } > > There are a couple of call sites where we could pass in a LC but we'd need to > add the LC to ctor for classes listed above. The default configs usually > include just console logging, but is that straight to the console or via a > ConsoleAppender? > > I could even see adding a ctor > AbstractConfiguration.AbstractConfiguration(NullConfiguration) to make it > obvious that this is the only way is OK to pass null for the logger context. > Then the NullConfiguration ctor does not need to pass null. > > Thoughts? > > Gary > > ---------- Forwarded message ---------- > From: Gary Gregory <garydgreg...@gmail.com <mailto:garydgreg...@gmail.com>> > Date: Thu, Aug 25, 2016 at 8:54 PM > Subject: Tying up loose ends with > AbstractConfiguration.AbstractConfiguration(LoggerContext, > ConfigurationSource) > To: Log4J Developers List <log4j-dev@logging.apache.org > <mailto:log4j-dev@logging.apache.org>> > > > Hi All: > > I'd like to tied up some loose end with Tying up loose ends with > AbstractConfiguration.AbstractConfiguration(LoggerContext, > ConfigurationSource) > > There are three call sites that do this: > > > -- > E-Mail: garydgreg...@gmail.com <mailto:garydgreg...@gmail.com> | > ggreg...@apache.org <mailto:ggreg...@apache.org> > Java Persistence with Hibernate, Second Edition > <http://www.manning.com/bauer3/> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > Spring Batch in Action <http://www.manning.com/templier/> > Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> > Home: http://garygregory.com/ <http://garygregory.com/> > Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory> > > > -- > E-Mail: garydgreg...@gmail.com <mailto:garydgreg...@gmail.com> | > ggreg...@apache.org <mailto:ggreg...@apache.org> > Java Persistence with Hibernate, Second Edition > <http://www.manning.com/bauer3/> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > Spring Batch in Action <http://www.manning.com/templier/> > Blog: http://garygregory.wordpress.com <http://garygregory.wordpress.com/> > Home: http://garygregory.com/ <http://garygregory.com/> > Tweet! http://twitter.com/GaryGregory <http://twitter.com/GaryGregory>