Skip to content

Difference between record == null on successful get() vs KEY_NOT_FOUND (Error Code 2) in Aerospike Java Client #522

Description

@aditya-32

Hi i would like to understand the difference between the case when in java client we see Error code 2 for KEY NOT FOUND and when we get null record

While using the Aerospike Java client, I am observing two different behaviors:

  1. The get() call completes successfully, but the returned Record object is null.
  2. The get() call throws an AerospikeException with result code 2 (KEY_NOT_FOUND), indicating that the key digest was not found.

like for sync get call in aerospike java client
`
/**

  • Read record header and bins for specified key.
    • The policy can be used to specify timeouts.
    • @param policy generic configuration parameters, pass in null for defaults
    • @param key unique record identifier
    • @param binNames bins to retrieve
    • @return if found, return record instance. If not found, return null.
    • @throws AerospikeException if read fails
      */
      public final Record get(Policy policy, Key key, String... binNames)

`

wanted to understand when records can be null and when we would get Aerospike Exception with error code 2?

Aerospike client version: aerospike-client-jdk21:9.0.5
Aerospike Server version: 6.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions