Modified: websites/production/commons/content/proper/commons-logging/xref/org/apache/commons/logging/impl/LogFactoryImpl.html ============================================================================== --- websites/production/commons/content/proper/commons-logging/xref/org/apache/commons/logging/impl/LogFactoryImpl.html (original) +++ websites/production/commons/content/proper/commons-logging/xref/org/apache/commons/logging/impl/LogFactoryImpl.html Sun Mar 24 17:59:10 2024 @@ -271,12 +271,12 @@ <a class="jxr_linenumber" name="L263" href="#L263">263</a> <em class="jxr_javadoccomment"> * This value is initialized by {@code getLogConstructor()},</em> <a class="jxr_linenumber" name="L264" href="#L264">264</a> <em class="jxr_javadoccomment"> * and then returned repeatedly.</em> <a class="jxr_linenumber" name="L265" href="#L265">265</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L266" href="#L266">266</a> <strong class="jxr_keyword">protected</strong> Constructor logConstructor; +<a class="jxr_linenumber" name="L266" href="#L266">266</a> <strong class="jxr_keyword">protected</strong> Constructor<?> logConstructor; <a class="jxr_linenumber" name="L267" href="#L267">267</a> <a class="jxr_linenumber" name="L268" href="#L268">268</a> <em class="jxr_javadoccomment">/**</em> <a class="jxr_linenumber" name="L269" href="#L269">269</a> <em class="jxr_javadoccomment"> * The signature of the Constructor to be used.</em> <a class="jxr_linenumber" name="L270" href="#L270">270</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L271" href="#L271">271</a> <strong class="jxr_keyword">protected</strong> Class[] logConstructorSignature = { String.<strong class="jxr_keyword">class</strong> }; +<a class="jxr_linenumber" name="L271" href="#L271">271</a> <strong class="jxr_keyword">protected</strong> Class<?>[] logConstructorSignature = { String.<strong class="jxr_keyword">class</strong> }; <a class="jxr_linenumber" name="L272" href="#L272">272</a> <a class="jxr_linenumber" name="L273" href="#L273">273</a> <em class="jxr_javadoccomment">/**</em> <a class="jxr_linenumber" name="L274" href="#L274">274</a> <em class="jxr_javadoccomment"> * The one-argument {@code setLogFactory} method of the selected</em> @@ -287,7 +287,7 @@ <a class="jxr_linenumber" name="L279" href="#L279">279</a> <em class="jxr_javadoccomment">/**</em> <a class="jxr_linenumber" name="L280" href="#L280">280</a> <em class="jxr_javadoccomment"> * The signature of the {@code setLogFactory} method to be used.</em> <a class="jxr_linenumber" name="L281" href="#L281">281</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L282" href="#L282">282</a> <strong class="jxr_keyword">protected</strong> Class[] logMethodSignature = { LogFactory.<strong class="jxr_keyword">class</strong> }; +<a class="jxr_linenumber" name="L282" href="#L282">282</a> <strong class="jxr_keyword">protected</strong> Class<?>[] logMethodSignature = { LogFactory.<strong class="jxr_keyword">class</strong> }; <a class="jxr_linenumber" name="L283" href="#L283">283</a> <a class="jxr_linenumber" name="L284" href="#L284">284</a> <em class="jxr_javadoccomment">/**</em> <a class="jxr_linenumber" name="L285" href="#L285">285</a> <em class="jxr_javadoccomment"> * See getBaseClassLoader and initConfiguration.</em> @@ -339,9 +339,9 @@ <a class="jxr_linenumber" name="L331" href="#L331">331</a> <a class="jxr_linenumber" name="L332" href="#L332">332</a> <strong class="jxr_keyword">final</strong> Object[] params = { logCategory }; <a class="jxr_linenumber" name="L333" href="#L333">333</a> <a name="Log" href="../../../../../org/apache/commons/logging/Log.html#Log">Log</a> logAdapter = <strong class="jxr_keyword">null</strong>; -<a class="jxr_linenumber" name="L334" href="#L334">334</a> Constructor constructor = <strong class="jxr_keyword">null</strong>; +<a class="jxr_linenumber" name="L334" href="#L334">334</a> Constructor<?> constructor = <strong class="jxr_keyword">null</strong>; <a class="jxr_linenumber" name="L335" href="#L335">335</a> -<a class="jxr_linenumber" name="L336" href="#L336">336</a> Class logAdapterClass = <strong class="jxr_keyword">null</strong>; +<a class="jxr_linenumber" name="L336" href="#L336">336</a> Class<?> logAdapterClass = <strong class="jxr_keyword">null</strong>; <a class="jxr_linenumber" name="L337" href="#L337">337</a> ClassLoader currentCL = getBaseClassLoader(); <a class="jxr_linenumber" name="L338" href="#L338">338</a> <a class="jxr_linenumber" name="L339" href="#L339">339</a> <strong class="jxr_keyword">for</strong>(;;) { @@ -369,7 +369,7 @@ <a class="jxr_linenumber" name="L361" href="#L361">361</a> } <a class="jxr_linenumber" name="L362" href="#L362">362</a> } <a class="jxr_linenumber" name="L363" href="#L363">363</a> -<a class="jxr_linenumber" name="L364" href="#L364">364</a> Class clazz; +<a class="jxr_linenumber" name="L364" href="#L364">364</a> Class<?> clazz; <a class="jxr_linenumber" name="L365" href="#L365">365</a> <strong class="jxr_keyword">try</strong> { <a class="jxr_linenumber" name="L366" href="#L366">366</a> clazz = Class.forName(logAdapterClassName, <strong class="jxr_keyword">true</strong>, currentCL); <a class="jxr_linenumber" name="L367" href="#L367">367</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> ClassNotFoundException originalClassNotFoundException) { @@ -648,7 +648,7 @@ <a class="jxr_linenumber" name="L640" href="#L640">640</a> } <a class="jxr_linenumber" name="L641" href="#L641">641</a> <a class="jxr_linenumber" name="L642" href="#L642">642</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L643" href="#L643">643</a> <em class="jxr_javadoccomment"> * Return the configuration attribute with the specified name (if any),</em> +<a class="jxr_linenumber" name="L643" href="#L643">643</a> <em class="jxr_javadoccomment"> * Gets the configuration attribute with the specified name (if any),</em> <a class="jxr_linenumber" name="L644" href="#L644">644</a> <em class="jxr_javadoccomment"> * or {@code null} if there is no such attribute.</em> <a class="jxr_linenumber" name="L645" href="#L645">645</a> <em class="jxr_javadoccomment"> *</em> <a class="jxr_linenumber" name="L646" href="#L646">646</a> <em class="jxr_javadoccomment"> * @param name Name of the attribute to return</em> @@ -659,7 +659,7 @@ <a class="jxr_linenumber" name="L651" href="#L651">651</a> } <a class="jxr_linenumber" name="L652" href="#L652">652</a> <a class="jxr_linenumber" name="L653" href="#L653">653</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L654" href="#L654">654</a> <em class="jxr_javadoccomment"> * Return an array containing the names of all currently defined</em> +<a class="jxr_linenumber" name="L654" href="#L654">654</a> <em class="jxr_javadoccomment"> * Gets an array containing the names of all currently defined</em> <a class="jxr_linenumber" name="L655" href="#L655">655</a> <em class="jxr_javadoccomment"> * configuration attributes. If there are no such attributes, a zero</em> <a class="jxr_linenumber" name="L656" href="#L656">656</a> <em class="jxr_javadoccomment"> * length array is returned.</em> <a class="jxr_linenumber" name="L657" href="#L657">657</a> <em class="jxr_javadoccomment"> */</em> @@ -669,7 +669,7 @@ <a class="jxr_linenumber" name="L661" href="#L661">661</a> } <a class="jxr_linenumber" name="L662" href="#L662">662</a> <a class="jxr_linenumber" name="L663" href="#L663">663</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L664" href="#L664">664</a> <em class="jxr_javadoccomment"> * Return the class loader from which we should try to load the logging</em> +<a class="jxr_linenumber" name="L664" href="#L664">664</a> <em class="jxr_javadoccomment"> * Gets the class loader from which we should try to load the logging</em> <a class="jxr_linenumber" name="L665" href="#L665">665</a> <em class="jxr_javadoccomment"> * adapter classes.</em> <a class="jxr_linenumber" name="L666" href="#L666">666</a> <em class="jxr_javadoccomment"> * <p></em> <a class="jxr_linenumber" name="L667" href="#L667">667</a> <em class="jxr_javadoccomment"> * This method usually returns the context class loader. However if it</em> @@ -684,489 +684,489 @@ <a class="jxr_linenumber" name="L676" href="#L676">676</a> <em class="jxr_javadoccomment"> * failed to correctly set the context class loader. This is a bug in</em> <a class="jxr_linenumber" name="L677" href="#L677">677</a> <em class="jxr_javadoccomment"> * the calling application; however we provide the option for JCL to</em> <a class="jxr_linenumber" name="L678" href="#L678">678</a> <em class="jxr_javadoccomment"> * simply generate a warning rather than fail outright.</em> -<a class="jxr_linenumber" name="L679" href="#L679">679</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L680" href="#L680">680</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L681" href="#L681">681</a> <strong class="jxr_keyword">private</strong> ClassLoader getBaseClassLoader() <strong class="jxr_keyword">throws</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a> { -<a class="jxr_linenumber" name="L682" href="#L682">682</a> <strong class="jxr_keyword">final</strong> ClassLoader thisClassLoader = getClassLoader(LogFactoryImpl.<strong class="jxr_keyword">class</strong>); -<a class="jxr_linenumber" name="L683" href="#L683">683</a> -<a class="jxr_linenumber" name="L684" href="#L684">684</a> <strong class="jxr_keyword">if</strong> (!useTCCL) { -<a class="jxr_linenumber" name="L685" href="#L685">685</a> <strong class="jxr_keyword">return</strong> thisClassLoader; -<a class="jxr_linenumber" name="L686" href="#L686">686</a> } -<a class="jxr_linenumber" name="L687" href="#L687">687</a> -<a class="jxr_linenumber" name="L688" href="#L688">688</a> <strong class="jxr_keyword">final</strong> ClassLoader contextClassLoader = getContextClassLoaderInternal(); -<a class="jxr_linenumber" name="L689" href="#L689">689</a> -<a class="jxr_linenumber" name="L690" href="#L690">690</a> <strong class="jxr_keyword">final</strong> ClassLoader baseClassLoader = getLowestClassLoader( -<a class="jxr_linenumber" name="L691" href="#L691">691</a> contextClassLoader, thisClassLoader); -<a class="jxr_linenumber" name="L692" href="#L692">692</a> -<a class="jxr_linenumber" name="L693" href="#L693">693</a> <strong class="jxr_keyword">if</strong> (baseClassLoader == <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L694" href="#L694">694</a> <em class="jxr_comment">// The two class loaders are not part of a parent child relationship.</em> -<a class="jxr_linenumber" name="L695" href="#L695">695</a> <em class="jxr_comment">// In some classloading setups (e.g. JBoss with its</em> -<a class="jxr_linenumber" name="L696" href="#L696">696</a> <em class="jxr_comment">// UnifiedLoaderRepository) this can still work, so if user hasn't</em> -<a class="jxr_linenumber" name="L697" href="#L697">697</a> <em class="jxr_comment">// forbidden it, just return the contextClassLoader.</em> -<a class="jxr_linenumber" name="L698" href="#L698">698</a> <strong class="jxr_keyword">if</strong> (!allowFlawedContext) { -<a class="jxr_linenumber" name="L699" href="#L699">699</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a>(<span class="jxr_string">"Bad class loader hierarchy; LogFactoryImpl was loaded via"</span> + -<a class="jxr_linenumber" name="L700" href="#L700">700</a> <span class="jxr_string">" a class loader that is not related to the current context"</span> + -<a class="jxr_linenumber" name="L701" href="#L701">701</a> <span class="jxr_string">" class loader."</span>); -<a class="jxr_linenumber" name="L702" href="#L702">702</a> } -<a class="jxr_linenumber" name="L703" href="#L703">703</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L704" href="#L704">704</a> logDiagnostic(<span class="jxr_string">"[WARNING] the context class loader is not part of a"</span> + -<a class="jxr_linenumber" name="L705" href="#L705">705</a> <span class="jxr_string">" parent-child relationship with the class loader that"</span> + -<a class="jxr_linenumber" name="L706" href="#L706">706</a> <span class="jxr_string">" loaded LogFactoryImpl."</span>); -<a class="jxr_linenumber" name="L707" href="#L707">707</a> } -<a class="jxr_linenumber" name="L708" href="#L708">708</a> <em class="jxr_comment">// If contextClassLoader were null, getLowestClassLoader() would</em> -<a class="jxr_linenumber" name="L709" href="#L709">709</a> <em class="jxr_comment">// have returned thisClassLoader. The fact we are here means</em> -<a class="jxr_linenumber" name="L710" href="#L710">710</a> <em class="jxr_comment">// contextClassLoader is not null, so we can just return it.</em> -<a class="jxr_linenumber" name="L711" href="#L711">711</a> <strong class="jxr_keyword">return</strong> contextClassLoader; -<a class="jxr_linenumber" name="L712" href="#L712">712</a> } -<a class="jxr_linenumber" name="L713" href="#L713">713</a> -<a class="jxr_linenumber" name="L714" href="#L714">714</a> <strong class="jxr_keyword">if</strong> (baseClassLoader != contextClassLoader) { -<a class="jxr_linenumber" name="L715" href="#L715">715</a> <em class="jxr_comment">// We really should just use the contextClassLoader as the starting</em> -<a class="jxr_linenumber" name="L716" href="#L716">716</a> <em class="jxr_comment">// point for scanning for log adapter classes. However it is expected</em> -<a class="jxr_linenumber" name="L717" href="#L717">717</a> <em class="jxr_comment">// that there are a number of broken systems out there which create</em> -<a class="jxr_linenumber" name="L718" href="#L718">718</a> <em class="jxr_comment">// custom class loaders but fail to set the context class loader so</em> -<a class="jxr_linenumber" name="L719" href="#L719">719</a> <em class="jxr_comment">// we handle those flawed systems anyway.</em> -<a class="jxr_linenumber" name="L720" href="#L720">720</a> <strong class="jxr_keyword">if</strong> (!allowFlawedContext) { -<a class="jxr_linenumber" name="L721" href="#L721">721</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a>( -<a class="jxr_linenumber" name="L722" href="#L722">722</a> <span class="jxr_string">"Bad class loader hierarchy; LogFactoryImpl was loaded via"</span> + -<a class="jxr_linenumber" name="L723" href="#L723">723</a> <span class="jxr_string">" a class loader that is not related to the current context"</span> + -<a class="jxr_linenumber" name="L724" href="#L724">724</a> <span class="jxr_string">" class loader."</span>); -<a class="jxr_linenumber" name="L725" href="#L725">725</a> } -<a class="jxr_linenumber" name="L726" href="#L726">726</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L727" href="#L727">727</a> logDiagnostic( -<a class="jxr_linenumber" name="L728" href="#L728">728</a> <span class="jxr_string">"Warning: the context class loader is an ancestor of the"</span> + -<a class="jxr_linenumber" name="L729" href="#L729">729</a> <span class="jxr_string">" class loader that loaded LogFactoryImpl; it should be"</span> + -<a class="jxr_linenumber" name="L730" href="#L730">730</a> <span class="jxr_string">" the same or a descendant. The application using"</span> + -<a class="jxr_linenumber" name="L731" href="#L731">731</a> <span class="jxr_string">" commons-logging should ensure the context class loader"</span> + -<a class="jxr_linenumber" name="L732" href="#L732">732</a> <span class="jxr_string">" is used correctly."</span>); -<a class="jxr_linenumber" name="L733" href="#L733">733</a> } -<a class="jxr_linenumber" name="L734" href="#L734">734</a> } -<a class="jxr_linenumber" name="L735" href="#L735">735</a> -<a class="jxr_linenumber" name="L736" href="#L736">736</a> <strong class="jxr_keyword">return</strong> baseClassLoader; -<a class="jxr_linenumber" name="L737" href="#L737">737</a> } -<a class="jxr_linenumber" name="L738" href="#L738">738</a> -<a class="jxr_linenumber" name="L739" href="#L739">739</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L740" href="#L740">740</a> <em class="jxr_javadoccomment"> * Gets the setting for the user-configurable behavior specified by key.</em> -<a class="jxr_linenumber" name="L741" href="#L741">741</a> <em class="jxr_javadoccomment"> * If nothing has explicitly been set, then return dflt.</em> -<a class="jxr_linenumber" name="L742" href="#L742">742</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L743" href="#L743">743</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> getBooleanConfiguration(<strong class="jxr_keyword">final</strong> String key, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> dflt) { -<a class="jxr_linenumber" name="L744" href="#L744">744</a> <strong class="jxr_keyword">final</strong> String val = getConfigurationValue(key); -<a class="jxr_linenumber" name="L745" href="#L745">745</a> <strong class="jxr_keyword">if</strong> (val == <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L746" href="#L746">746</a> <strong class="jxr_keyword">return</strong> dflt; -<a class="jxr_linenumber" name="L747" href="#L747">747</a> } -<a class="jxr_linenumber" name="L748" href="#L748">748</a> <strong class="jxr_keyword">return</strong> Boolean.parseBoolean(val); -<a class="jxr_linenumber" name="L749" href="#L749">749</a> } -<a class="jxr_linenumber" name="L750" href="#L750">750</a> -<a class="jxr_linenumber" name="L751" href="#L751">751</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L752" href="#L752">752</a> <em class="jxr_javadoccomment"> * Attempt to find an attribute (see method setAttribute) or a</em> -<a class="jxr_linenumber" name="L753" href="#L753">753</a> <em class="jxr_javadoccomment"> * system property with the provided name and return its value.</em> -<a class="jxr_linenumber" name="L754" href="#L754">754</a> <em class="jxr_javadoccomment"> * <p></em> -<a class="jxr_linenumber" name="L755" href="#L755">755</a> <em class="jxr_javadoccomment"> * The attributes associated with this object are checked before</em> -<a class="jxr_linenumber" name="L756" href="#L756">756</a> <em class="jxr_javadoccomment"> * system properties in case someone has explicitly called setAttribute,</em> -<a class="jxr_linenumber" name="L757" href="#L757">757</a> <em class="jxr_javadoccomment"> * or a configuration property has been set in a commons-logging.properties</em> -<a class="jxr_linenumber" name="L758" href="#L758">758</a> <em class="jxr_javadoccomment"> * file.</em> -<a class="jxr_linenumber" name="L759" href="#L759">759</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L760" href="#L760">760</a> <em class="jxr_javadoccomment"> * @return the value associated with the property, or null.</em> -<a class="jxr_linenumber" name="L761" href="#L761">761</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L762" href="#L762">762</a> <strong class="jxr_keyword">private</strong> String getConfigurationValue(<strong class="jxr_keyword">final</strong> String property) { -<a class="jxr_linenumber" name="L763" href="#L763">763</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L764" href="#L764">764</a> logDiagnostic(<span class="jxr_string">"[ENV] Trying to get configuration for item "</span> + property); -<a class="jxr_linenumber" name="L765" href="#L765">765</a> } -<a class="jxr_linenumber" name="L766" href="#L766">766</a> -<a class="jxr_linenumber" name="L767" href="#L767">767</a> <strong class="jxr_keyword">final</strong> Object valueObj = getAttribute(property); -<a class="jxr_linenumber" name="L768" href="#L768">768</a> <strong class="jxr_keyword">if</strong> (valueObj != <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L769" href="#L769">769</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L770" href="#L770">770</a> logDiagnostic(<span class="jxr_string">"[ENV] Found LogFactory attribute ["</span> + valueObj + <span class="jxr_string">"] for "</span> + property); -<a class="jxr_linenumber" name="L771" href="#L771">771</a> } -<a class="jxr_linenumber" name="L772" href="#L772">772</a> <strong class="jxr_keyword">return</strong> valueObj.toString(); -<a class="jxr_linenumber" name="L773" href="#L773">773</a> } -<a class="jxr_linenumber" name="L774" href="#L774">774</a> -<a class="jxr_linenumber" name="L775" href="#L775">775</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L776" href="#L776">776</a> logDiagnostic(<span class="jxr_string">"[ENV] No LogFactory attribute found for "</span> + property); -<a class="jxr_linenumber" name="L777" href="#L777">777</a> } -<a class="jxr_linenumber" name="L778" href="#L778">778</a> -<a class="jxr_linenumber" name="L779" href="#L779">779</a> <strong class="jxr_keyword">try</strong> { -<a class="jxr_linenumber" name="L780" href="#L780">780</a> <em class="jxr_comment">// warning: minor security hole here, in that we potentially read a system</em> -<a class="jxr_linenumber" name="L781" href="#L781">781</a> <em class="jxr_comment">// property that the caller cannot, then output it in readable form as a</em> -<a class="jxr_linenumber" name="L782" href="#L782">782</a> <em class="jxr_comment">// diagnostic message. However it's only ever JCL-specific properties</em> -<a class="jxr_linenumber" name="L783" href="#L783">783</a> <em class="jxr_comment">// involved here, so the harm is truly trivial.</em> -<a class="jxr_linenumber" name="L784" href="#L784">784</a> <strong class="jxr_keyword">final</strong> String value = getSystemProperty(property, <strong class="jxr_keyword">null</strong>); -<a class="jxr_linenumber" name="L785" href="#L785">785</a> <strong class="jxr_keyword">if</strong> (value != <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L786" href="#L786">786</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L787" href="#L787">787</a> logDiagnostic(<span class="jxr_string">"[ENV] Found system property ["</span> + value + <span class="jxr_string">"] for "</span> + property); -<a class="jxr_linenumber" name="L788" href="#L788">788</a> } -<a class="jxr_linenumber" name="L789" href="#L789">789</a> <strong class="jxr_keyword">return</strong> value; -<a class="jxr_linenumber" name="L790" href="#L790">790</a> } -<a class="jxr_linenumber" name="L791" href="#L791">791</a> -<a class="jxr_linenumber" name="L792" href="#L792">792</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L793" href="#L793">793</a> logDiagnostic(<span class="jxr_string">"[ENV] No system property found for property "</span> + property); -<a class="jxr_linenumber" name="L794" href="#L794">794</a> } -<a class="jxr_linenumber" name="L795" href="#L795">795</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> SecurityException e) { -<a class="jxr_linenumber" name="L796" href="#L796">796</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L797" href="#L797">797</a> logDiagnostic(<span class="jxr_string">"[ENV] Security prevented reading system property "</span> + property); -<a class="jxr_linenumber" name="L798" href="#L798">798</a> } -<a class="jxr_linenumber" name="L799" href="#L799">799</a> } -<a class="jxr_linenumber" name="L800" href="#L800">800</a> -<a class="jxr_linenumber" name="L801" href="#L801">801</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L802" href="#L802">802</a> logDiagnostic(<span class="jxr_string">"[ENV] No configuration defined for item "</span> + property); -<a class="jxr_linenumber" name="L803" href="#L803">803</a> } -<a class="jxr_linenumber" name="L804" href="#L804">804</a> -<a class="jxr_linenumber" name="L805" href="#L805">805</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; -<a class="jxr_linenumber" name="L806" href="#L806">806</a> } -<a class="jxr_linenumber" name="L807" href="#L807">807</a> -<a class="jxr_linenumber" name="L808" href="#L808">808</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L809" href="#L809">809</a> <em class="jxr_javadoccomment"> * Convenience method to derive a name from the specified class and</em> -<a class="jxr_linenumber" name="L810" href="#L810">810</a> <em class="jxr_javadoccomment"> * call {@code getInstance(String)} with it.</em> -<a class="jxr_linenumber" name="L811" href="#L811">811</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L812" href="#L812">812</a> <em class="jxr_javadoccomment"> * @param clazz Class for which a suitable Log name will be derived</em> -<a class="jxr_linenumber" name="L813" href="#L813">813</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L814" href="#L814">814</a> <em class="jxr_javadoccomment"> * @throws LogConfigurationException if a suitable {@code Log}</em> -<a class="jxr_linenumber" name="L815" href="#L815">815</a> <em class="jxr_javadoccomment"> * instance cannot be returned</em> -<a class="jxr_linenumber" name="L816" href="#L816">816</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L817" href="#L817">817</a> @Override -<a class="jxr_linenumber" name="L818" href="#L818">818</a> <strong class="jxr_keyword">public</strong> <a name="Log" href="../../../../../org/apache/commons/logging/Log.html#Log">Log</a> getInstance(<strong class="jxr_keyword">final</strong> Class<?> clazz) <strong class="jxr_keyword">throws</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a> { -<a class="jxr_linenumber" name="L819" href="#L819">819</a> <strong class="jxr_keyword">return</strong> getInstance(clazz.getName()); -<a class="jxr_linenumber" name="L820" href="#L820">820</a> } -<a class="jxr_linenumber" name="L821" href="#L821">821</a> -<a class="jxr_linenumber" name="L822" href="#L822">822</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L823" href="#L823">823</a> <em class="jxr_javadoccomment"> * <p>Construct (if necessary) and return a {@code Log} instance,</em> -<a class="jxr_linenumber" name="L824" href="#L824">824</a> <em class="jxr_javadoccomment"> * using the factory's current set of configuration attributes.</p></em> -<a class="jxr_linenumber" name="L825" href="#L825">825</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L826" href="#L826">826</a> <em class="jxr_javadoccomment"> * <p><strong>NOTE</strong> - Depending upon the implementation of</em> -<a class="jxr_linenumber" name="L827" href="#L827">827</a> <em class="jxr_javadoccomment"> * the {@code LogFactory} you are using, the {@code Log}</em> -<a class="jxr_linenumber" name="L828" href="#L828">828</a> <em class="jxr_javadoccomment"> * instance you are returned may or may not be local to the current</em> -<a class="jxr_linenumber" name="L829" href="#L829">829</a> <em class="jxr_javadoccomment"> * application, and may or may not be returned again on a subsequent</em> -<a class="jxr_linenumber" name="L830" href="#L830">830</a> <em class="jxr_javadoccomment"> * call with the same name argument.</p></em> -<a class="jxr_linenumber" name="L831" href="#L831">831</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L832" href="#L832">832</a> <em class="jxr_javadoccomment"> * @param name Logical name of the {@code Log} instance to be</em> -<a class="jxr_linenumber" name="L833" href="#L833">833</a> <em class="jxr_javadoccomment"> * returned (the meaning of this name is only known to the underlying</em> -<a class="jxr_linenumber" name="L834" href="#L834">834</a> <em class="jxr_javadoccomment"> * logging implementation that is being wrapped)</em> -<a class="jxr_linenumber" name="L835" href="#L835">835</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L836" href="#L836">836</a> <em class="jxr_javadoccomment"> * @throws LogConfigurationException if a suitable {@code Log}</em> -<a class="jxr_linenumber" name="L837" href="#L837">837</a> <em class="jxr_javadoccomment"> * instance cannot be returned</em> -<a class="jxr_linenumber" name="L838" href="#L838">838</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L839" href="#L839">839</a> @Override -<a class="jxr_linenumber" name="L840" href="#L840">840</a> <strong class="jxr_keyword">public</strong> <a name="Log" href="../../../../../org/apache/commons/logging/Log.html#Log">Log</a> getInstance(<strong class="jxr_keyword">final</strong> String name) <strong class="jxr_keyword">throws</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a> { -<a class="jxr_linenumber" name="L841" href="#L841">841</a> <strong class="jxr_keyword">return</strong> instances.computeIfAbsent(name, <strong class="jxr_keyword">this</strong>::newInstance); -<a class="jxr_linenumber" name="L842" href="#L842">842</a> } -<a class="jxr_linenumber" name="L843" href="#L843">843</a> -<a class="jxr_linenumber" name="L844" href="#L844">844</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L845" href="#L845">845</a> <em class="jxr_javadoccomment"> * Return the fully qualified Java class name of the {@link Log} implementation we will be using.</em> -<a class="jxr_linenumber" name="L846" href="#L846">846</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L847" href="#L847">847</a> <em class="jxr_javadoccomment"> * @return the fully qualified Java class name of the {@link Log} implementation we will be using.</em> -<a class="jxr_linenumber" name="L848" href="#L848">848</a> <em class="jxr_javadoccomment"> * @deprecated Never invoked by this class; subclasses should not assume it will be.</em> -<a class="jxr_linenumber" name="L849" href="#L849">849</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L850" href="#L850">850</a> @Deprecated -<a class="jxr_linenumber" name="L851" href="#L851">851</a> <strong class="jxr_keyword">protected</strong> String getLogClassName() { -<a class="jxr_linenumber" name="L852" href="#L852">852</a> <strong class="jxr_keyword">if</strong> (logClassName == <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L853" href="#L853">853</a> discoverLogImplementation(getClass().getName()); -<a class="jxr_linenumber" name="L854" href="#L854">854</a> } -<a class="jxr_linenumber" name="L855" href="#L855">855</a> -<a class="jxr_linenumber" name="L856" href="#L856">856</a> <strong class="jxr_keyword">return</strong> logClassName; -<a class="jxr_linenumber" name="L857" href="#L857">857</a> } -<a class="jxr_linenumber" name="L858" href="#L858">858</a> -<a class="jxr_linenumber" name="L859" href="#L859">859</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L860" href="#L860">860</a> <em class="jxr_javadoccomment"> * <p></em> -<a class="jxr_linenumber" name="L861" href="#L861">861</a> <em class="jxr_javadoccomment"> * Return the {@code Constructor} that can be called to instantiate new {@link org.apache.commons.logging.Log} instances.</em> -<a class="jxr_linenumber" name="L862" href="#L862">862</a> <em class="jxr_javadoccomment"> * </p></em> -<a class="jxr_linenumber" name="L863" href="#L863">863</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L864" href="#L864">864</a> <em class="jxr_javadoccomment"> * <p></em> -<a class="jxr_linenumber" name="L865" href="#L865">865</a> <em class="jxr_javadoccomment"> * <strong>IMPLEMENTATION NOTE</strong> - Race conditions caused by calling this method from more than one thread are ignored, because the same</em> -<a class="jxr_linenumber" name="L866" href="#L866">866</a> <em class="jxr_javadoccomment"> * {@code Constructor} instance will ultimately be derived in all circumstances.</em> -<a class="jxr_linenumber" name="L867" href="#L867">867</a> <em class="jxr_javadoccomment"> * </p></em> -<a class="jxr_linenumber" name="L868" href="#L868">868</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L869" href="#L869">869</a> <em class="jxr_javadoccomment"> * @return the {@code Constructor} that can be called to instantiate new {@link org.apache.commons.logging.Log} instances.</em> -<a class="jxr_linenumber" name="L870" href="#L870">870</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L871" href="#L871">871</a> <em class="jxr_javadoccomment"> * @throws LogConfigurationException if a suitable constructor cannot be returned</em> -<a class="jxr_linenumber" name="L872" href="#L872">872</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L873" href="#L873">873</a> <em class="jxr_javadoccomment"> * @deprecated Never invoked by this class; subclasses should not assume it will be.</em> -<a class="jxr_linenumber" name="L874" href="#L874">874</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L875" href="#L875">875</a> @Deprecated -<a class="jxr_linenumber" name="L876" href="#L876">876</a> <strong class="jxr_keyword">protected</strong> Constructor getLogConstructor() -<a class="jxr_linenumber" name="L877" href="#L877">877</a> <strong class="jxr_keyword">throws</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a> { -<a class="jxr_linenumber" name="L878" href="#L878">878</a> -<a class="jxr_linenumber" name="L879" href="#L879">879</a> <em class="jxr_comment">// Return the previously identified Constructor (if any)</em> -<a class="jxr_linenumber" name="L880" href="#L880">880</a> <strong class="jxr_keyword">if</strong> (logConstructor == <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L881" href="#L881">881</a> discoverLogImplementation(getClass().getName()); -<a class="jxr_linenumber" name="L882" href="#L882">882</a> } -<a class="jxr_linenumber" name="L883" href="#L883">883</a> -<a class="jxr_linenumber" name="L884" href="#L884">884</a> <strong class="jxr_keyword">return</strong> logConstructor; -<a class="jxr_linenumber" name="L885" href="#L885">885</a> } -<a class="jxr_linenumber" name="L886" href="#L886">886</a> -<a class="jxr_linenumber" name="L887" href="#L887">887</a> <em class="jxr_comment">// ------------------------------------------------------ Private Methods</em> -<a class="jxr_linenumber" name="L888" href="#L888">888</a> -<a class="jxr_linenumber" name="L889" href="#L889">889</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L890" href="#L890">890</a> <em class="jxr_javadoccomment"> * Given two related class loaders, return the one which is a child of</em> -<a class="jxr_linenumber" name="L891" href="#L891">891</a> <em class="jxr_javadoccomment"> * the other.</em> -<a class="jxr_linenumber" name="L892" href="#L892">892</a> <em class="jxr_javadoccomment"> * <p></em> -<a class="jxr_linenumber" name="L893" href="#L893">893</a> <em class="jxr_javadoccomment"> * @param c1 is a class loader (including the null class loader)</em> -<a class="jxr_linenumber" name="L894" href="#L894">894</a> <em class="jxr_javadoccomment"> * @param c2 is a class loader (including the null class loader)</em> -<a class="jxr_linenumber" name="L895" href="#L895">895</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L896" href="#L896">896</a> <em class="jxr_javadoccomment"> * @return c1 if it has c2 as an ancestor, c2 if it has c1 as an ancestor,</em> -<a class="jxr_linenumber" name="L897" href="#L897">897</a> <em class="jxr_javadoccomment"> * and null if neither is an ancestor of the other.</em> -<a class="jxr_linenumber" name="L898" href="#L898">898</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L899" href="#L899">899</a> <strong class="jxr_keyword">private</strong> ClassLoader getLowestClassLoader(<strong class="jxr_keyword">final</strong> ClassLoader c1, <strong class="jxr_keyword">final</strong> ClassLoader c2) { -<a class="jxr_linenumber" name="L900" href="#L900">900</a> <em class="jxr_comment">// TODO: use AccessController when dealing with class loaders here</em> -<a class="jxr_linenumber" name="L901" href="#L901">901</a> -<a class="jxr_linenumber" name="L902" href="#L902">902</a> <strong class="jxr_keyword">if</strong> (c1 == <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L903" href="#L903">903</a> <strong class="jxr_keyword">return</strong> c2; -<a class="jxr_linenumber" name="L904" href="#L904">904</a> } -<a class="jxr_linenumber" name="L905" href="#L905">905</a> -<a class="jxr_linenumber" name="L906" href="#L906">906</a> <strong class="jxr_keyword">if</strong> (c2 == <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L907" href="#L907">907</a> <strong class="jxr_keyword">return</strong> c1; -<a class="jxr_linenumber" name="L908" href="#L908">908</a> } -<a class="jxr_linenumber" name="L909" href="#L909">909</a> -<a class="jxr_linenumber" name="L910" href="#L910">910</a> ClassLoader current; -<a class="jxr_linenumber" name="L911" href="#L911">911</a> -<a class="jxr_linenumber" name="L912" href="#L912">912</a> <em class="jxr_comment">// scan c1's ancestors to find c2</em> -<a class="jxr_linenumber" name="L913" href="#L913">913</a> current = c1; -<a class="jxr_linenumber" name="L914" href="#L914">914</a> <strong class="jxr_keyword">while</strong> (current != <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L915" href="#L915">915</a> <strong class="jxr_keyword">if</strong> (current == c2) { -<a class="jxr_linenumber" name="L916" href="#L916">916</a> <strong class="jxr_keyword">return</strong> c1; -<a class="jxr_linenumber" name="L917" href="#L917">917</a> } -<a class="jxr_linenumber" name="L918" href="#L918">918</a> <em class="jxr_comment">// current = current.getParent();</em> -<a class="jxr_linenumber" name="L919" href="#L919">919</a> current = getParentClassLoader(current); -<a class="jxr_linenumber" name="L920" href="#L920">920</a> } -<a class="jxr_linenumber" name="L921" href="#L921">921</a> -<a class="jxr_linenumber" name="L922" href="#L922">922</a> <em class="jxr_comment">// scan c2's ancestors to find c1</em> -<a class="jxr_linenumber" name="L923" href="#L923">923</a> current = c2; -<a class="jxr_linenumber" name="L924" href="#L924">924</a> <strong class="jxr_keyword">while</strong> (current != <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L925" href="#L925">925</a> <strong class="jxr_keyword">if</strong> (current == c1) { -<a class="jxr_linenumber" name="L926" href="#L926">926</a> <strong class="jxr_keyword">return</strong> c2; -<a class="jxr_linenumber" name="L927" href="#L927">927</a> } -<a class="jxr_linenumber" name="L928" href="#L928">928</a> <em class="jxr_comment">// current = current.getParent();</em> -<a class="jxr_linenumber" name="L929" href="#L929">929</a> current = getParentClassLoader(current); -<a class="jxr_linenumber" name="L930" href="#L930">930</a> } -<a class="jxr_linenumber" name="L931" href="#L931">931</a> -<a class="jxr_linenumber" name="L932" href="#L932">932</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; -<a class="jxr_linenumber" name="L933" href="#L933">933</a> } -<a class="jxr_linenumber" name="L934" href="#L934">934</a> -<a class="jxr_linenumber" name="L935" href="#L935">935</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L936" href="#L936">936</a> <em class="jxr_javadoccomment"> * Fetch the parent class loader of a specified class loader.</em> -<a class="jxr_linenumber" name="L937" href="#L937">937</a> <em class="jxr_javadoccomment"> * <p></em> -<a class="jxr_linenumber" name="L938" href="#L938">938</a> <em class="jxr_javadoccomment"> * If a SecurityException occurs, null is returned.</em> -<a class="jxr_linenumber" name="L939" href="#L939">939</a> <em class="jxr_javadoccomment"> * <p></em> -<a class="jxr_linenumber" name="L940" href="#L940">940</a> <em class="jxr_javadoccomment"> * Note that this method is non-static merely so logDiagnostic is available.</em> -<a class="jxr_linenumber" name="L941" href="#L941">941</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L942" href="#L942">942</a> <strong class="jxr_keyword">private</strong> ClassLoader getParentClassLoader(<strong class="jxr_keyword">final</strong> ClassLoader cl) { -<a class="jxr_linenumber" name="L943" href="#L943">943</a> <strong class="jxr_keyword">try</strong> { -<a class="jxr_linenumber" name="L944" href="#L944">944</a> <strong class="jxr_keyword">return</strong> AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> cl.getParent()); -<a class="jxr_linenumber" name="L945" href="#L945">945</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> SecurityException ex) { -<a class="jxr_linenumber" name="L946" href="#L946">946</a> logDiagnostic(<span class="jxr_string">"[SECURITY] Unable to obtain parent class loader"</span>); -<a class="jxr_linenumber" name="L947" href="#L947">947</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; -<a class="jxr_linenumber" name="L948" href="#L948">948</a> } -<a class="jxr_linenumber" name="L949" href="#L949">949</a> -<a class="jxr_linenumber" name="L950" href="#L950">950</a> } -<a class="jxr_linenumber" name="L951" href="#L951">951</a> -<a class="jxr_linenumber" name="L952" href="#L952">952</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L953" href="#L953">953</a> <em class="jxr_javadoccomment"> * Generates an internal diagnostic logging of the discovery failure and</em> -<a class="jxr_linenumber" name="L954" href="#L954">954</a> <em class="jxr_javadoccomment"> * then throws a {@code LogConfigurationException} that wraps</em> -<a class="jxr_linenumber" name="L955" href="#L955">955</a> <em class="jxr_javadoccomment"> * the passed {@code Throwable}.</em> -<a class="jxr_linenumber" name="L956" href="#L956">956</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L957" href="#L957">957</a> <em class="jxr_javadoccomment"> * @param logAdapterClassName is the class name of the Log implementation</em> -<a class="jxr_linenumber" name="L958" href="#L958">958</a> <em class="jxr_javadoccomment"> * that could not be instantiated. Cannot be {@code null}.</em> -<a class="jxr_linenumber" name="L959" href="#L959">959</a> <em class="jxr_javadoccomment"> * @param discoveryFlaw is the Throwable created by the class loader</em> -<a class="jxr_linenumber" name="L960" href="#L960">960</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L961" href="#L961">961</a> <em class="jxr_javadoccomment"> * @throws LogConfigurationException ALWAYS</em> -<a class="jxr_linenumber" name="L962" href="#L962">962</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L963" href="#L963">963</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> handleFlawedDiscovery(<strong class="jxr_keyword">final</strong> String logAdapterClassName, -<a class="jxr_linenumber" name="L964" href="#L964">964</a> <strong class="jxr_keyword">final</strong> Throwable discoveryFlaw) { -<a class="jxr_linenumber" name="L965" href="#L965">965</a> -<a class="jxr_linenumber" name="L966" href="#L966">966</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L967" href="#L967">967</a> logDiagnostic(<span class="jxr_string">"Could not instantiate Log '"</span> + -<a class="jxr_linenumber" name="L968" href="#L968">968</a> logAdapterClassName + <span class="jxr_string">"' -- "</span> + -<a class="jxr_linenumber" name="L969" href="#L969">969</a> discoveryFlaw.getClass().getName() + <span class="jxr_string">": "</span> + -<a class="jxr_linenumber" name="L970" href="#L970">970</a> discoveryFlaw.getLocalizedMessage()); -<a class="jxr_linenumber" name="L971" href="#L971">971</a> -<a class="jxr_linenumber" name="L972" href="#L972">972</a> <strong class="jxr_keyword">if</strong> (discoveryFlaw instanceof InvocationTargetException ) { -<a class="jxr_linenumber" name="L973" href="#L973">973</a> <em class="jxr_comment">// Ok, the lib is there but while trying to create a real underlying</em> -<a class="jxr_linenumber" name="L974" href="#L974">974</a> <em class="jxr_comment">// logger something failed in the underlying lib; display info about</em> -<a class="jxr_linenumber" name="L975" href="#L975">975</a> <em class="jxr_comment">// that if possible.</em> -<a class="jxr_linenumber" name="L976" href="#L976">976</a> <strong class="jxr_keyword">final</strong> InvocationTargetException ite = (InvocationTargetException) discoveryFlaw; -<a class="jxr_linenumber" name="L977" href="#L977">977</a> <strong class="jxr_keyword">final</strong> Throwable cause = ite.getTargetException(); -<a class="jxr_linenumber" name="L978" href="#L978">978</a> <strong class="jxr_keyword">if</strong> (cause != <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L979" href="#L979">979</a> logDiagnostic(<span class="jxr_string">"... InvocationTargetException: "</span> + -<a class="jxr_linenumber" name="L980" href="#L980">980</a> cause.getClass().getName() + <span class="jxr_string">": "</span> + -<a class="jxr_linenumber" name="L981" href="#L981">981</a> cause.getLocalizedMessage()); -<a class="jxr_linenumber" name="L982" href="#L982">982</a> -<a class="jxr_linenumber" name="L983" href="#L983">983</a> <strong class="jxr_keyword">if</strong> (cause instanceof ExceptionInInitializerError) { -<a class="jxr_linenumber" name="L984" href="#L984">984</a> <strong class="jxr_keyword">final</strong> ExceptionInInitializerError eiie = (ExceptionInInitializerError) cause; -<a class="jxr_linenumber" name="L985" href="#L985">985</a> <strong class="jxr_keyword">final</strong> Throwable cause2 = eiie.getCause(); -<a class="jxr_linenumber" name="L986" href="#L986">986</a> <strong class="jxr_keyword">if</strong> (cause2 != <strong class="jxr_keyword">null</strong>) { -<a class="jxr_linenumber" name="L987" href="#L987">987</a> <strong class="jxr_keyword">final</strong> StringWriter sw = <strong class="jxr_keyword">new</strong> StringWriter(); -<a class="jxr_linenumber" name="L988" href="#L988">988</a> cause2.printStackTrace(<strong class="jxr_keyword">new</strong> PrintWriter(sw, <strong class="jxr_keyword">true</strong>)); -<a class="jxr_linenumber" name="L989" href="#L989">989</a> logDiagnostic(<span class="jxr_string">"... ExceptionInInitializerError: "</span> + sw.toString()); -<a class="jxr_linenumber" name="L990" href="#L990">990</a> } -<a class="jxr_linenumber" name="L991" href="#L991">991</a> } -<a class="jxr_linenumber" name="L992" href="#L992">992</a> } -<a class="jxr_linenumber" name="L993" href="#L993">993</a> } -<a class="jxr_linenumber" name="L994" href="#L994">994</a> } -<a class="jxr_linenumber" name="L995" href="#L995">995</a> -<a class="jxr_linenumber" name="L996" href="#L996">996</a> <strong class="jxr_keyword">if</strong> (!allowFlawedDiscovery) { -<a class="jxr_linenumber" name="L997" href="#L997">997</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a>(discoveryFlaw); -<a class="jxr_linenumber" name="L998" href="#L998">998</a> } -<a class="jxr_linenumber" name="L999" href="#L999">999</a> } -<a class="jxr_linenumber" name="L1000" href="#L1000">1000</a> -<a class="jxr_linenumber" name="L1001" href="#L1001">1001</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L1002" href="#L1002">1002</a> <em class="jxr_javadoccomment"> * Report a problem loading the log adapter, then either return</em> -<a class="jxr_linenumber" name="L1003" href="#L1003">1003</a> <em class="jxr_javadoccomment"> * (if the situation is considered recoverable) or throw a</em> -<a class="jxr_linenumber" name="L1004" href="#L1004">1004</a> <em class="jxr_javadoccomment"> * LogConfigurationException.</em> -<a class="jxr_linenumber" name="L1005" href="#L1005">1005</a> <em class="jxr_javadoccomment"> * <p></em> -<a class="jxr_linenumber" name="L1006" href="#L1006">1006</a> <em class="jxr_javadoccomment"> * There are two possible reasons why we successfully loaded the</em> -<a class="jxr_linenumber" name="L1007" href="#L1007">1007</a> <em class="jxr_javadoccomment"> * specified log adapter class then failed to cast it to a Log object:</em> -<a class="jxr_linenumber" name="L1008" href="#L1008">1008</a> <em class="jxr_javadoccomment"> * <ol></em> -<a class="jxr_linenumber" name="L1009" href="#L1009">1009</a> <em class="jxr_javadoccomment"> * <li>the specific class just doesn't implement the Log interface</em> -<a class="jxr_linenumber" name="L1010" href="#L1010">1010</a> <em class="jxr_javadoccomment"> * (user screwed up), or</em> -<a class="jxr_linenumber" name="L1011" href="#L1011">1011</a> <em class="jxr_javadoccomment"> * <li> the specified class has bound to a Log class loaded by some other</em> -<a class="jxr_linenumber" name="L1012" href="#L1012">1012</a> <em class="jxr_javadoccomment"> * class loader; Log@ClassLoaderX cannot be cast to Log@ClassLoaderY.</em> -<a class="jxr_linenumber" name="L1013" href="#L1013">1013</a> <em class="jxr_javadoccomment"> * </ol></em> -<a class="jxr_linenumber" name="L1014" href="#L1014">1014</a> <em class="jxr_javadoccomment"> * <p></em> -<a class="jxr_linenumber" name="L1015" href="#L1015">1015</a> <em class="jxr_javadoccomment"> * Here we try to figure out which case has occurred so we can give the</em> -<a class="jxr_linenumber" name="L1016" href="#L1016">1016</a> <em class="jxr_javadoccomment"> * user some reasonable feedback.</em> -<a class="jxr_linenumber" name="L1017" href="#L1017">1017</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L1018" href="#L1018">1018</a> <em class="jxr_javadoccomment"> * @param badClassLoader is the class loader we loaded the problem class from,</em> -<a class="jxr_linenumber" name="L1019" href="#L1019">1019</a> <em class="jxr_javadoccomment"> * ie it is equivalent to badClass.getClassLoader().</em> -<a class="jxr_linenumber" name="L1020" href="#L1020">1020</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L1021" href="#L1021">1021</a> <em class="jxr_javadoccomment"> * @param badClass is a Class object with the desired name, but which</em> -<a class="jxr_linenumber" name="L1022" href="#L1022">1022</a> <em class="jxr_javadoccomment"> * does not implement Log correctly.</em> -<a class="jxr_linenumber" name="L1023" href="#L1023">1023</a> <em class="jxr_javadoccomment"> *</em> -<a class="jxr_linenumber" name="L1024" href="#L1024">1024</a> <em class="jxr_javadoccomment"> * @throws LogConfigurationException when the situation</em> -<a class="jxr_linenumber" name="L1025" href="#L1025">1025</a> <em class="jxr_javadoccomment"> * should not be recovered from.</em> -<a class="jxr_linenumber" name="L1026" href="#L1026">1026</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L1027" href="#L1027">1027</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> handleFlawedHierarchy(<strong class="jxr_keyword">final</strong> ClassLoader badClassLoader, <strong class="jxr_keyword">final</strong> Class badClass) -<a class="jxr_linenumber" name="L1028" href="#L1028">1028</a> <strong class="jxr_keyword">throws</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a> { -<a class="jxr_linenumber" name="L1029" href="#L1029">1029</a> -<a class="jxr_linenumber" name="L1030" href="#L1030">1030</a> <strong class="jxr_keyword">boolean</strong> implementsLog = false; -<a class="jxr_linenumber" name="L1031" href="#L1031">1031</a> <strong class="jxr_keyword">final</strong> String logInterfaceName = Log.<strong class="jxr_keyword">class</strong>.getName(); -<a class="jxr_linenumber" name="L1032" href="#L1032">1032</a> <strong class="jxr_keyword">final</strong> Class[] interfaces = badClass.getInterfaces(); -<a class="jxr_linenumber" name="L1033" href="#L1033">1033</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">final</strong> Class element : interfaces) { -<a class="jxr_linenumber" name="L1034" href="#L1034">1034</a> <strong class="jxr_keyword">if</strong> (logInterfaceName.equals(element.getName())) { -<a class="jxr_linenumber" name="L1035" href="#L1035">1035</a> implementsLog = <strong class="jxr_keyword">true</strong>; -<a class="jxr_linenumber" name="L1036" href="#L1036">1036</a> <strong class="jxr_keyword">break</strong>; -<a class="jxr_linenumber" name="L1037" href="#L1037">1037</a> } -<a class="jxr_linenumber" name="L1038" href="#L1038">1038</a> } -<a class="jxr_linenumber" name="L1039" href="#L1039">1039</a> -<a class="jxr_linenumber" name="L1040" href="#L1040">1040</a> <strong class="jxr_keyword">if</strong> (implementsLog) { -<a class="jxr_linenumber" name="L1041" href="#L1041">1041</a> <em class="jxr_comment">// the class does implement an interface called Log, but</em> -<a class="jxr_linenumber" name="L1042" href="#L1042">1042</a> <em class="jxr_comment">// it is in the wrong class loader</em> -<a class="jxr_linenumber" name="L1043" href="#L1043">1043</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L1044" href="#L1044">1044</a> <strong class="jxr_keyword">try</strong> { -<a class="jxr_linenumber" name="L1045" href="#L1045">1045</a> <strong class="jxr_keyword">final</strong> ClassLoader logInterfaceClassLoader = getClassLoader(Log.<strong class="jxr_keyword">class</strong>); -<a class="jxr_linenumber" name="L1046" href="#L1046">1046</a> logDiagnostic(<span class="jxr_string">"Class '"</span> + badClass.getName() + <span class="jxr_string">"' was found in class loader "</span> + -<a class="jxr_linenumber" name="L1047" href="#L1047">1047</a> objectId(badClassLoader) + <span class="jxr_string">". It is bound to a Log interface which is not"</span> + -<a class="jxr_linenumber" name="L1048" href="#L1048">1048</a> <span class="jxr_string">" the one loaded from class loader "</span> + objectId(logInterfaceClassLoader)); -<a class="jxr_linenumber" name="L1049" href="#L1049">1049</a> } <strong class="jxr_keyword">catch</strong> (<strong class="jxr_keyword">final</strong> Throwable t) { -<a class="jxr_linenumber" name="L1050" href="#L1050">1050</a> handleThrowable(t); <em class="jxr_comment">// may re-throw t</em> -<a class="jxr_linenumber" name="L1051" href="#L1051">1051</a> logDiagnostic(<span class="jxr_string">"Error while trying to output diagnostics about"</span> + <span class="jxr_string">" bad class '"</span> + badClass + <span class="jxr_string">"'"</span>); -<a class="jxr_linenumber" name="L1052" href="#L1052">1052</a> } -<a class="jxr_linenumber" name="L1053" href="#L1053">1053</a> } -<a class="jxr_linenumber" name="L1054" href="#L1054">1054</a> -<a class="jxr_linenumber" name="L1055" href="#L1055">1055</a> <strong class="jxr_keyword">if</strong> (!allowFlawedHierarchy) { -<a class="jxr_linenumber" name="L1056" href="#L1056">1056</a> <strong class="jxr_keyword">final</strong> StringBuilder msg = <strong class="jxr_keyword">new</strong> StringBuilder(); -<a class="jxr_linenumber" name="L1057" href="#L1057">1057</a> msg.append(<span class="jxr_string">"Terminating logging for this context "</span>); -<a class="jxr_linenumber" name="L1058" href="#L1058">1058</a> msg.append(<span class="jxr_string">"due to bad log hierarchy. "</span>); -<a class="jxr_linenumber" name="L1059" href="#L1059">1059</a> msg.append(<span class="jxr_string">"You have more than one version of '"</span>); -<a class="jxr_linenumber" name="L1060" href="#L1060">1060</a> msg.append(Log.<strong class="jxr_keyword">class</strong>.getName()); -<a class="jxr_linenumber" name="L1061" href="#L1061">1061</a> msg.append(<span class="jxr_string">"' visible."</span>); -<a class="jxr_linenumber" name="L1062" href="#L1062">1062</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L1063" href="#L1063">1063</a> logDiagnostic(msg.toString()); -<a class="jxr_linenumber" name="L1064" href="#L1064">1064</a> } -<a class="jxr_linenumber" name="L1065" href="#L1065">1065</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a>(msg.toString()); -<a class="jxr_linenumber" name="L1066" href="#L1066">1066</a> } -<a class="jxr_linenumber" name="L1067" href="#L1067">1067</a> -<a class="jxr_linenumber" name="L1068" href="#L1068">1068</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L1069" href="#L1069">1069</a> <strong class="jxr_keyword">final</strong> StringBuilder msg = <strong class="jxr_keyword">new</strong> StringBuilder(); -<a class="jxr_linenumber" name="L1070" href="#L1070">1070</a> msg.append(<span class="jxr_string">"Warning: bad log hierarchy. "</span>); -<a class="jxr_linenumber" name="L1071" href="#L1071">1071</a> msg.append(<span class="jxr_string">"You have more than one version of '"</span>); -<a class="jxr_linenumber" name="L1072" href="#L1072">1072</a> msg.append(Log.<strong class="jxr_keyword">class</strong>.getName()); -<a class="jxr_linenumber" name="L1073" href="#L1073">1073</a> msg.append(<span class="jxr_string">"' visible."</span>); -<a class="jxr_linenumber" name="L1074" href="#L1074">1074</a> logDiagnostic(msg.toString()); -<a class="jxr_linenumber" name="L1075" href="#L1075">1075</a> } -<a class="jxr_linenumber" name="L1076" href="#L1076">1076</a> } <strong class="jxr_keyword">else</strong> { -<a class="jxr_linenumber" name="L1077" href="#L1077">1077</a> <em class="jxr_comment">// this is just a bad adapter class</em> -<a class="jxr_linenumber" name="L1078" href="#L1078">1078</a> <strong class="jxr_keyword">if</strong> (!allowFlawedDiscovery) { -<a class="jxr_linenumber" name="L1079" href="#L1079">1079</a> <strong class="jxr_keyword">final</strong> StringBuilder msg = <strong class="jxr_keyword">new</strong> StringBuilder(); -<a class="jxr_linenumber" name="L1080" href="#L1080">1080</a> msg.append(<span class="jxr_string">"Terminating logging for this context. "</span>); -<a class="jxr_linenumber" name="L1081" href="#L1081">1081</a> msg.append(<span class="jxr_string">"Log class '"</span>); -<a class="jxr_linenumber" name="L1082" href="#L1082">1082</a> msg.append(badClass.getName()); -<a class="jxr_linenumber" name="L1083" href="#L1083">1083</a> msg.append(<span class="jxr_string">"' does not implement the Log interface."</span>); -<a class="jxr_linenumber" name="L1084" href="#L1084">1084</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L1085" href="#L1085">1085</a> logDiagnostic(msg.toString()); -<a class="jxr_linenumber" name="L1086" href="#L1086">1086</a> } -<a class="jxr_linenumber" name="L1087" href="#L1087">1087</a> -<a class="jxr_linenumber" name="L1088" href="#L1088">1088</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a>(msg.toString()); -<a class="jxr_linenumber" name="L1089" href="#L1089">1089</a> } -<a class="jxr_linenumber" name="L1090" href="#L1090">1090</a> -<a class="jxr_linenumber" name="L1091" href="#L1091">1091</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { -<a class="jxr_linenumber" name="L1092" href="#L1092">1092</a> <strong class="jxr_keyword">final</strong> StringBuilder msg = <strong class="jxr_keyword">new</strong> StringBuilder(); -<a class="jxr_linenumber" name="L1093" href="#L1093">1093</a> msg.append(<span class="jxr_string">"[WARNING] Log class '"</span>); -<a class="jxr_linenumber" name="L1094" href="#L1094">1094</a> msg.append(badClass.getName()); -<a class="jxr_linenumber" name="L1095" href="#L1095">1095</a> msg.append(<span class="jxr_string">"' does not implement the Log interface."</span>); -<a class="jxr_linenumber" name="L1096" href="#L1096">1096</a> logDiagnostic(msg.toString()); -<a class="jxr_linenumber" name="L1097" href="#L1097">1097</a> } -<a class="jxr_linenumber" name="L1098" href="#L1098">1098</a> } -<a class="jxr_linenumber" name="L1099" href="#L1099">1099</a> } -<a class="jxr_linenumber" name="L1100" href="#L1100">1100</a> -<a class="jxr_linenumber" name="L1101" href="#L1101">1101</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L1102" href="#L1102">1102</a> <em class="jxr_javadoccomment"> * Appends message if the given name is similar to the candidate.</em> -<a class="jxr_linenumber" name="L1103" href="#L1103">1103</a> <em class="jxr_javadoccomment"> * @param messageBuffer {@code StringBuffer} the message should be appended to,</em> -<a class="jxr_linenumber" name="L1104" href="#L1104">1104</a> <em class="jxr_javadoccomment"> * not null</em> -<a class="jxr_linenumber" name="L1105" href="#L1105">1105</a> <em class="jxr_javadoccomment"> * @param name the (trimmed) name to be test against the candidate, not null</em> -<a class="jxr_linenumber" name="L1106" href="#L1106">1106</a> <em class="jxr_javadoccomment"> * @param candidate the candidate name (not null)</em> -<a class="jxr_linenumber" name="L1107" href="#L1107">1107</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L1108" href="#L1108">1108</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> informUponSimilarName(<strong class="jxr_keyword">final</strong> StringBuilder messageBuffer, <strong class="jxr_keyword">final</strong> String name, -<a class="jxr_linenumber" name="L1109" href="#L1109">1109</a> <strong class="jxr_keyword">final</strong> String candidate) { -<a class="jxr_linenumber" name="L1110" href="#L1110">1110</a> <strong class="jxr_keyword">if</strong> (name.equals(candidate)) { -<a class="jxr_linenumber" name="L1111" href="#L1111">1111</a> <em class="jxr_comment">// Don't suggest a name that is exactly the same as the one the</em> -<a class="jxr_linenumber" name="L1112" href="#L1112">1112</a> <em class="jxr_comment">// user tried...</em> -<a class="jxr_linenumber" name="L1113" href="#L1113">1113</a> <strong class="jxr_keyword">return</strong>; -<a class="jxr_linenumber" name="L1114" href="#L1114">1114</a> } -<a class="jxr_linenumber" name="L1115" href="#L1115">1115</a> -<a class="jxr_linenumber" name="L1116" href="#L1116">1116</a> <em class="jxr_comment">// If the user provides a name that is in the right package, and gets</em> -<a class="jxr_linenumber" name="L1117" href="#L1117">1117</a> <em class="jxr_comment">// the first 5 characters of the adapter class right (ignoring case),</em> -<a class="jxr_linenumber" name="L1118" href="#L1118">1118</a> <em class="jxr_comment">// then suggest the candidate adapter class name.</em> -<a class="jxr_linenumber" name="L1119" href="#L1119">1119</a> <strong class="jxr_keyword">if</strong> (name.regionMatches(<strong class="jxr_keyword">true</strong>, 0, candidate, 0, PKG_LEN + 5)) { -<a class="jxr_linenumber" name="L1120" href="#L1120">1120</a> messageBuffer.append(<span class="jxr_string">" Did you mean '"</span>); -<a class="jxr_linenumber" name="L1121" href="#L1121">1121</a> messageBuffer.append(candidate); -<a class="jxr_linenumber" name="L1122" href="#L1122">1122</a> messageBuffer.append(<span class="jxr_string">"'?"</span>); -<a class="jxr_linenumber" name="L1123" href="#L1123">1123</a> } -<a class="jxr_linenumber" name="L1124" href="#L1124">1124</a> } -<a class="jxr_linenumber" name="L1125" href="#L1125">1125</a> -<a class="jxr_linenumber" name="L1126" href="#L1126">1126</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L1127" href="#L1127">1127</a> <em class="jxr_javadoccomment"> * Initialize a number of variables that control the behavior of this</em> -<a class="jxr_linenumber" name="L1128" href="#L1128">1128</a> <em class="jxr_javadoccomment"> * class and that can be tweaked by the user. This is done when the first</em> -<a class="jxr_linenumber" name="L1129" href="#L1129">1129</a> <em class="jxr_javadoccomment"> * logger is created, not in the constructor of this class, because we</em> -<a class="jxr_linenumber" name="L1130" href="#L1130">1130</a> <em class="jxr_javadoccomment"> * need to give the user a chance to call method setAttribute in order to</em> -<a class="jxr_linenumber" name="L1131" href="#L1131">1131</a> <em class="jxr_javadoccomment"> * configure this object.</em> -<a class="jxr_linenumber" name="L1132" href="#L1132">1132</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L1133" href="#L1133">1133</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> initConfiguration() { -<a class="jxr_linenumber" name="L1134" href="#L1134">1134</a> allowFlawedContext = getBooleanConfiguration(ALLOW_FLAWED_CONTEXT_PROPERTY, <strong class="jxr_keyword">true</strong>); -<a class="jxr_linenumber" name="L1135" href="#L1135">1135</a> allowFlawedDiscovery = getBooleanConfiguration(ALLOW_FLAWED_DISCOVERY_PROPERTY, <strong class="jxr_keyword">true</strong>); -<a class="jxr_linenumber" name="L1136" href="#L1136">1136</a> allowFlawedHierarchy = getBooleanConfiguration(ALLOW_FLAWED_HIERARCHY_PROPERTY, <strong class="jxr_keyword">true</strong>); -<a class="jxr_linenumber" name="L1137" href="#L1137">1137</a> } -<a class="jxr_linenumber" name="L1138" href="#L1138">1138</a> -<a class="jxr_linenumber" name="L1139" href="#L1139">1139</a> <em class="jxr_javadoccomment">/**</em> -<a class="jxr_linenumber" name="L1140" href="#L1140">1140</a> <em class="jxr_javadoccomment"> * Calculate and cache a string that uniquely identifies this instance,</em> -<a class="jxr_linenumber" name="L1141" href="#L1141">1141</a> <em class="jxr_javadoccomment"> * including which class loader the object was loaded from.</em> -<a class="jxr_linenumber" name="L1142" href="#L1142">1142</a> <em class="jxr_javadoccomment"> * <p></em> -<a class="jxr_linenumber" name="L1143" href="#L1143">1143</a> <em class="jxr_javadoccomment"> * This string will later be prefixed to each "internal logging" message</em> -<a class="jxr_linenumber" name="L1144" href="#L1144">1144</a> <em class="jxr_javadoccomment"> * emitted, so that users can clearly see any unexpected behavior.</em> -<a class="jxr_linenumber" name="L1145" href="#L1145">1145</a> <em class="jxr_javadoccomment"> * <p></em> -<a class="jxr_linenumber" name="L1146" href="#L1146">1146</a> <em class="jxr_javadoccomment"> * Note that this method does not detect whether internal logging is</em> -<a class="jxr_linenumber" name="L1147" href="#L1147">1147</a> <em class="jxr_javadoccomment"> * enabled or not, nor where to output stuff if it is; that is all</em> -<a class="jxr_linenumber" name="L1148" href="#L1148">1148</a> <em class="jxr_javadoccomment"> * handled by the parent LogFactory class. This method just computes</em> -<a class="jxr_linenumber" name="L1149" href="#L1149">1149</a> <em class="jxr_javadoccomment"> * its own unique prefix for log messages.</em> -<a class="jxr_linenumber" name="L1150" href="#L1150">1150</a> <em class="jxr_javadoccomment"> */</em> -<a class="jxr_linenumber" name="L1151" href="#L1151">1151</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> initDiagnostics() { -<a class="jxr_linenumber" name="L1152" href="#L1152">1152</a> <em class="jxr_comment">// It would be nice to include an identifier of the context class loader</em> -<a class="jxr_linenumber" name="L1153" href="#L1153">1153</a> <em class="jxr_comment">// that this LogFactoryImpl object is responsible for. However that</em> -<a class="jxr_linenumber" name="L1154" href="#L1154">1154</a> <em class="jxr_comment">// isn't possible as that information isn't available. It is possible</em> -<a class="jxr_linenumber" name="L1155" href="#L1155">1155</a> <em class="jxr_comment">// to figure this out by looking at the logging from LogFactory to</em> -<a class="jxr_linenumber" name="L1156" href="#L1156">1156</a> <em class="jxr_comment">// see the context & impl ids from when this object was instantiated,</em> -<a class="jxr_linenumber" name="L1157" href="#L1157">1157</a> <em class="jxr_comment">// in order to link the impl id output as this object's prefix back to</em> -<a class="jxr_linenumber" name="L1158" href="#L1158">1158</a> <em class="jxr_comment">// the context it is intended to manage.</em> -<a class="jxr_linenumber" name="L1159" href="#L1159">1159</a> <em class="jxr_comment">// Note that this prefix should be kept consistent with that</em> -<a class="jxr_linenumber" name="L1160" href="#L1160">1160</a> <em class="jxr_comment">// in LogFactory.</em> -<a class="jxr_linenumber" name="L1161" href="#L1161">1161</a> <strong class="jxr_keyword">final</strong> Class clazz = <strong class="jxr_keyword">this</strong>.getClass(); +<a class="jxr_linenumber" name="L679" href="#L679">679</a> <em class="jxr_javadoccomment"> */</em> +<a class="jxr_linenumber" name="L680" href="#L680">680</a> <strong class="jxr_keyword">private</strong> ClassLoader getBaseClassLoader() <strong class="jxr_keyword">throws</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a> { +<a class="jxr_linenumber" name="L681" href="#L681">681</a> <strong class="jxr_keyword">final</strong> ClassLoader thisClassLoader = getClassLoader(LogFactoryImpl.<strong class="jxr_keyword">class</strong>); +<a class="jxr_linenumber" name="L682" href="#L682">682</a> +<a class="jxr_linenumber" name="L683" href="#L683">683</a> <strong class="jxr_keyword">if</strong> (!useTCCL) { +<a class="jxr_linenumber" name="L684" href="#L684">684</a> <strong class="jxr_keyword">return</strong> thisClassLoader; +<a class="jxr_linenumber" name="L685" href="#L685">685</a> } +<a class="jxr_linenumber" name="L686" href="#L686">686</a> +<a class="jxr_linenumber" name="L687" href="#L687">687</a> <strong class="jxr_keyword">final</strong> ClassLoader contextClassLoader = getContextClassLoaderInternal(); +<a class="jxr_linenumber" name="L688" href="#L688">688</a> +<a class="jxr_linenumber" name="L689" href="#L689">689</a> <strong class="jxr_keyword">final</strong> ClassLoader baseClassLoader = getLowestClassLoader( +<a class="jxr_linenumber" name="L690" href="#L690">690</a> contextClassLoader, thisClassLoader); +<a class="jxr_linenumber" name="L691" href="#L691">691</a> +<a class="jxr_linenumber" name="L692" href="#L692">692</a> <strong class="jxr_keyword">if</strong> (baseClassLoader == <strong class="jxr_keyword">null</strong>) { +<a class="jxr_linenumber" name="L693" href="#L693">693</a> <em class="jxr_comment">// The two class loaders are not part of a parent child relationship.</em> +<a class="jxr_linenumber" name="L694" href="#L694">694</a> <em class="jxr_comment">// In some classloading setups (e.g. JBoss with its</em> +<a class="jxr_linenumber" name="L695" href="#L695">695</a> <em class="jxr_comment">// UnifiedLoaderRepository) this can still work, so if user hasn't</em> +<a class="jxr_linenumber" name="L696" href="#L696">696</a> <em class="jxr_comment">// forbidden it, just return the contextClassLoader.</em> +<a class="jxr_linenumber" name="L697" href="#L697">697</a> <strong class="jxr_keyword">if</strong> (!allowFlawedContext) { +<a class="jxr_linenumber" name="L698" href="#L698">698</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a>(<span class="jxr_string">"Bad class loader hierarchy; LogFactoryImpl was loaded via"</span> + +<a class="jxr_linenumber" name="L699" href="#L699">699</a> <span class="jxr_string">" a class loader that is not related to the current context"</span> + +<a class="jxr_linenumber" name="L700" href="#L700">700</a> <span class="jxr_string">" class loader."</span>); +<a class="jxr_linenumber" name="L701" href="#L701">701</a> } +<a class="jxr_linenumber" name="L702" href="#L702">702</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { +<a class="jxr_linenumber" name="L703" href="#L703">703</a> logDiagnostic(<span class="jxr_string">"[WARNING] the context class loader is not part of a"</span> + +<a class="jxr_linenumber" name="L704" href="#L704">704</a> <span class="jxr_string">" parent-child relationship with the class loader that"</span> + +<a class="jxr_linenumber" name="L705" href="#L705">705</a> <span class="jxr_string">" loaded LogFactoryImpl."</span>); +<a class="jxr_linenumber" name="L706" href="#L706">706</a> } +<a class="jxr_linenumber" name="L707" href="#L707">707</a> <em class="jxr_comment">// If contextClassLoader were null, getLowestClassLoader() would</em> +<a class="jxr_linenumber" name="L708" href="#L708">708</a> <em class="jxr_comment">// have returned thisClassLoader. The fact we are here means</em> +<a class="jxr_linenumber" name="L709" href="#L709">709</a> <em class="jxr_comment">// contextClassLoader is not null, so we can just return it.</em> +<a class="jxr_linenumber" name="L710" href="#L710">710</a> <strong class="jxr_keyword">return</strong> contextClassLoader; +<a class="jxr_linenumber" name="L711" href="#L711">711</a> } +<a class="jxr_linenumber" name="L712" href="#L712">712</a> +<a class="jxr_linenumber" name="L713" href="#L713">713</a> <strong class="jxr_keyword">if</strong> (baseClassLoader != contextClassLoader) { +<a class="jxr_linenumber" name="L714" href="#L714">714</a> <em class="jxr_comment">// We really should just use the contextClassLoader as the starting</em> +<a class="jxr_linenumber" name="L715" href="#L715">715</a> <em class="jxr_comment">// point for scanning for log adapter classes. However it is expected</em> +<a class="jxr_linenumber" name="L716" href="#L716">716</a> <em class="jxr_comment">// that there are a number of broken systems out there which create</em> +<a class="jxr_linenumber" name="L717" href="#L717">717</a> <em class="jxr_comment">// custom class loaders but fail to set the context class loader so</em> +<a class="jxr_linenumber" name="L718" href="#L718">718</a> <em class="jxr_comment">// we handle those flawed systems anyway.</em> +<a class="jxr_linenumber" name="L719" href="#L719">719</a> <strong class="jxr_keyword">if</strong> (!allowFlawedContext) { +<a class="jxr_linenumber" name="L720" href="#L720">720</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a name="LogConfigurationException" href="../../../../../org/apache/commons/logging/LogConfigurationException.html#LogConfigurationException">LogConfigurationException</a>( +<a class="jxr_linenumber" name="L721" href="#L721">721</a> <span class="jxr_string">"Bad class loader hierarchy; LogFactoryImpl was loaded via"</span> + +<a class="jxr_linenumber" name="L722" href="#L722">722</a> <span class="jxr_string">" a class loader that is not related to the current context"</span> + +<a class="jxr_linenumber" name="L723" href="#L723">723</a> <span class="jxr_string">" class loader."</span>); +<a class="jxr_linenumber" name="L724" href="#L724">724</a> } +<a class="jxr_linenumber" name="L725" href="#L725">725</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { +<a class="jxr_linenumber" name="L726" href="#L726">726</a> logDiagnostic( +<a class="jxr_linenumber" name="L727" href="#L727">727</a> <span class="jxr_string">"Warning: the context class loader is an ancestor of the"</span> + +<a class="jxr_linenumber" name="L728" href="#L728">728</a> <span class="jxr_string">" class loader that loaded LogFactoryImpl; it should be"</span> + +<a class="jxr_linenumber" name="L729" href="#L729">729</a> <span class="jxr_string">" the same or a descendant. The application using"</span> + +<a class="jxr_linenumber" name="L730" href="#L730">730</a> <span class="jxr_string">" commons-logging should ensure the context class loader"</span> + +<a class="jxr_linenumber" name="L731" href="#L731">731</a> <span class="jxr_string">" is used correctly."</span>); +<a class="jxr_linenumber" name="L732" href="#L732">732</a> } +<a class="jxr_linenumber" name="L733" href="#L733">733</a> } +<a class="jxr_linenumber" name="L734" href="#L734">734</a> +<a class="jxr_linenumber" name="L735" href="#L735">735</a> <strong class="jxr_keyword">return</strong> baseClassLoader; +<a class="jxr_linenumber" name="L736" href="#L736">736</a> } +<a class="jxr_linenumber" name="L737" href="#L737">737</a> +<a class="jxr_linenumber" name="L738" href="#L738">738</a> <em class="jxr_javadoccomment">/**</em> +<a class="jxr_linenumber" name="L739" href="#L739">739</a> <em class="jxr_javadoccomment"> * Gets the setting for the user-configurable behavior specified by key.</em> +<a class="jxr_linenumber" name="L740" href="#L740">740</a> <em class="jxr_javadoccomment"> * If nothing has explicitly been set, then return dflt.</em> +<a class="jxr_linenumber" name="L741" href="#L741">741</a> <em class="jxr_javadoccomment"> */</em> +<a class="jxr_linenumber" name="L742" href="#L742">742</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> getBooleanConfiguration(<strong class="jxr_keyword">final</strong> String key, <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> dflt) { +<a class="jxr_linenumber" name="L743" href="#L743">743</a> <strong class="jxr_keyword">final</strong> String val = getConfigurationValue(key); +<a class="jxr_linenumber" name="L744" href="#L744">744</a> <strong class="jxr_keyword">if</strong> (val == <strong class="jxr_keyword">null</strong>) { +<a class="jxr_linenumber" name="L745" href="#L745">745</a> <strong class="jxr_keyword">return</strong> dflt; +<a class="jxr_linenumber" name="L746" href="#L746">746</a> } +<a class="jxr_linenumber" name="L747" href="#L747">747</a> <strong class="jxr_keyword">return</strong> Boolean.parseBoolean(val); +<a class="jxr_linenumber" name="L748" href="#L748">748</a> } +<a class="jxr_linenumber" name="L749" href="#L749">749</a> +<a class="jxr_linenumber" name="L750" href="#L750">750</a> <em class="jxr_javadoccomment">/**</em> +<a class="jxr_linenumber" name="L751" href="#L751">751</a> <em class="jxr_javadoccomment"> * Attempt to find an attribute (see method setAttribute) or a</em> +<a class="jxr_linenumber" name="L752" href="#L752">752</a> <em class="jxr_javadoccomment"> * system property with the provided name and return its value.</em> +<a class="jxr_linenumber" name="L753" href="#L753">753</a> <em class="jxr_javadoccomment"> * <p></em> +<a class="jxr_linenumber" name="L754" href="#L754">754</a> <em class="jxr_javadoccomment"> * The attributes associated with this object are checked before</em> +<a class="jxr_linenumber" name="L755" href="#L755">755</a> <em class="jxr_javadoccomment"> * system properties in case someone has explicitly called setAttribute,</em> +<a class="jxr_linenumber" name="L756" href="#L756">756</a> <em class="jxr_javadoccomment"> * or a configuration property has been set in a commons-logging.properties</em> +<a class="jxr_linenumber" name="L757" href="#L757">757</a> <em class="jxr_javadoccomment"> * file.</em> +<a class="jxr_linenumber" name="L758" href="#L758">758</a> <em class="jxr_javadoccomment"> *</em> +<a class="jxr_linenumber" name="L759" href="#L759">759</a> <em class="jxr_javadoccomment"> * @return the value associated with the property, or null.</em> +<a class="jxr_linenumber" name="L760" href="#L760">760</a> <em class="jxr_javadoccomment"> */</em> +<a class="jxr_linenumber" name="L761" href="#L761">761</a> <strong class="jxr_keyword">private</strong> String getConfigurationValue(<strong class="jxr_keyword">final</strong> String property) { +<a class="jxr_linenumber" name="L762" href="#L762">762</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { +<a class="jxr_linenumber" name="L763" href="#L763">763</a> logDiagnostic(<span class="jxr_string">"[ENV] Trying to get configuration for item "</span> + property); +<a class="jxr_linenumber" name="L764" href="#L764">764</a> } +<a class="jxr_linenumber" name="L765" href="#L765">765</a> +<a class="jxr_linenumber" name="L766" href="#L766">766</a> <strong class="jxr_keyword">final</strong> Object valueObj = getAttribute(property); +<a class="jxr_linenumber" name="L767" href="#L767">767</a> <strong class="jxr_keyword">if</strong> (valueObj != <strong class="jxr_keyword">null</strong>) { +<a class="jxr_linenumber" name="L768" href="#L768">768</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { +<a class="jxr_linenumber" name="L769" href="#L769">769</a> logDiagnostic(<span class="jxr_string">"[ENV] Found LogFactory attribute ["</span> + valueObj + <span class="jxr_string">"] for "</span> + property); +<a class="jxr_linenumber" name="L770" href="#L770">770</a> } +<a class="jxr_linenumber" name="L771" href="#L771">771</a> <strong class="jxr_keyword">return</strong> valueObj.toString(); +<a class="jxr_linenumber" name="L772" href="#L772">772</a> } +<a class="jxr_linenumber" name="L773" href="#L773">773</a> +<a class="jxr_linenumber" name="L774" href="#L774">774</a> <strong class="jxr_keyword">if</strong> (isDiagnosticsEnabled()) { +<a class="jxr_linenumber" name="L775" href="#L775">775</a> logDiagnostic(<span class="jxr_string">"[ENV] No LogFactory attribute found for "</span> + property); +<a class="jxr_linenumber" name="L776" href="#L776">776</a> } +<a class="jxr_linenumber" name="L777" href="#L777">777</a> +<a class="jxr_linenumber" name="L778" href="#L778">778</a> <strong class="jxr_keyword">try</strong> { +<a class="jxr_linenumber" name="L779" href="#L779">779</a> <em class="jxr_comment">// warning: minor security hole here, in that we potentially read a system</em> +<a class="jxr_linenumber" name="L780" href="#L780">780</a> <em class="jxr_comment">// property that the caller cannot, then output it in readable form as a</em>
[... 394 lines stripped ...]