You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@zookeeper.apache.org by "xiaoqin.fu (JIRA)" <ji...@apache.org> on 2019/08/13 15:24:00 UTC

[jira] [Updated] (ZOOKEEPER-3487) Execution the same conditional statement twice in ZooTrace

     [ https://issues.apache.org/jira/browse/ZOOKEEPER-3487?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

xiaoqin.fu updated ZOOKEEPER-3487:
----------------------------------
    Description: 
    public static void logTraceMessage(Logger log, long mask, String msg) {
        if (isTraceEnabled(log, mask)) {
            log.trace(msg);
        }
    }

    static public void logQuorumPacket(Logger log, long mask,
            char direction, QuorumPacket qp)
    {
        if (isTraceEnabled(log, mask)) { 
            logTraceMessage(log, mask, direction +
                    " " + LearnerHandler.packetToString(qp));
         }
    }	
	
	We should remove one of two "if (isTraceEnabled(log, mask))" conditional statements:
	
    public static void logTraceMessage(Logger log, long mask, String msg) {
        if (isTraceEnabled(log, mask)) {
            log.trace(msg);
        }
    }
    static public void logQuorumPacket(Logger log, long mask,
            char direction, QuorumPacket qp)
    {
            logTraceMessage(log, mask, direction +
                    " " + LearnerHandler.packetToString(qp));        
    }		

  was:
	In org.apache.zookeeper.server.ZooTrace, a conditional statement may be executed twice:
	Method logQuorumPacket calls method logTraceMessage with same conditional statement "if (isTraceEnabled(log, mask))".
	If other methods call logQuorumPacket, they execute "if (isTraceEnabled(log, mask))" conditional statement twice.
	We should remove one of two "if (isTraceEnabled(log, mask))" conditional statements.


> Execution the same conditional statement twice in ZooTrace
> ----------------------------------------------------------
>
>                 Key: ZOOKEEPER-3487
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3487
>             Project: ZooKeeper
>          Issue Type: Improvement
>          Components: server
>    Affects Versions: 3.4.11, 3.4.12, 3.4.13, 3.5.5, 3.4.14
>         Environment: 	Ubuntu 16.04.3 LTS
> 	Open JDK version "1.8.0_191" build 25.191-b12
>            Reporter: xiaoqin.fu
>            Priority: Minor
>
>     public static void logTraceMessage(Logger log, long mask, String msg) {
>         if (isTraceEnabled(log, mask)) {
>             log.trace(msg);
>         }
>     }
>     static public void logQuorumPacket(Logger log, long mask,
>             char direction, QuorumPacket qp)
>     {
>         if (isTraceEnabled(log, mask)) { 
>             logTraceMessage(log, mask, direction +
>                     " " + LearnerHandler.packetToString(qp));
>          }
>     }	
> 	
> 	We should remove one of two "if (isTraceEnabled(log, mask))" conditional statements:
> 	
>     public static void logTraceMessage(Logger log, long mask, String msg) {
>         if (isTraceEnabled(log, mask)) {
>             log.trace(msg);
>         }
>     }
>     static public void logQuorumPacket(Logger log, long mask,
>             char direction, QuorumPacket qp)
>     {
>             logTraceMessage(log, mask, direction +
>                     " " + LearnerHandler.packetToString(qp));        
>     }		



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)