Repository navigation
refactor: reduce code duplication across storage, concatenation, and utility classes - #146
Merged
Merged
Conversation
…utility classes - Extract thread pool executor creation and lifecycle management (createUploadExecutor, resizeThreadPoolExecutor, shutdownExecutor) and prefix sanitization (sanitizePrefix) to Utils - Introduce AbstractUploadStorageService providing shared configuration, accessors, deduplication retrieval, executor management, and locking lifecycle handling for S3StorageService and AzureBlobStorageService - Introduce AbstractConcatenationService providing shared partial upload validation, sorting, and length calculation for VirtualConcatenationService, S3ConcatenationService, and AzureBlobConcatenationService - Centralize checksum index relative path parsing in ChecksumKey.parseFromIndexRelativePath - Streamline lock wrapping in TusFileUploadService and deduplicate handler checks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses the SonarCloud code duplication warnings across
tus-java-serverby extracting common utilities, introducing shared abstract base classes, and consolidating redundant logic across storage, concatenation, and checksum index classes.Changes
Thread Pool Lifecycle Consolidation:
Utils.createUploadExecutor,Utils.resizeThreadPoolExecutor, andUtils.shutdownExecutorinme.desair.tus.server.util.Utils.AsyncChunkUploader,AbstractUploadStorageService, and test suites.Unified Prefix Sanitization:
Utils.sanitizePrefixand removed duplicate copies inS3UtilsandAzureUtils.Utils.sanitizePrefixdirectly.Abstract Upload Storage Service (
AbstractUploadStorageService):getUploadInfo(url, ownerKey),copyUploadTo, deduplication lookups (deduplicate,getUploadInfoByChecksum), and locking service replacement cleanup intoAbstractUploadStorageService.default void copyUploadTomethod onUploadStorageService.S3StorageServiceandAzureBlobStorageServiceto extendAbstractUploadStorageService.Abstract Concatenation Service (
AbstractConcatenationService):getPartialUploads), cumulative length calculation (calculateTotalLength), and completion validation (checkAllCompleted).default Long calculateTotalLength(List<UploadInfo>)method onUploadConcatenationService.VirtualConcatenationService,S3ConcatenationService, andAzureBlobConcatenationServiceto extendAbstractConcatenationService.Checksum Key Index Parsing (
ChecksumKey):ChecksumKey.parseFromIndexRelativePath(String relativePath, String parentSuffix).S3ChecksumIndexandAzureBlobChecksumIndex.Lock Wrapping & Stream Helpers:
wrapStreamWithLockandcloseLockQuietlyinTusFileUploadService.supports(...)in download extension request handlers.Verification & Metrics
master(exceeds the 95.00% threshold).UploadInfo.serialVersionUID = -8751200491586638308Lis unchanged.mvn -P codestyle com.spotify.fmt:fmt-maven-plugin:format).