https://issues.apache.org/bugzilla/show_bug.cgi?id=48613

--- Comment #3 from Konstantin Kolinko <knst.koli...@gmail.com> 2010-01-27 
19:22:27 UTC ---
Filip, the proposed patch (rev.903928) is wrong -- see sequence of calls
described in the Comment 1 in this issue.

Connector#setProtocol(String) is called by Digester when creating instance of
the Connector,  and that happens long before the Lifecycle event is fired and
reaches the listener.

Thus, with the patch, AprLifecycleListener will report that the native library
is found, but Connector#setProtocol(String) will create a non-Apr connector.
(an exact opposite of Bug 48311).

It can be seen in the logs, running the trunk as of rev.903928:

28.01.2010 6:12:55 org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.19.
28.01.2010 6:12:55 org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false],
ra
ndom [true].
28.01.2010 6:12:56 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
28.01.2010 6:12:56 org.apache.coyote.ajp.AjpProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009

Note that "Http11Protocol" and "AjpProtocol" were printed, instead of 
"Http11AprProtocol" and "AjpAprProtocol" that were expected. 


I see two ways of fixing the current issue:
a) quick but somewhat dirty:

Use the fact that AprLifecycleListener instance is created by digester before
the instance of a connector.

That is, in AprLifecycleListener class constructor set some volatile static
field as a flag stating that "an instance of the Listener was created" and test
that flag in the init() method.

I wonder, whether we will need to wait for Lifecycle.INIT_EVENT to happen, or
all initialization (including initializeSSL() call) can be done at the same
time.


b) more elaborate,

Change implementation of o.a.c.connector.Connector, to defer the
AprLifecycleListener.isAprAvailable() call until Connector#start() is called.

This means:
 #  in Connector#setProtocol(String) method: do not initialize
protocolHandlerClassName field there
 #  in Connector(String) constructor: do not initialize protocolHandler field
 #  in Connector#setProperty(String, String) method: allow it to work when
protocolHandler is not yet initialized, e.g. by caching the values in a map

But with such a change Connector#setProperty() won't be able to report about
unknown properties at call time, thus "Warn if the user tries to set an invalid
property" feature will need to be reimplemented here.



Thus it looks to me that it would be better to go with a).

If we refuse to go with b), then Connector#setProtocol() and
Connector#setProtocolHandlerClassName methods can be made private (or at least
protected), because as of now they work only when called from Connector(String)
constructor.

Comments?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to