From 35c1cb4114b7603652ff0af5ef488841145dc8c4 Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Mon, 22 May 2023 10:43:00 +0200 Subject: [PATCH] Updated Pack200 class to handle the absence of the command. The command was deprecated in later VMs --- Signed-off-by: Peter Kriens Signed-off-by: Peter Kriens --- .../src/aQute/p2/packed/Unpack200.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/biz.aQute.repository/src/aQute/p2/packed/Unpack200.java b/biz.aQute.repository/src/aQute/p2/packed/Unpack200.java index 016a08f950..aedf3156df 100644 --- a/biz.aQute.repository/src/aQute/p2/packed/Unpack200.java +++ b/biz.aQute.repository/src/aQute/p2/packed/Unpack200.java @@ -32,6 +32,17 @@ public Unpack200() { private void prepare() { String commandStr = getJavaExecutable("unpack200"); + if (commandStr == null) + return; + File path = IO.getFile(commandStr); + if (!path.isFile()) + return; + + if (!path.canExecute()) { + logger.debug("Path to unpack200 exists but cannot execute {}", commandStr); + return; + } + StringBuffer sb = new StringBuffer(); Command cmd = new Command(); cmd.add(commandStr); @@ -40,13 +51,15 @@ private void prepare() { try { logger.debug("Calling: {}", cmd.toString()); result = cmd.execute(sb, sb); + if (result == 0) { + unpackCommand = commandStr; + canUnpack = true; + } else { + logger.warn("pack200 command at {} returned a non-zero state {}", sb, result); + } } catch (Exception e) { - logger.error("Error: " + sb.toString(), e); - result = -1; - } - if (result == 0) { - unpackCommand = commandStr; - canUnpack = true; + logger.warn("Cannot execute pack200 command at {} {}", sb, e.getMessage()); + return; } }