From 0e16b404fa607e7431d27f45347095eb1107b071 Mon Sep 17 00:00:00 2001 From: Jochen Berger Date: Wed, 27 May 2026 07:42:21 +0200 Subject: [PATCH] Fix NoSuchElementException if package is not exported --- solstice/CHANGELOG.md | 2 ++ .../src/main/java/dev/equo/solstice/Solstice.java | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/solstice/CHANGELOG.md b/solstice/CHANGELOG.md index 63f854e7..b8c215aa 100644 --- a/solstice/CHANGELOG.md +++ b/solstice/CHANGELOG.md @@ -3,6 +3,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format. ## [Unreleased] +### Fixed +- Fix NoSuchElementException if package is not exported ## [1.8.1] - 2025-01-14 ### Fixed diff --git a/solstice/src/main/java/dev/equo/solstice/Solstice.java b/solstice/src/main/java/dev/equo/solstice/Solstice.java index 71591143..73ec32be 100644 --- a/solstice/src/main/java/dev/equo/solstice/Solstice.java +++ b/solstice/src/main/java/dev/equo/solstice/Solstice.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023 EquoTech, Inc. and others. + * Copyright (c) 2023-2026 EquoTech, Inc. and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -293,11 +293,13 @@ private boolean pkgExportIsNotDuplicate( if (thisManifest.totalPkgImports().contains(pkg)) { return true; } - var element = - thisManifest.pkgExportsRaw().stream() - .filter(e -> e.getValue().equals(pkg)) - .findFirst() - .get(); + var elementOpt = + thisManifest.pkgExportsRaw().stream().filter(e -> e.getValue().equals(pkg)).findFirst(); + if (elementOpt.isEmpty()) { + return false; + } + var element = elementOpt.get(); + String mandatory = element.getDirective("mandatory"); if (mandatory != null) { if ("split".equals(element.getAttribute(mandatory))) {