You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2021/05/06 09:04:05 UTC
[karaf] branch main updated: [KARAF-6964] Prevent NPE if MANIFEST
doesn't exist in Main
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/main by this push:
new 9469794 [KARAF-6964] Prevent NPE if MANIFEST doesn't exist in Main
new 668a655 Merge pull request #1365 from jbonofre/KARAF-6964
9469794 is described below
commit 94697949b9fad9a598bb762b9ecd7fcdebb6f34a
Author: jbonofre <jb...@apache.org>
AuthorDate: Wed May 5 16:35:07 2021 +0200
[KARAF-6964] Prevent NPE if MANIFEST doesn't exist in Main
---
.../apache/karaf/shell/impl/console/standalone/Main.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/standalone/Main.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/standalone/Main.java
index ead34fb..8ad5f1d 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/standalone/Main.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/standalone/Main.java
@@ -154,14 +154,16 @@ public class Main {
for (URL url : urls) {
try (JarFile jarFile = new JarFile(url.toURI().getPath())) {
Manifest manifest = jarFile.getManifest();
- String embeddedArtifacts = manifest.getMainAttributes().getValue(JarInJarConstants.REDIRECTED_CLASS_PATH_MANIFEST_NAME);
- if (embeddedArtifacts != null) {
- String[] artifacts = embeddedArtifacts.split( "," );
- for ( String artifact : artifacts ) {
- if (!artifact.endsWith(JarInJarConstants.JAR_EXTENSION )) {
- continue;
+ if (manifest != null) {
+ String embeddedArtifacts = manifest.getMainAttributes().getValue(JarInJarConstants.REDIRECTED_CLASS_PATH_MANIFEST_NAME);
+ if (embeddedArtifacts != null) {
+ String[] artifacts = embeddedArtifacts.split(",");
+ for (String artifact : artifacts) {
+ if (!artifact.endsWith(JarInJarConstants.JAR_EXTENSION)) {
+ continue;
+ }
+ result.add(new URL(JarInJarConstants.JAR_INTERNAL_URL_PROTOCOL_WITH_COLON + artifact + JarInJarConstants.JAR_INTERNAL_SEPARATOR));
}
- result.add(new URL(JarInJarConstants.JAR_INTERNAL_URL_PROTOCOL_WITH_COLON + artifact + JarInJarConstants.JAR_INTERNAL_SEPARATOR));
}
}
}