Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/spdx/library/model/SpdxModelFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public static Optional<ModelObject> getModelObject(IModelStore modelStore, Strin
try {
return Optional.of(new ExternalSpdxElement(modelStore, documentUri, id, copyManager, true));
} catch(InvalidSPDXAnalysisException ex) {
logger.warn("Attempting to get a model object for an invalid SPDX ID. Returning empty");
logger.warn("Attempting to get a model object for an invalid SPDX ID. Returning empty", ex);
return Optional.empty();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static AnyLicenseInfo parseLicenseExpression(String expression, IModelStore stor
// Add the expression to the error message to provide additional information to the user
throw new LicenseParserException(ex.getMessage()+" License expression: '"+expression+"'", ex);
} catch (EmptyStackException ex) {
throw new LicenseParserException("Invalid license expression: '"+expression+"' - check that every operator (e.g. AND and OR) has operators and that parenthesis are matched");
throw new LicenseParserException("Invalid license expression: '"+expression+"' - check that every operator (e.g. AND and OR) has operators and that parenthesis are matched", ex);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static AnyLicenseInfo parseSPDXLicenseString(String licenseString, @Nulla
} catch (LicenseParserException e) {
throw new InvalidLicenseStringException(e.getMessage(),e);
} catch (InvalidSPDXAnalysisException e) {
throw new InvalidLicenseStringException("Unexpected SPDX error parsing license string");
throw new InvalidLicenseStringException("Unexpected SPDX error parsing license string", e);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/spdx/library/model/license/ListedLicenses.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ private static Properties loadLicenseProperties() {
}
} catch (IOException e) {
// Ignore it and fall through
logger.warn("IO Exception reading listed license properties file: " + e.getMessage());
logger.warn("IO Exception reading listed license properties file: " + e.getMessage(), e);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
logger.warn("Unable to close listed license properties file: " + e.getMessage());
logger.warn("Unable to close listed license properties file: " + e.getMessage(), e);
}
}
}
Expand All @@ -108,16 +108,16 @@ private void initializeLicenseModelStore() {
try {
licenseModelStore = new SpdxListedLicenseWebStore();
} catch(InvalidSPDXAnalysisException ex) {
logger.error("Unable to access the most current listed licenses from https://spdx.org/licenses - using locally cached licenses: "+ex.getMessage());
logger.error("Unable to access the most current listed licenses from https://spdx.org/licenses - using locally cached licenses: "+ex.getMessage(), ex);
licenseModelStore = null;
}
}
if (licenseModelStore == null) {
try {
licenseModelStore = new SpdxListedLicenseLocalStore();
} catch(InvalidSPDXAnalysisException ex) {
logger.error("Error loading cached SPDX licenses");
throw new RuntimeException("Unexpected error loading SPDX Listed Licenses");
logger.error("Error loading cached SPDX licenses", ex);
throw new RuntimeException("Unexpected error loading SPDX Listed Licenses", ex);
}
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public String getLicenseTextHtml() throws InvalidLicenseTemplateException, Inval
try {
return SpdxLicenseTemplateHelper.templateTextToHtml(templateText);
} catch(LicenseTemplateRuleException ex) {
throw new InvalidLicenseTemplateException("Invalid license expression found in license text for license "+getName()+":"+ex.getMessage());
throw new InvalidLicenseTemplateException("Invalid license expression found in license text for license "+getName()+":"+ex.getMessage(), ex);
}
} else {
return SpdxLicenseTemplateHelper.formatEscapeHTML(this.getLicenseText());
Expand Down Expand Up @@ -179,7 +179,7 @@ public String getLicenseHeaderHtml() throws InvalidLicenseTemplateException, Inv
try {
return SpdxLicenseTemplateHelper.templateTextToHtml(templateText);
} catch(LicenseTemplateRuleException ex) {
throw new InvalidLicenseTemplateException("Invalid license expression found in standard license header for license "+getName()+":"+ex.getMessage());
throw new InvalidLicenseTemplateException("Invalid license expression found in standard license header for license "+getName()+":"+ex.getMessage(), ex);
}
} else {
return SpdxLicenseTemplateHelper.formatEscapeHTML(this.getStandardLicenseHeader());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private ListedReferenceTypes() {
}
} catch (IOException e) {
logger.warn("IO Exception reading listed reference type properties file: "
+ e.getMessage() + ", loading properties from class properties file.");
+ e.getMessage() + ", loading properties from class properties file.", e);
}
if (Objects.isNull(in)) {
try {
Expand All @@ -77,15 +77,15 @@ private ListedReferenceTypes() {
logger.error("Unable to load listed reference type properties");
}
} catch (IOException ex2) {
logger.error("IO exception reading listed reference type properties from class properties file: "+ex2.getMessage());
logger.error("IO exception reading listed reference type properties from class properties file: "+ex2.getMessage(), ex2);
}
}
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
logger.warn("Unable to close listed license properties file: " + e.getMessage());
logger.warn("Unable to close listed license properties file: " + e.getMessage(), e);
}
}
}
Expand Down Expand Up @@ -165,7 +165,7 @@ public URI getListedReferenceUri(String listedReferenceName) throws InvalidSPDXA
retval = new URI(SpdxConstants.SPDX_LISTED_REFERENCE_TYPES_PREFIX + listedReferenceName);
} catch (URISyntaxException e) {
logger.error("Error forming listed license URI",e);
throw new InvalidSPDXAnalysisException(listedReferenceName + " is not a valid SPDX listed reference type syntax.");
throw new InvalidSPDXAnalysisException(listedReferenceName + " is not a valid SPDX listed reference type syntax.",e);
}
if (!isListedReferenceType(retval)) {
throw new InvalidSPDXAnalysisException(listedReferenceName + " is not a valid SPDX listed reference type.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ private void loadIds() throws InvalidSPDXAnalysisException {
ExceptionJsonTOC exceptionToc = gson.fromJson(tocJsonStr.toString(), ExceptionJsonTOC.class);
exceptionIds = exceptionToc.getExceptionIds();
} catch (MalformedURLException e) {
throw new SpdxListedLicenseException("License TOC URL invalid") ;
throw new SpdxListedLicenseException("License TOC URL invalid", e) ;
} catch (IOException e) {
throw new SpdxListedLicenseException("I/O error reading license TOC");
throw new SpdxListedLicenseException("I/O error reading license TOC", e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
logger.warn("Unable to close JSON TOC reader");
logger.warn("Unable to close JSON TOC reader", e);
}
}
}
Expand Down Expand Up @@ -326,23 +326,23 @@ private LicenseJson fetchLicenseJson(String idCaseInsensitive) throws InvalidSPD
LicenseJson license = gson.fromJson(licenseJsonStr.toString(), LicenseJson.class);
this.listedLicenseCache.put(id, license);
} catch (MalformedURLException e) {
logger.error("Json license invalid for ID "+id);
throw new SpdxListedLicenseException("JSON license URL invalid for ID "+id);
logger.error("Json license invalid for ID "+id, e);
throw new SpdxListedLicenseException("JSON license URL invalid for ID "+id, e);
} catch (IOException e) {
logger.error("I/O error opening Json license URL");
throw new SpdxListedLicenseException("I/O Error reading license data for ID "+id);
logger.error("I/O error opening Json license URL", e);
throw new SpdxListedLicenseException("I/O Error reading license data for ID "+id, e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
logger.warn("Unable to close JSON TOC reader");
logger.warn("Unable to close JSON TOC reader", e);
}
} else if (jsonStream != null) {
try {
jsonStream.close();
} catch (IOException e) {
logger.warn("Unable to close JSON TOC input stream");
logger.warn("Unable to close JSON TOC input stream", e);
}
}
}
Expand Down Expand Up @@ -398,22 +398,22 @@ private ExceptionJson fetchExceptionJson(String idCaseInsensitive) throws Invali
this.listedExceptionCache.put(id, exc);
} catch (MalformedURLException e) {
logger.error("Json license invalid for ID "+id);
throw new SpdxListedLicenseException("JSON license URL invalid for ID "+id);
throw new SpdxListedLicenseException("JSON license URL invalid for ID "+id, e);
} catch (IOException e) {
logger.error("I/O error opening Json license URL");
throw new SpdxListedLicenseException("I/O Error reading license data for ID "+id);
throw new SpdxListedLicenseException("I/O Error reading license data for ID "+id, e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
logger.warn("Unable to close JSON TOC reader");
logger.warn("Unable to close JSON TOC reader", e);
}
} else if (jsonStream != null) {
try {
jsonStream.close();
} catch (IOException e) {
logger.warn("Unable to close JSON TOC input stream");
logger.warn("Unable to close JSON TOC input stream", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private InputStream getUrlInputStream(URL url) throws IOException {
try {
redirectUrl = new URL(redirectUrlStr);
} catch(Exception ex) {
throw new IOException("Invalid redirect URL");
throw new IOException("Invalid redirect URL", ex);
}
if (!redirectUrl.getProtocol().toLowerCase().startsWith("http")) {
throw new IOException("Invalid redirect protocol");
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/spdx/storage/simple/StoredTypedItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public boolean addValueToList(String propertyName, Object value) throws SpdxInva
}
return list.add(value);
} catch (Exception ex) {
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName);
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName, ex);
}
}

Expand All @@ -222,7 +222,7 @@ public boolean removeTypedValueFromList(String propertyName, TypedValue value) t
}
return list.remove(value);
} catch (Exception ex) {
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName);
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName, ex);
}
}

Expand Down Expand Up @@ -257,7 +257,7 @@ public boolean removeValueFromList(String propertyName, Object value) throws Spd
}
return list.remove(value);
} catch (Exception ex) {
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName);
throw new SpdxInvalidTypeException("Invalid list type for "+propertyName, ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,14 @@ public static String removeCommentChars(String s) {
}
return sb.toString();
} catch (IOException e) {
logger.warn("IO error reading strings?!?");
logger.warn("IO error reading strings?!?", e);
return s;
} finally {
if (Objects.nonNull(reader)) {
try {
reader.close();
} catch (IOException e) {
logger.warn("IO error closing a string reader?!?");
logger.warn("IO error closing a string reader?!?", e);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/spdx/utility/compare/SpdxComparer.java
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ private void compareDocumentContents() throws SpdxCompareException {
}
}
} catch(InvalidSPDXAnalysisException ex) {
throw new SpdxCompareException("Error getting SPDX document items: "+ex.getMessage());
throw new SpdxCompareException("Error getting SPDX document items: "+ex.getMessage(), ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void addDocumentSnippet(SpdxDocument spdxDocument,
this.differenceFound = true;
}
} catch (InvalidSPDXAnalysisException e) {
throw new SpdxCompareException("SPDX error getting byte range: "+e.getMessage());
throw new SpdxCompareException("SPDX error getting byte range: "+e.getMessage(), e);
}
try {
Optional<StartEndPointer> lineRange = snippet.getLineRange();
Expand All @@ -111,22 +111,22 @@ public void addDocumentSnippet(SpdxDocument spdxDocument,
this.differenceFound = true;
}
} catch (InvalidSPDXAnalysisException e) {
throw new SpdxCompareException("SPDX error getting line range: "+e.getMessage());
throw new SpdxCompareException("SPDX error getting line range: "+e.getMessage(), e);
}
try {
SpdxFile fromFile = snippet.getSnippetFromFile();
SpdxFile fromFile2 = snippet2.getSnippetFromFile();
compareSnippetFromFiles(spdxDocument, fromFile, document2, fromFile2);
} catch (InvalidSPDXAnalysisException e) {
throw new SpdxCompareException("SPDX error getting snippet from file: "+e.getMessage());
throw new SpdxCompareException("SPDX error getting snippet from file: "+e.getMessage(), e);
}
try {
if (!SpdxComparer.stringsEqual(snippet2.getName(), snippet.getName())) {
this.nameEquals = false;
this.differenceFound = true;
}
} catch (InvalidSPDXAnalysisException e) {
throw new SpdxCompareException("SPDX error comparing snippet names: "+e.getMessage());
throw new SpdxCompareException("SPDX error comparing snippet names: "+e.getMessage(), e);
}
}
inProgress = false;
Expand Down