From 27f378f2c269a99f0579bc84048cade2ebfe4338 Mon Sep 17 00:00:00 2001 From: Gary O'Neall Date: Wed, 24 Jun 2026 16:47:02 -0700 Subject: [PATCH] Fix compatibility in parse license message signature Incompatibility introduced in PR #339 Signed-off-by: Gary O'Neall --- src/main/java/org/spdx/library/LicenseInfoFactory.java | 6 ++++-- .../spdx/utility/license/LicenseExpressionParserTestV2.java | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/spdx/library/LicenseInfoFactory.java b/src/main/java/org/spdx/library/LicenseInfoFactory.java index 5d425a20..ee9ecde2 100644 --- a/src/main/java/org/spdx/library/LicenseInfoFactory.java +++ b/src/main/java/org/spdx/library/LicenseInfoFactory.java @@ -95,9 +95,10 @@ public static SpdxListedLicense getListedLicenseByIdCompatV2(String licenseId)th * @param copyManager allows for copying of any properties set which use other model stores or document URI's. If null, the default will be used. * @return an SPDXLicenseInfo created from the string. If the license expression is not parseable, a InvalidLicenseExpression is returned. * @throws DefaultStoreNotInitializedException if the default model store is not initialized + * @throws InvalidLicenseStringException no longer used, a InvalidLicenseExpression is returned on parsing errors - retained for compatibility in the method signature */ public static org.spdx.library.model.v2.license.AnyLicenseInfo parseSPDXLicenseStringCompatV2(String licenseString, @Nullable IModelStore store, - @Nullable String documentUri, @Nullable IModelCopyManager copyManager) throws DefaultStoreNotInitializedException { + @Nullable String documentUri, @Nullable IModelCopyManager copyManager) throws DefaultStoreNotInitializedException, InvalidLicenseStringException { if (Objects.isNull(store)) { store = DefaultModelStore.getDefaultModelStore(); } @@ -217,12 +218,13 @@ private static org.spdx.library.model.v2.license.AnyLicenseInfo fixSingleMemberS * @param customIdToUri Mapping of the id prefixes used in the license expression to the namespace preceding the external ID * @return an SPDXLicenseInfo created from the string. If the license expression is not parseable, a InvalidLicenseExpression is returned. * @throws DefaultStoreNotInitializedException if the default model store is not initialized + * @throws InvalidLicenseStringException no longer used, a InvalidLicenseExpression is returned on parsing errors - retained for compatibility in the method signature */ public static AnyLicenseInfo parseSPDXLicenseString(String licenseString, @Nullable IModelStore store, @Nullable String customLicensePrefix, @Nullable CreationInfo creationInfo, @Nullable IModelCopyManager copyManager, - @Nullable List customIdToUri) throws InvalidLicenseStringException, DefaultStoreNotInitializedException { + @Nullable List customIdToUri) throws InvalidLicenseStringException, DefaultStoreNotInitializedException, InvalidLicenseStringException { if (Objects.isNull(store)) { store = DefaultModelStore.getDefaultModelStore(); } diff --git a/src/test/java/org/spdx/utility/license/LicenseExpressionParserTestV2.java b/src/test/java/org/spdx/utility/license/LicenseExpressionParserTestV2.java index a825ccb9..e6611139 100644 --- a/src/test/java/org/spdx/utility/license/LicenseExpressionParserTestV2.java +++ b/src/test/java/org/spdx/utility/license/LicenseExpressionParserTestV2.java @@ -244,9 +244,9 @@ public void testRegressionSameTerms() throws InvalidSPDXAnalysisException { } public void testInvalidExceptionOnly() throws InvalidSPDXAnalysisException { - # "389-exception" is a valid license exception, - # but a license expression has to be presented with a license, - # to form a valid license expression. + // "389-exception" is a valid license exception, + // but a license expression has to be presented with a license, + // to form a valid license expression. AnyLicenseInfo result = LicenseInfoFactory.parseSPDXLicenseStringCompatV2("389-exception"); assertTrue(result instanceof InvalidLicenseExpression); assertEquals("389-exception", ((InvalidLicenseExpression)result).getLicenseExpression());