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

Beibei Zhao updated ZOOKEEPER-4648:
-----------------------------------
    Description: 
FinalRequestProcessor addAuditLog before the process of request and make 
failedTxn=false, but I think failedTxn should be true if the request can not 
pass the checkACL and throw KeeperException.
{code:java}
@param failedTxn whether audit is being done failed transaction for normal 
transaction

public void processRequest(Request request) {
        ......
        try {
            ......
            AuditHelper.addAuditLog(request, rc);

            switch (request.type) {
            ......
            case OpCode.getAllChildrenNumber: {
                lastOp = "GETACN";
                ......
                zks.checkACL(
                    request.cnxn,
                    zks.getZKDatabase().aclForNode(n),
                    ZooDefs.Perms.READ,
                    request.authInfo,
                    path,
                    null);
                ......
                break;
            }
            ......
            }
        } catch (SessionMovedException e) {
            ......
        } catch (KeeperException e) {
            err = e.code();
        } catch (Exception e) {
            ......
        }
{code}


  was:

which rc is better???

{code:java}
public void processRequest(Request request) {
        ......
        try {
            if (request.getHdr() != null && request.getHdr().getType() == 
OpCode.error) {
                AuditHelper.addAuditLog(request, rc, true);
                /*
                 * When local session upgrading is disabled, leader will
                 * reject the ephemeral node creation due to session expire.
                 * However, if this is the follower that issue the request,
                 * it will have the correct error code, so we should use that
                 * and report to user
                 */
                if (request.getException() != null) {
                    throw request.getException();
                } else {
                    throw 
KeeperException.create(KeeperException.Code.get(((ErrorTxn) 
request.getTxn()).getErr()));
                }
            }

            ......
            AuditHelper.addAuditLog(request, rc);

            switch (request.type) {
            ......
            case OpCode.getAllChildrenNumber: {
                lastOp = "GETACN";
                ......
                zks.checkACL(
                    request.cnxn,
                    zks.getZKDatabase().aclForNode(n),
                    ZooDefs.Perms.READ,
                    request.authInfo,
                    path,
                    null);
                ......
                break;
            }
            ......
            }
        } catch (SessionMovedException e) {
            ......
        } catch (KeeperException e) {
            err = e.code();
        } catch (Exception e) {
            ......
        }
{code}



> FinalRequestProcessor addAuditLog after the process of request maybe better.
> ----------------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-4648
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4648
>             Project: ZooKeeper
>          Issue Type: Bug
>            Reporter: Beibei Zhao
>            Priority: Major
>
> FinalRequestProcessor addAuditLog before the process of request and make 
> failedTxn=false, but I think failedTxn should be true if the request can not 
> pass the checkACL and throw KeeperException.
> {code:java}
> @param failedTxn whether audit is being done failed transaction for normal 
> transaction
> public void processRequest(Request request) {
>         ......
>         try {
>             ......
>             AuditHelper.addAuditLog(request, rc);
>             switch (request.type) {
>             ......
>             case OpCode.getAllChildrenNumber: {
>                 lastOp = "GETACN";
>                 ......
>                 zks.checkACL(
>                     request.cnxn,
>                     zks.getZKDatabase().aclForNode(n),
>                     ZooDefs.Perms.READ,
>                     request.authInfo,
>                     path,
>                     null);
>                 ......
>                 break;
>             }
>             ......
>             }
>         } catch (SessionMovedException e) {
>             ......
>         } catch (KeeperException e) {
>             err = e.code();
>         } catch (Exception e) {
>             ......
>         }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to