diff --git a/pom.xml b/pom.xml
index dbc5e622..e5ca6eac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,7 +35,7 @@
org.apache.commons
commons-lang3
- 3.20.0
+ 3.22.0
commons-io
@@ -45,19 +45,19 @@
commons-codec
commons-codec
- 1.22.1
+ 1.23.0
org.slf4j
slf4j-api
- 1.7.36
+ 2.0.20
io.minio
minio
- 9.0.3
+ 9.0.4
provided
@@ -65,31 +65,7 @@
com.azure
azure-storage-blob
- 12.35.0
- provided
-
-
- io.netty
- netty-codec
- 4.2.17.Final
- provided
-
-
- io.netty
- netty-codec-http
- 4.2.17.Final
- provided
-
-
- io.netty
- netty-codec-http2
- 4.2.17.Final
- provided
-
-
- io.netty
- netty-codec-dns
- 4.2.17.Final
+ 12.37.2
provided
@@ -97,44 +73,41 @@
com.squareup.okhttp3
okhttp
- 4.12.0
+ 4.12.1
provided
org.jetbrains.kotlin
kotlin-stdlib
- 2.3.21
+ 2.4.21
provided
-
- org.bouncycastle
- bcprov-jdk18on
- 1.85
- provided
-
-
+
+
com.fasterxml.jackson.core
jackson-databind
- 2.22.3
+ 2.23.0
com.fasterxml.jackson.core
jackson-annotations
- 2.22
+ 2.23
com.fasterxml.jackson.core
jackson-core
- 2.22.3
+ 2.23.0
org.slf4j
slf4j-simple
- 1.7.36
+ 2.0.20
test
@@ -181,7 +154,7 @@
org.jacoco
jacoco-maven-plugin
- 0.8.15
+ 0.8.16
${surefireArgLine} ${surefireJvmArgs}
@@ -281,7 +254,7 @@
org.apache.maven.plugins
maven-failsafe-plugin
- 3.2.5
+ 3.6.1
${failsafeArgLine} ${failsafeJvmArgs}
@@ -308,7 +281,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.13.0
+ 3.16.0
17
UTF-8
diff --git a/src/main/java/me/desair/tus/server/upload/azure/AzureUtils.java b/src/main/java/me/desair/tus/server/upload/azure/AzureUtils.java
index 1ebc72c9..305898b0 100644
--- a/src/main/java/me/desair/tus/server/upload/azure/AzureUtils.java
+++ b/src/main/java/me/desair/tus/server/upload/azure/AzureUtils.java
@@ -20,13 +20,6 @@ private AzureUtils() {
// Utility class
}
- /**
- * Checks whether a blob exists in Azure Blob Storage.
- *
- * @param blobClient The {@link BlobClient} to inspect
- * @return {@code true} if the blob exists; {@code false} if it does not exist, argument is null,
- * or an error occurs
- */
/**
* Calculates the cutoff timestamp before which listed blobs can be considered candidates for
* expiration, subtracting a safety margin to account for clock skew and in-flight writes.
@@ -38,10 +31,20 @@ public static OffsetDateTime calculateExpirationCutoff(Long uploadExpirationPeri
if (uploadExpirationPeriod == null || uploadExpirationPeriod <= 0) {
return null;
}
- return OffsetDateTime.now()
- .minus(Duration.ofMillis(Math.max(0L, uploadExpirationPeriod - 2000L)));
+ // Do not clamp (uploadExpirationPeriod - 2000L) at 0: when uploadExpirationPeriod is shorter
+ // than the 2000ms safety margin (e.g. 1ms in tests), the cutoff must remain in the future
+ // (now + 2000ms - uploadExpirationPeriod) so remote clocks slightly ahead of the host JVM
+ // do not cause newly expired blobs to be skipped.
+ return OffsetDateTime.now().minus(Duration.ofMillis(uploadExpirationPeriod - 2000L));
}
+ /**
+ * Checks whether a blob exists in Azure Blob Storage.
+ *
+ * @param blobClient The {@link BlobClient} to inspect
+ * @return {@code true} if the blob exists; {@code false} if it does not exist, argument is null,
+ * or an error occurs
+ */
public static boolean blobExists(BlobClient blobClient) {
if (blobClient == null) {
return false;
diff --git a/src/main/java/me/desair/tus/server/upload/s3/S3Utils.java b/src/main/java/me/desair/tus/server/upload/s3/S3Utils.java
index f33ca672..febe0748 100644
--- a/src/main/java/me/desair/tus/server/upload/s3/S3Utils.java
+++ b/src/main/java/me/desair/tus/server/upload/s3/S3Utils.java
@@ -63,8 +63,11 @@ public static ZonedDateTime calculateExpirationCutoff(Long uploadExpirationPerio
if (uploadExpirationPeriod == null || uploadExpirationPeriod <= 0) {
return null;
}
- return ZonedDateTime.now()
- .minus(Duration.ofMillis(Math.max(0L, uploadExpirationPeriod - 2000L)));
+ // Do not clamp (uploadExpirationPeriod - 2000L) at 0: when uploadExpirationPeriod is shorter
+ // than the 2000ms safety margin (e.g. 1ms in tests), the cutoff must remain in the future
+ // (now + 2000ms - uploadExpirationPeriod) so remote clocks slightly ahead of the host JVM
+ // do not cause newly expired objects to be skipped.
+ return ZonedDateTime.now().minus(Duration.ofMillis(uploadExpirationPeriod - 2000L));
}
/**
diff --git a/src/test/java/me/desair/tus/server/upload/azure/AzureUtilsTest.java b/src/test/java/me/desair/tus/server/upload/azure/AzureUtilsTest.java
index 9207b157..e1174be0 100644
--- a/src/test/java/me/desair/tus/server/upload/azure/AzureUtilsTest.java
+++ b/src/test/java/me/desair/tus/server/upload/azure/AzureUtilsTest.java
@@ -200,8 +200,10 @@ public void testCalculateExpirationCutoff() {
assertNull(AzureUtils.calculateExpirationCutoff(0L));
assertNull(AzureUtils.calculateExpirationCutoff(-100L));
+ OffsetDateTime now = OffsetDateTime.now();
OffsetDateTime shortCutoff = AzureUtils.calculateExpirationCutoff(1000L);
assertNotNull(shortCutoff);
+ assertTrue(shortCutoff.isAfter(now));
OffsetDateTime longCutoff = AzureUtils.calculateExpirationCutoff(10_000L);
assertNotNull(longCutoff);
diff --git a/src/test/java/me/desair/tus/server/upload/s3/S3UtilsTest.java b/src/test/java/me/desair/tus/server/upload/s3/S3UtilsTest.java
index 47c03089..04c02609 100644
--- a/src/test/java/me/desair/tus/server/upload/s3/S3UtilsTest.java
+++ b/src/test/java/me/desair/tus/server/upload/s3/S3UtilsTest.java
@@ -25,6 +25,7 @@
import io.minio.messages.ErrorResponse;
import io.minio.messages.Item;
import java.io.InputStream;
+import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -326,6 +327,22 @@ public void testParseErrorResponseHttp501() {
assertEquals(S3ErrorType.API_NOT_IMPLEMENTED, S3Utils.parseErrorResponse(ex));
}
+ @Test
+ public void testCalculateExpirationCutoff() {
+ assertNull(S3Utils.calculateExpirationCutoff(null));
+ assertNull(S3Utils.calculateExpirationCutoff(0L));
+ assertNull(S3Utils.calculateExpirationCutoff(-100L));
+
+ ZonedDateTime now = ZonedDateTime.now();
+ ZonedDateTime shortCutoff = S3Utils.calculateExpirationCutoff(1000L);
+ assertNotNull(shortCutoff);
+ assertTrue(shortCutoff.isAfter(now));
+
+ ZonedDateTime longCutoff = S3Utils.calculateExpirationCutoff(10_000L);
+ assertNotNull(longCutoff);
+ assertTrue(longCutoff.isBefore(ZonedDateTime.now()));
+ }
+
private ErrorResponseException createExceptionWithCode(String code) {
ErrorResponse errorResponse = mock(ErrorResponse.class);
when(errorResponse.code()).thenReturn(code);