Skip to content

feat: pre-release code consistency, docs polish, and test optimizations for v2.0.0 - #123

Merged
tomdesair merged 5 commits into
masterfrom
feature/pre-release-polish-v2
Aug 28, 2026
Merged

feat: pre-release code consistency, docs polish, and test optimizations for v2.0.0#123
tomdesair merged 5 commits into
masterfrom
feature/pre-release-polish-v2

Conversation

@tomdesair

@tomdesair tomdesair commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Summary

This PR addresses pre-release polish items identified during final review of version 2.0.0, resolves SonarCloud reliability issues, unifies the distributed lease locking architecture, and harmonizes JSON serialization across all domain objects.

1. Unified Serialization Architecture

  • Aligned UploadInfoJsonSerializer with LeaseDataJsonSerializer: Added complete suite of serializers and deserializers (String, byte[], OutputStream, File, Path, and typed/generic variants) to UploadInfoJsonSerializer.
  • Removed Redundant Utils Methods: Removed Utils.writeJson and Utils.readJson. DiskStorageService now delegates serialization directly to UploadInfoJsonSerializer.
  • NFS & Container File Lock Safety: Removed OS kernel FileLock attempts from Utils.readSerializable and Utils.writeSerializable (using standard Files.newInputStream / Files.newOutputStream), adhering to docs/DISK_BASED_LOCKING.md and preventing ENOLCK on shared network storage and unprivileged containers.

2. Distributed Lease Locking Architecture & SonarCloud Reliability Fixes

  • Extracted LeaseData DTO: Separated the serializable lease data model (LeaseData) from active lock lifecycle handles (LeaseFileUploadLock, S3UploadLock), adhering strictly to the Single Responsibility Principle.
  • Unified LeaseDataJsonSerializer: Centralized JSON serialization/deserialization across both disk-based locking (LeaseFileLockingService) and S3 distributed locking (S3LockingService), eliminating S3UploadLockJsonSerializer.
  • Constructor Simplicity: Simplified active lock handles to 1 public constructor (+ 1 test-injected executor constructor) requiring LeaseData, completely resolving partially initialized object warnings and potential NullPointerExceptions.
  • Unified Schema: Standardized lockPath and stopPath properties across disk and S3 backends, with ownership verification ensuring lockPath integrity.
  • Template Method Signature: Updated tryAcquireLock(UploadId, LeaseData) in AbstractLeaseLockingService.
  • Null Safety: Added null-safety checks in Utils.java for serializable and JSON file path operations.

3. Code Consistency & Fixes

  • Default Locking Consistency: Updated TusFileUploadService no-arg constructor to instantiate LeaseFileLockingService(idFactory, storagePath), aligning with withStoragePath(String) to ensure container- and NFS-safe locking by default.
  • Cloud Storage Metadata Flags: Overrode isJsonSerializationEnabled() to return true on both S3StorageService and AzureBlobStorageService.
  • Dual-Protocol Javadocs: Updated class Javadoc on TusFileUploadService documenting dual-protocol support for both Tus 1.0.0 and IETF Resumable Uploads for HTTP (RUFH).
  • HttpProblemDetails Delegation: Simplified HttpProblemDetails#writeTo(TusServletResponse) to directly delegate to writeTo((HttpServletResponse) response).

4. Documentation Accuracy

  • README.md: Updated Maven dependency snippet to 2.0.0, corrected protocol enum reference to ProtocolVersion.RUFH, and updated test suite class names.
  • docs/TESTING.md: Updated version to 2.0.0 and retry count to 40 retries (8.0s budget).
  • docs/S3_STORAGE.md: Synced test summary table with LeaseDataJsonSerializerTest.
  • docs/LOCKING.md: Updated the UploadLockingService snippet to reflect actual interface signatures.
  • docs/MIGRATION.md: Fixed inline comment referencing RUFH.
  • docs/RELEASE.md: Cleaned up Section 6 numbering and streamlined instructions for Sonatype Central Portal Publishing.

5. Verification

  • All 1031 unit and integration tests passed (BUILD SUCCESS).
  • Code coverage gate passed ($\ge 90%$ across all files; serializers at 100%).
  • Google Java Style formatting verified.
  • RUFH draft-12 Python conformity tests passed (51/51 tests passing 100%).

@coveralls

coveralls commented Aug 20, 2026

Copy link
Copy Markdown

Coverage Status

Coverage is 94.585%feature/pre-release-polish-v2 into master. No base build found for master.

…erializer and remove redundant Utils json/file-lock methods
… for LeaseFileLockingService

- Replace directory move-and-rollback with atomic sibling mutex (<UploadId>.mutex/) and in-place expired lock takeover
- Introduce LeaseFileMutex supporting try-with-resources, constructor-level auto-acquisition, isAcquired(), and 5s crash recovery
- Extract doesLockOwnershipMatch helper in LeaseFileUploadLock and S3UploadLock for fencing on release and renewal
- Add unit and stress tests for LeaseFileMutex and concurrent eviction contention
- Update documentation in DISK_BASED_LOCKING.md, LOCKING.md, and CHANGELOG.md
… helper

- Add Utils.createTempSiblingPath, Utils.atomicMove, and AutoCloseable Utils.TempPath
- Centralize atomic serialization with temporary file rename in LeaseDataJsonSerializer, UploadInfoJsonSerializer, and Utils.writeSerializable
- Add Utils.deletePathQuietly and replace redundant deleteIfExists try-catch blocks across all disk-based services
- Add unit tests in UtilsTest, LeaseDataJsonSerializerTest, and UploadInfoJsonSerializerTest
@tomdesair
tomdesair merged commit 8c29a92 into master Aug 28, 2026
13 checks passed
@tomdesair
tomdesair deleted the feature/pre-release-polish-v2 branch August 28, 2026 20:03
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.

2 participants