Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Pack200 class to handle the absence of the command #5669

Merged
merged 1 commit into from
May 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions biz.aQute.repository/src/aQute/p2/packed/Unpack200.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
}

Expand Down