Skip to content

NPE in OpReadEntry #11282

Closed
Closed

Description

@littleorca

In OpReadEntry.create:

op.readPosition = cursor.ledger.startReadOperationOnLedger(readPositionRef, op); // op.cursor not assigned yet
op.cursor = cursor;

In ManagedLedgerImpl.startReadOperationOnLedger:

if (null == ledgerId) {
opReadEntry.readEntriesFailed(new ManagedLedgerException.NoMoreEntriesToReadException("The ceilingKey(K key) method is used to return the " +
"least key greater than or equal to the given key, or null if there is no such key"), null);
}

Back to OpReadEntry.readEntriesFailed:

cursor.readOperationCompleted(); // NPE raised here!

Version: 2.8.0-SNAPSHOT

Activity

  1. added
    type/bug
    on Jul 12, 2021
  2. hangc0276 commented on Aug 11, 2021

    @hangc0276
    Contributor

    @littleorca I am a litter confused for the NPE in cursor.readOperationCompleted(), would you please provide the stack of the NPE?

  3. littleorca commented on Aug 12, 2021

    @littleorca
    Author

    @littleorca I am a litter confused for the NPE in cursor.readOperationCompleted(), would you please provide the stack of the NPE?

    Try this test case:

        @Test
        public void readEntryNPE() throws Exception {
            MetadataStore metadataStore = new ZKMetadataStore(ZK_CONNECTION, MetadataStoreConfig.builder().build());
            ClientConfiguration bkClientConf = new ClientConfiguration();
            bkClientConf.setMetadataServiceUri(METADATA_SERVICE_URI);
            ManagedLedgerFactoryImpl factory = new ManagedLedgerFactoryImpl(metadataStore, bkClientConf);
            ManagedLedger ml = factory.open(ML_NAME);
            ManagedCursor c = ml.openCursor(CURSOR_NAME);
            Position pos = ml.addEntry("Hello world!".getBytes(StandardCharsets.UTF_8));
            c.close();
            ml.close();
            factory.shutdown();
    
            factory = new ManagedLedgerFactoryImpl(metadataStore, bkClientConf);
            ml = factory.open(ML_NAME);
            c = ml.openCursor(CURSOR_NAME);
            c.markDelete(pos);
            ml.terminate();
            ml.close();
            factory.shutdown();
    
            factory = new ManagedLedgerFactoryImpl(metadataStore, bkClientConf);
            ml = factory.open(ML_NAME);
            c = ml.openCursor(CURSOR_NAME);
            c.seek(pos);
            c.readEntries(1);
        }
  4. hangc0276 commented on Aug 13, 2021

    @hangc0276
    Contributor

    OK, thanks for your feedback, I will deep into it. @littleorca

  5. codelipenghui commented on Mar 4, 2022

    @codelipenghui
    Contributor

    The issue had no activity for 30 days, mark with Stale label.

  6. tisonkun commented on Apr 14, 2023

    @tisonkun
    Member

    Closed by #15837.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/staletype/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions