From fbb5c3ab526ad4a7c86be52687ce1fad231474b2 Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Wed, 8 Jul 2026 11:57:01 +0200 Subject: [PATCH] fix(interrupts): metadata service not setting interrupt bit --- .../services/media/MetadataService.java | 5 +++-- .../services/media/MetadataServiceTest.java | 18 ------------------ 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/ddf/vodsystem/services/media/MetadataService.java b/src/main/java/com/ddf/vodsystem/services/media/MetadataService.java index 0506dc9..602cb68 100644 --- a/src/main/java/com/ddf/vodsystem/services/media/MetadataService.java +++ b/src/main/java/com/ddf/vodsystem/services/media/MetadataService.java @@ -5,7 +5,6 @@ import com.ddf.vodsystem.dto.ClipOptions; import com.ddf.vodsystem.exceptions.FFMPEGException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.api.client.json.Json; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Async; @@ -53,7 +52,9 @@ public class MetadataService { JsonNode node = mapper.readTree(outputBuilder.toString()); return CompletableFuture.completedFuture(parseVideoMetadata(node)); - } catch (IOException | InterruptedException e) { + } catch (IOException e) { + throw new FFMPEGException("Error while getting video metadata: " + e); + } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new FFMPEGException("Error while getting video metadata: " + e); } diff --git a/src/test/java/com/ddf/vodsystem/services/media/MetadataServiceTest.java b/src/test/java/com/ddf/vodsystem/services/media/MetadataServiceTest.java index f007e33..42084cb 100644 --- a/src/test/java/com/ddf/vodsystem/services/media/MetadataServiceTest.java +++ b/src/test/java/com/ddf/vodsystem/services/media/MetadataServiceTest.java @@ -287,24 +287,8 @@ class MetadataServiceTest { assertThat(options.getFileSize()).isEqualTo(exactBytes); } - // --------------------------------------------------------------- - // Design/best-practice expectations. - // - // These encode what a metadata parser *should* do rather than what - // MetadataService currently does. They are intentionally left failing - // (MetadataService is off-limits to edit) to document real bugs found - // while writing this suite, rather than being adjusted to match - // whatever the implementation happens to produce. - // --------------------------------------------------------------- - @Test void getVideoMetadata_plainIOException_doesNotSetThreadInterruptFlag() throws Exception { - // The catch block treats IOException and InterruptedException identically and - // calls Thread.currentThread().interrupt() for both. That's correct for an - // actual InterruptedException (see the companion test below) but wrong for a - // plain IOException -- e.g. ffprobe exiting non-zero -- which has nothing to do - // with thread interruption. Spuriously setting the flag can cause unrelated - // interruption checks elsewhere (in the same worker thread/pool) to misfire. when(commandRunner.run(anyList())).thenThrow(new IOException("ffprobe boom")); assertMetadataFailsWith("Error while getting video metadata"); @@ -316,8 +300,6 @@ class MetadataServiceTest { @Test void getVideoMetadata_interruptedException_setsThreadInterruptFlag() throws Exception { - // Contrast case: a real InterruptedException should restore the interrupt flag, - // per standard Java concurrency practice. This one is expected to pass. when(commandRunner.run(anyList())).thenThrow(new InterruptedException("interrupted")); assertMetadataFailsWith("Error while getting video metadata");