From 4763533530441a70fee1f30f8a2c9853fe3ed29f Mon Sep 17 00:00:00 2001 From: Alex Dolski Date: Wed, 4 Oct 2017 11:45:37 -0500 Subject: [PATCH] Fix initialize() failing to set isClassInitialized = true (#159) --- .../cantaloupe/processor/KakaduProcessor.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/edu/illinois/library/cantaloupe/processor/KakaduProcessor.java b/src/main/java/edu/illinois/library/cantaloupe/processor/KakaduProcessor.java index 18a388f61..9eb2e1168 100644 --- a/src/main/java/edu/illinois/library/cantaloupe/processor/KakaduProcessor.java +++ b/src/main/java/edu/illinois/library/cantaloupe/processor/KakaduProcessor.java @@ -128,18 +128,22 @@ private static String getPath(String binaryName) { } private static synchronized void initialize() throws IOException { - // Due to a quirk of kdu_expand, this processor requires access to - // /dev/stdout. - final Path devStdout = Paths.get("/dev/stdout"); - if (Files.exists(devStdout) && Files.isWritable(devStdout)) { - // Due to another quirk of kdu_expand, we need to create a symlink - // from {temp path}/stdout.tif to /dev/stdout, to tell kdu_expand - // what format to write. - stdoutSymlink = createStdoutSymlink(); - } else { - LOGGER.error("Sorry, but " + KakaduProcessor.class.getSimpleName() + - " won't work on this platform as it requires access to " + - "/dev/stdout."); + try { + // Due to a quirk of kdu_expand, this processor requires access to + // /dev/stdout. + final Path devStdout = Paths.get("/dev/stdout"); + if (Files.exists(devStdout) && Files.isWritable(devStdout)) { + // Due to another quirk of kdu_expand, we need to create a symlink + // from {temp path}/stdout.tif to /dev/stdout, to tell kdu_expand + // what format to write. + stdoutSymlink = createStdoutSymlink(); + } else { + LOGGER.error("Sorry, but " + KakaduProcessor.class.getSimpleName() + + " won't work on this platform as it requires access to " + + "/dev/stdout."); + } + } finally { + isClassInitialized.set(true); } }