On Wed, Apr 7, 2021 at 2:42 PM Rainer Jung <rainer.j...@kippdata.de> wrote:
> The only direct calls to AprStatus.isAprAvailable() outside of the > APRLifecycleListener itself are actually in Connector.java. Replacing > those by calls to the listener seems to work for me: > > diff --git a/java/org/apache/catalina/connector/Connector.java > b/java/org/apache/catalina/connector/Connector.java > index 1cc15802eb..53a210e6b2 100644 > --- a/java/org/apache/catalina/connector/Connector.java > +++ b/java/org/apache/catalina/connector/Connector.java > @@ -29,6 +29,7 @@ import org.apache.catalina.Globals; > import org.apache.catalina.LifecycleException; > import org.apache.catalina.LifecycleState; > import org.apache.catalina.Service; > +import org.apache.catalina.core.AprLifecycleListener; > import org.apache.catalina.core.AprStatus; > import org.apache.catalina.util.LifecycleMBeanBase; > import org.apache.coyote.AbstractProtocol; > @@ -80,7 +81,7 @@ public class Connector extends LifecycleMBeanBase { > > > public Connector(String protocol) { > - boolean apr = AprStatus.isAprAvailable() && > + boolean apr = AprLifecycleListener.isAprAvailable() && > Ok, so I thought only the first change was significant, the others occur after AprLifecycleListener runs its init so it should work just fine. Rémy > AprStatus.getUseAprConnector(); > ProtocolHandler p = null; > try { > @@ -1020,11 +1021,11 @@ public class Connector extends LifecycleMBeanBase > { > throw new > > LifecycleException(sm.getString("coyoteConnector.protocolHandlerNoAprListener", > getProtocolHandlerClassName())); > } > - if (protocolHandler.isAprRequired() && > !AprStatus.isAprAvailable()) { > + if (protocolHandler.isAprRequired() && > !AprLifecycleListener.isAprAvailable()) { > throw new > > LifecycleException(sm.getString("coyoteConnector.protocolHandlerNoAprLibrary", > getProtocolHandlerClassName())); > } > - if (AprStatus.isAprAvailable() && AprStatus.getUseOpenSSL() && > + if (AprLifecycleListener.isAprAvailable() && > AprStatus.getUseOpenSSL() && > protocolHandler instanceof AbstractHttp11JsseProtocol) { > AbstractHttp11JsseProtocol<?> jsseProtocolHandler = > (AbstractHttp11JsseProtocol<?>) protocolHandler; > > Feel free to apply. > > Regards, > > Rainer > > > Am 07.04.2021 um 14:32 schrieb Rainer Jung: > > I think the reason is: > > > > o.a.c.connector.Connector checks AprStatus.isAprAvailable(). It > > previously checked AprLifecycleListener.isAprAvailable(). The difference > > is, that the old AprLifecycleListener.isAprAvailable() triggers the > > init() of AprLifecycleListener, whereas AprStatus.isAprAvailable() does > > not. > > > > I think isAprAvailable() is the only method with side effects that was > > moved from AprLifecycleListener to AprStatus. Since it is still > > available in AprLifecycleListener, I think it would be safest to > > typically not call it in AprStatus but instead in AprLifecycleListener. > > > > Regards, > > > > Rainer > > > > Am 07.04.2021 um 14:02 schrieb Rainer Jung: > >> Maybe related to f4dac6846c548144799b1c3f33aba4eb320a3413. > >> > >> Am 07.04.2021 um 13:53 schrieb Rainer Jung: > >>> Hi there, > >>> > >>> a colleague of mine observed a change in behavior starting with TC > >>> 9.0.38: until 9.0.37 the default server.xml with the connector > >>> protocol="HTTP/1.1", installed tcnative and attribute > >>> useAprConnector="true" for the AprLifecycleListener actually starts > >>> an APR connector as documented and expected: > >>> > >>> INFO [main] org.apache.coyote.AbstractProtocol.init Initializing > >>> ProtocolHandler ["http-apr-8080"] > >>> > >>> Same situation starting with 9.0.38 (and at least until 9.0.44): > >>> > >>> INFO [main] org.apache.coyote.AbstractProtocol.init Initializing > >>> ProtocolHandler ["http-nio-8080"] > >>> > >>> I increased log level for a coupe of packages to FINEST and see the > >>> following differences during startup: > >>> > >>> FINE [main] org.apache.tomcat.util.IntrospectionUtils.setProperty > >>> IntrospectionUtils: setProperty(class > >>> org.apache.catalina.core.AprLifecycleListener SSLEngine=on) > >>> FINE [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin > >>> [SetPropertiesRule]{Server/Listener} Setting property > >>> 'useAprConnector' to 'true' > >>> FINE [main] org.apache.tomcat.util.IntrospectionUtils.setProperty > >>> IntrospectionUtils: setProperty(class > >>> org.apache.catalina.core.AprLifecycleListener useAprConnector=true) > >>> ### ONLY ADDRESS DIFFERENCE > >>> -FINE [main] org.apache.tomcat.util.digester.SetNextRule.end > >>> [SetNextRule]{Server/Listener} Call > >>> > org.apache.catalina.core.StandardServer.addLifecycleListener(org.apache.catalina.core.AprLifecycleListener@383534aa) > > >>> > >>> +FINE [main] org.apache.tomcat.util.digester.SetNextRule.end > >>> [SetNextRule]{Server/Listener} Call > >>> > org.apache.catalina.core.StandardServer.addLifecycleListener(org.apache.catalina.core.AprLifecycleListener@136432db) > > >>> > >>> FINE [main] org.apache.tomcat.util.IntrospectionUtils.callMethod1 > >>> IntrospectionUtils: callMethod1 > >>> org.apache.catalina.core.StandardServer > >>> org.apache.catalina.core.AprLifecycleListener > >>> org.apache.catalina.LifecycleListener > >>> FINE [main] org.apache.tomcat.util.digester.ObjectCreateRule.end > >>> [ObjectCreateRule]{Server/Listener} Pop > >>> org.apache.catalina.core.AprLifecycleListener > >>> #### WRONG CLASS CHOSEN IN NEWER VERSIONS > >>> -FINE [main] org.apache.tomcat.util.IntrospectionUtils.setProperty > >>> IntrospectionUtils: setProperty(class > >>> org.apache.coyote.http11.Http11AprProtocol port=8080) > >>> +FINE [main] org.apache.tomcat.util.IntrospectionUtils.setProperty > >>> IntrospectionUtils: setProperty(class > >>> org.apache.coyote.http11.Http11NioProtocol port=8080) > >>> FINE [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin > >>> [SetPropertiesRule]{Server/Service/Connector} Setting property > >>> 'protocol' to 'HTTP/1.1' > >>> ... > >>> > >>> and after these lines the logs use consistenly APR versus NIO in the > >>> two versions. Both startup logs show the same > >>> > >>> INFO [main] > >>> org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded > >>> Apache Tomcat Native library [1.2.27] using APR version [1.7.0]. > >>> INFO [main] > >>> org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR > >>> capabilities: IPv6 [true], sendfile [true], accept filters [false], > >>> random [true]. > >>> INFO [main] > >>> org.apache.catalina.core.AprLifecycleListener.lifecycleEvent > >>> APR/OpenSSL configuration: useAprConnector [true], useOpenSSL [true] > >>> INFO [main] > >>> org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL > >>> successfully initialized [OpenSSL 1.1.1k 25 Mar 2021] > >>> > >>> I didn't find an obvious reason in the changelog. Maybe an unwanted > >>> backport part from 10 or some startup order change. > >>> > >>> I have not yet checked 8.5 etc. > >>> > >>> Regards, > >>> > >>> Rainer > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > > For additional commands, e-mail: dev-h...@tomcat.apache.org > > > > -- > kippdata > informationstechnologie GmbH Tel: 0228 98549 -0 > Bornheimer Str. 33a Fax: 0228 98549 -50 > 53111 Bonn www.kippdata.de > > HRB 8018 Amtsgericht Bonn / USt.-IdNr. DE 196 457 417 > Geschäftsführer: Dr. Thomas Höfer, Rainer Jung, Sven Maurmann > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > >