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:01:58 UTC
[karaf] branch karaf-4.2.x 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 karaf-4.2.x
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/karaf-4.2.x by this push:
new bfefdbe [KARAF-6964] Prevent NPE if MANIFEST doesn't exist in Main
bfefdbe is described below
commit bfefdbe18d618689bc19313b95a8b898e057c3b9
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
(cherry picked from commit 94697949b9fad9a598bb762b9ecd7fcdebb6f34a)
---
.../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));
}
}
}