visxu opened a new issue, #23661:
URL: https://github.com/apache/pulsar/issues/23661

   ### Search before asking
   
   - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) 
and found nothing similar.
   
   
   ### Motivation
   
   We met a corner case when invoking subscription creating API. If client 
sends a empty JSON object, the backend service will create a subscription with 
earliest initialPosition.  
   Likes this, the requestBody JSON object, is deserialized to API param 
`ResetCursorData.java` instance, `ledgerId` and `entryId` are set to `0`.
   <img width="1493" alt="image" 
src="https://github.com/user-attachments/assets/ac61b195-b50c-469b-a6b9-558014791cec";>
   ```java
   public class ResetCursorData {
       protected long ledgerId;
       protected long entryId;
       protected int partitionIndex = -1;
       protected boolean isExcluded = false;
       protected int batchIndex = -1;
       protected Map<String, String> properties;
       
   }   
   ```
   In Pulsar, if client didn't set a specific value, the expected is Latest. 
But in the situation above, subscription was created with earliest position.
   
   ### Solution
   
   In the creating subscription API, the requestBody param 
ResetCursorData.java, set `ledgerId` and `entryId` to `Long.MAX_VALUE`, not 
`long` default value `0`.
   
   ### Alternatives
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [X] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to