public void setNoMorePages()
    {
        PendingRead pendingRead;
        long bufferedBytes;
        synchronized (this) {
            // ignore duplicate calls
            if (noMorePages) {
                return;
            }

            noMorePages = true;

            pendingRead = this.pendingRead;
            this.pendingRead = null;
            bufferedBytes = this.bufferedBytes.get();
        }

        // there will be no more pages, so process the pending read
        if (pendingRead != null) {
            processRead(pendingRead, bufferedBytes);
        }
    }
@Test
    public void testAddAfterNoMorePages()
    {
        ClientBuffer buffer = new ClientBuffer(TASK_INSTANCE_ID, BUFFER_ID, NOOP_RELEASE_LISTENER);
        buffer.setNoMorePages();
        addPage(buffer, createPage(0));
        addPage(buffer, createPage(0));
        assertBufferInfo(buffer, 0, 0);
    }