diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/JarTypeFilter.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/JarTypeFilter.java index 8a282f3a06a3..a05f3f8ada88 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/JarTypeFilter.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/JarTypeFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashSet; -import java.util.Optional; import java.util.Set; import java.util.jar.JarFile; import java.util.jar.Manifest; @@ -45,13 +44,18 @@ class JarTypeFilter extends DependencyFilter { @Override protected boolean filter(Artifact artifact) { try (JarFile jarFile = new JarFile(artifact.getFile())) { - return Optional.ofNullable(jarFile.getManifest()).map(Manifest::getMainAttributes) - .map((attributes) -> attributes.getValue("Spring-Boot-Jar-Type")).map(EXCLUDED_JAR_TYPES::contains) - .orElse(Boolean.FALSE); + Manifest manifest = jarFile.getManifest(); + if (manifest != null) { + String jarType = manifest.getMainAttributes().getValue("Spring-Boot-Jar-Type"); + if (jarType != null && EXCLUDED_JAR_TYPES.contains(jarType)) { + return true; + } + } } catch (IOException ex) { - return false; + // Continue } + return false; } }