Skip to content

Enforce KeyLock API constraints and synchronize READMEs#25

Merged
pmalirz merged 4 commits intomainfrom
fix-keylock-api-constraints-6709944941719295175
Mar 11, 2026
Merged

Enforce KeyLock API constraints and synchronize READMEs#25
pmalirz merged 4 commits intomainfrom
fix-keylock-api-constraints-6709944941719295175

Conversation

@pmalirz
Copy link
Copy Markdown
Owner

@pmalirz pmalirz commented Mar 11, 2026

This submission implements strict input validation for the tryLock method inside SimpleKeyLock to guarantee safe database operations and enforce documented API constraints. The changes reject empty/null/oversized lock keys and invalid expiration times, while properly handling null references during unlock. It includes unit test coverage for these edge cases. Additionally, documentation across the main README.md, dlock-core/README.md, and dlock-api interface Javadocs has been fully updated to explicitly outline these constraints, fulfilling the requirement for a clean, secure API and aligned documentation.


PR created automatically by Jules for task 6709944941719295175 started by @pmalirz

- Added input validation for `lockKey` (non-blank, max length 1000) and `expirationSeconds` (> 0) to `SimpleKeyLock.tryLock`.
- Added null-safety check for `lockHandle` in `SimpleKeyLock.unlock`.
- Updated corresponding Javadoc in `KeyLock`.
- Added unit tests for new validation logic in `LocalKeyLockTest`.
- Synchronized main and sub-module READMEs with actual API constraints.

Co-authored-by: pmalirz <19637300+pmalirz@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Extracted the magic number `1000` for lock key length into `KeyLock.MAX_LOCK_KEY_LENGTH`.
- Updated `SimpleKeyLock` input validation to use the new constant.
- Updated `LocalKeyLockTest` to dynamically generate strings exceeding the maximum length using the constant instead of a hardcoded value.

Co-authored-by: pmalirz <19637300+pmalirz@users.noreply.github.com>
google-labs-jules bot and others added 2 commits March 11, 2026 15:29
- Added missing Javadoc explaining that the length limit ensures compatibility with the underlying database schema.

Co-authored-by: pmalirz <19637300+pmalirz@users.noreply.github.com>
- Replaced the hardcoded '1000' character limit in the `KeyLock` Javadoc with `{@value #MAX_LOCK_KEY_LENGTH}`.
- Replaced the hardcoded '1000' string with references to `KeyLock.MAX_LOCK_KEY_LENGTH` in the main `README.md`, `dlock-core/README.md`, and `dlock-api/README.md`.

Co-authored-by: pmalirz <19637300+pmalirz@users.noreply.github.com>
@pmalirz pmalirz self-assigned this Mar 11, 2026
@pmalirz pmalirz merged commit 6d1a9ee into main Mar 11, 2026
2 checks passed
@pmalirz pmalirz deleted the fix-keylock-api-constraints-6709944941719295175 branch March 12, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant