You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2014/06/02 01:59:27 UTC

[Bug 56582] New: Use switch(enum) in implementations of ActionHook.action(ActionCode, ...)

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

            Bug ID: 56582
           Summary: Use switch(enum) in implementations of
                    ActionHook.action(ActionCode, ...)
           Product: Tomcat 8
           Version: 8.0.8
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Connectors
          Assignee: dev@tomcat.apache.org
          Reporter: knst.kolinko@gmail.com

As of now,
AbstractHttp11Processor.action(ActionCode, Object)
AbstractAjpProcessor.action(ActionCode, Object)

are implemented as a chain of if/elseif going through every defined ActionCode.

As ActionCode is an enum starting with Tomcat 7, I think it would be better to
reorganize the code to use switch(enum) construct.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56582] Use switch(enum) in implementations of ActionHook.action(ActionCode, ...)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56582

--- Comment #4 from Christopher Schultz <ch...@christopherschultz.net> ---
(In reply to Konstantin Kolinko from comment #1)
> I plan to backport this change to Tomcat 7, as I think switch() behaves
> better for performance.

+1

A tableswitch will be faster than a series of comparisons and jumps. If the set
of cases is sufficiently sparse, it will degrade to a lookupswitch which is no
slower than the old if/elseif implementation and may be a bit faster as
lookupswitch is likely to be a highly-optimized JVM operation not requiring any
JIT trickery.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56582] Use switch(enum) in implementations of ActionHook.action(ActionCode, ...)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56582

Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Konstantin Kolinko <kn...@gmail.com> ---
(In reply to Konstantin Kolinko from comment #1)

Implemented DISPATCH_EXECUTE action code for AJP connectors in Tomcat 8 by
r1599752, will be in 8.0.9.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56582] Use switch(enum) in implementations of ActionHook.action(ActionCode, ...)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56582

--- Comment #2 from Konstantin Kolinko <kn...@gmail.com> ---
Done for Tomcat 7 (r1599505 r1599711) and will be in 7.0.55.

I am ready to close this issue, but  DISPATCH_EXECUTE + AJP question for Tomcat
8 from Comment 1 is pending.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


[Bug 56582] Use switch(enum) in implementations of ActionHook.action(ActionCode, ...)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56582

--- Comment #1 from Konstantin Kolinko <kn...@gmail.com> ---
Done for Tomcat 8 (r1599385 r1599393 r1599395), will be in 8.0.9.

I plan to backport this change to Tomcat 7, as I think switch() behaves better
for performance.

One possible error spotted thanks to IDE warning:
DISPATCH_EXECUTE action code is not processed by AbstractAjpProcessor.
I placed a FIXME comment there.

The fix is likely to copy the code from AbstractHttp11Processor.action():
        case DISPATCH_EXECUTE: {
            getEndpoint().executeNonBlockingDispatches(socketWrapper);
            break;
        }

-- 
You are receiving this mail because:
You are the assignee for the bug.

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