Github user hanm commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/99#discussion_r90762715
  
    --- Diff: src/java/main/org/apache/zookeeper/server/NettyServerCnxn.java ---
    @@ -165,31 +163,35 @@ public void process(WatchedEvent event) {
         @Override
         public void sendResponse(ReplyHeader h, Record r, String tag)
                 throws IOException {
    -        if (!channel.isOpen()) {
    -            return;
    -        }
    -        ByteArrayOutputStream baos = new ByteArrayOutputStream();
    -        // Make space for length
    -        BinaryOutputArchive bos = BinaryOutputArchive.getArchive(baos);
             try {
    -            baos.write(fourBytes);
    -            bos.writeRecord(h, "header");
    -            if (r != null) {
    -                bos.writeRecord(r, tag);
    +            if (!channel.isOpen()) {
    +                return;
                 }
    -            baos.close();
    -        } catch (IOException e) {
    -            LOG.error("Error serializing response");
    -        }
    -        byte b[] = baos.toByteArray();
    -        ByteBuffer bb = ByteBuffer.wrap(b);
    -        bb.putInt(b.length - 4).rewind();
    -        sendBuffer(bb);
    -        if (h.getXid() > 0) {
    -            // zks cannot be null otherwise we would not have gotten here!
    -            if 
(!zkServer.shouldThrottle(outstandingCount.decrementAndGet())) {
    -                enableRecv();
    +            ByteArrayOutputStream baos = new ByteArrayOutputStream();
    +            // Make space for length
    +            BinaryOutputArchive bos = BinaryOutputArchive.getArchive(baos);
    +            try {
    +                baos.write(fourBytes);
    +                bos.writeRecord(h, "header");
    +                if (r != null) {
    +                    bos.writeRecord(r, tag);
    +                }
    +                baos.close();
    +            } catch (IOException e) {
    --- End diff --
    
    Agree on re-throw the exception here. We could just remove the try - catch 
block here given there is a new try - catch block added in this PR that wraps 
the entire `sendResponse.` 
    We can start triaging other places where the exceptions are swallowed but 
should re-throw after this PR merging in.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to