8160359: Improve jlink logging for cases when a plugin throws exception
Reviewed-by: jlaskey, redestad
This commit is contained in:
parent
2034cb4c6e
commit
e6e9bbfcdb
@ -268,7 +268,15 @@ public final class ImagePluginStack {
|
|||||||
resources.getStringTable());
|
resources.getStringTable());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resPool = p.transform(resPool, resMgr.resourcePoolBuilder());
|
try {
|
||||||
|
resPool = p.transform(resPool, resMgr.resourcePoolBuilder());
|
||||||
|
} catch (PluginException pe) {
|
||||||
|
if (JlinkTask.DEBUG) {
|
||||||
|
System.err.println("Plugin " + p.getName() + " threw exception during transform");
|
||||||
|
pe.printStackTrace();
|
||||||
|
}
|
||||||
|
throw pe;
|
||||||
|
}
|
||||||
if (resPool.isEmpty()) {
|
if (resPool.isEmpty()) {
|
||||||
throw new Exception("Invalid resource pool for plugin " + p);
|
throw new Exception("Invalid resource pool for plugin " + p);
|
||||||
}
|
}
|
||||||
@ -444,6 +452,7 @@ public final class ImagePluginStack {
|
|||||||
res = res.copyWithContent(bytes);
|
res = res.copyWithContent(bytes);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
if (JlinkTask.DEBUG) {
|
if (JlinkTask.DEBUG) {
|
||||||
|
System.err.println("IOException while reading resource: " + res.path());
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
throw new PluginException(ex);
|
throw new PluginException(ex);
|
||||||
|
@ -298,7 +298,15 @@ public final class Jlink {
|
|||||||
List<Plugin> bootPlugins = PluginRepository.getPlugins(Layer.boot());
|
List<Plugin> bootPlugins = PluginRepository.getPlugins(Layer.boot());
|
||||||
for (Plugin bp : bootPlugins) {
|
for (Plugin bp : bootPlugins) {
|
||||||
if (Utils.isAutoEnabled(bp)) {
|
if (Utils.isAutoEnabled(bp)) {
|
||||||
bp.configure(Collections.emptyMap());
|
try {
|
||||||
|
bp.configure(Collections.emptyMap());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
if (JlinkTask.DEBUG) {
|
||||||
|
System.err.println("Plugin " + bp.getName() + " threw exception with config: {}");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
plugins.add(bp);
|
plugins.add(bp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,15 @@ public final class PluginRepository {
|
|||||||
Objects.requireNonNull(pluginsLayer);
|
Objects.requireNonNull(pluginsLayer);
|
||||||
Plugin plugin = getPlugin(name, pluginsLayer);
|
Plugin plugin = getPlugin(name, pluginsLayer);
|
||||||
if (plugin != null) {
|
if (plugin != null) {
|
||||||
plugin.configure(config);
|
try {
|
||||||
|
plugin.configure(config);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
if (JlinkTask.DEBUG) {
|
||||||
|
System.err.println("Plugin " + plugin.getName() + " threw exception with config: " + config);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,15 @@ public final class TaskHelper {
|
|||||||
// we call configure once for each occurrence. It is upto the plugin
|
// we call configure once for each occurrence. It is upto the plugin
|
||||||
// to 'merge' and/or 'override' arguments.
|
// to 'merge' and/or 'override' arguments.
|
||||||
for (Map<String, String> map : argsMaps) {
|
for (Map<String, String> map : argsMaps) {
|
||||||
plugin.configure(Collections.unmodifiableMap(map));
|
try {
|
||||||
|
plugin.configure(Collections.unmodifiableMap(map));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
if (JlinkTask.DEBUG) {
|
||||||
|
System.err.println("Plugin " + plugin.getName() + " threw exception with config: " + map);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Utils.isDisabled(plugin)) {
|
if (!Utils.isDisabled(plugin)) {
|
||||||
|
@ -55,7 +55,7 @@ public final class ExcludeJmodSectionPlugin implements Plugin {
|
|||||||
public void configure(Map<String, String> config) {
|
public void configure(Map<String, String> config) {
|
||||||
String arg = config.get(NAME);
|
String arg = config.get(NAME);
|
||||||
if (arg.isEmpty()) {
|
if (arg.isEmpty()) {
|
||||||
throw new PluginException("Section name must be specified");
|
throw new IllegalArgumentException("Section name must be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
@ -66,7 +66,7 @@ public final class ExcludeJmodSectionPlugin implements Plugin {
|
|||||||
filters.add(Type.HEADER_FILE);
|
filters.add(Type.HEADER_FILE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new PluginException("Invalid section name: " + arg);
|
throw new IllegalArgumentException("Invalid section name: " + arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ package jdk.tools.jlink.internal.plugins;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UncheckedIOException;
|
||||||
import java.nio.file.FileSystem;
|
import java.nio.file.FileSystem;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.PathMatcher;
|
import java.nio.file.PathMatcher;
|
||||||
@ -177,7 +178,7 @@ public final class OrderResourcesPlugin implements Plugin {
|
|||||||
try {
|
try {
|
||||||
lines = Files.readAllLines(file.toPath());
|
lines = Files.readAllLines(file.toPath());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new PluginException(ex);
|
throw new UncheckedIOException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
|
@ -115,7 +115,7 @@ public final class ReleaseInfoPlugin implements Plugin {
|
|||||||
try (FileInputStream fis = new FileInputStream(operation)) {
|
try (FileInputStream fis = new FileInputStream(operation)) {
|
||||||
props.load(fis);
|
props.load(fis);
|
||||||
} catch (IOException exp) {
|
} catch (IOException exp) {
|
||||||
throw new RuntimeException(exp);
|
throw new UncheckedIOException(exp);
|
||||||
}
|
}
|
||||||
props.forEach((k, v) -> release.put(k.toString(), v.toString()));
|
props.forEach((k, v) -> release.put(k.toString(), v.toString()));
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ package jdk.tools.jlink.internal.plugins;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UncheckedIOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.PathMatcher;
|
import java.nio.file.PathMatcher;
|
||||||
@ -35,7 +36,6 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import jdk.tools.jlink.internal.Utils;
|
import jdk.tools.jlink.internal.Utils;
|
||||||
import jdk.tools.jlink.plugin.PluginException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -62,7 +62,7 @@ public class ResourceFilter implements Predicate<String> {
|
|||||||
try {
|
try {
|
||||||
lines = Files.readAllLines(file.toPath());
|
lines = Files.readAllLines(file.toPath());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new PluginException(ex);
|
throw new UncheckedIOException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.stream().forEach((line) -> {
|
lines.stream().forEach((line) -> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user