Browse Source

ZOOKEEPER-1247. dead code in PrepRequestProcessor.pRequest multi case (Thomas Koch via phunt)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1190073 13f79535-47bb-0310-9956-ffa450edef68
Patrick D. Hunt 13 years ago
parent
commit
4021bdec60
2 changed files with 15 additions and 10 deletions
  1. 3 0
      CHANGES.txt
  2. 12 10
      src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java

+ 3 - 0
CHANGES.txt

@@ -86,6 +86,9 @@ IMPROVEMENTS:
   ZOOKEEPER-1200. Remove obsolete DataTreeBuilder
   (Thomas Koch via phunt)
 
+  ZOOKEEPER-1247. dead code in PrepRequestProcessor.pRequest multi case
+  (Thomas Koch via phunt)
+
 Release 3.4.0 - 
 
 Non-backward compatible changes:

+ 12 - 10
src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java

@@ -500,27 +500,29 @@ public class PrepRequestProcessor extends Thread implements RequestProcessor {
                 Map<String, ChangeRecord> pendingChanges = getPendingChanges(multiRequest);
 
                 for(Op op: multiRequest) {
-                    Record subrequest = op.toRequestRecord() ;
+                    Record subrequest = op.toRequestRecord();
+                    int type;
+                    Record txn;
 
                     /* If we've already failed one of the ops, don't bother
                      * trying the rest as we know it's going to fail and it
                      * would be confusing in the logfiles.
                      */
                     if (ke != null) {
-                        request.getHdr().setType(OpCode.error);
-                        request.setTxn(new ErrorTxn(Code.RUNTIMEINCONSISTENCY.intValue()));
+                        type = OpCode.error;
+                        txn = new ErrorTxn(Code.RUNTIMEINCONSISTENCY.intValue());
                     }
 
                     /* Prep the request and convert to a Txn */
                     else {
                         try {
                             pRequest2Txn(op.getType(), zxid, request, subrequest);
+                            type = request.getHdr().getType();
+                            txn = request.getTxn();
                         } catch (KeeperException e) {
-                            if (ke == null) {
-                                ke = e;
-                            }
-                            request.getHdr().setType(OpCode.error);
-                            request.setTxn(new ErrorTxn(e.code().intValue()));
+                            ke = e;
+                            type = OpCode.error;
+                            txn = new ErrorTxn(e.code().intValue());
                             LOG.error(">>>> Got user-level KeeperException when processing "
                                     + request.toString()
                                     + " Error Path:" + e.getPath()
@@ -538,10 +540,10 @@ public class PrepRequestProcessor extends Thread implements RequestProcessor {
                     //       not sure how else to get the txn stored into our list.
                     ByteArrayOutputStream baos = new ByteArrayOutputStream();
                     BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
-                    request.getTxn().serialize(boa, "request") ;
+                    txn.serialize(boa, "request") ;
                     ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
 
-                    txns.add(new Txn(request.getHdr().getType(), bb.array()));
+                    txns.add(new Txn(type, bb.array()));
                 }
 
                 request.setHdr(new TxnHeader(request.sessionId, request.cxid, zxid, zks.getTime(), request.type));