Skip to content

Commit

Permalink
Merge pull request #3082 from cwisniew/fix-3081
Browse files Browse the repository at this point in the history
fix for NPE in library.listTokenLibraries()
  • Loading branch information
Phergus authored Oct 20, 2021
2 parents 0f52c4a + 8d24e14 commit 76d4356
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/main/java/net/rptools/maptool/model/framework/LibraryToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class LibraryToken implements Library {
/** The name of the property for the license information. */
private static final String LIB_LICENSE_PROPERTY_NAME = "liblicense";

/** The name of the property for the description of the l;ibrary. */
/** The name of the property for the description of the library. */
private static final String LIB_DESCRIPTION_PROPERTY_NAME = "libdescription";

/** The name of the property for the short description of the l;ibrary. */
/** The name of the property for the short description of the library. */
private static final String LIB_SHORT_DESCRIPTION_PROPERTY_NAME = "libshortdescription";

/** The version number to return if the lin:token version is unknown. */
Expand Down Expand Up @@ -279,21 +279,21 @@ public CompletableFuture<LibraryInfo> getLibraryInfo() {
return new ThreadExecutionHelper<LibraryInfo>()
.runOnSwingThread(
() -> {
String notSet = I18N.getText("library.property.value.notSpecified");
Token library = findLibrary(id);
String authorsString = getProperty(LIB_AUTHORS_PROPERTY_NAME, notSet);
var authors =
Arrays.stream(getProperty(LIB_AUTHORS_PROPERTY_NAME, "").split(","))
.map(String::trim)
.toArray(String[]::new);
Arrays.stream(authorsString.split(",")).map(String::trim).toArray(String[]::new);
return new LibraryInfo(
library.getName(),
library.getName(),
getProperty(LIB_VERSION_PROPERTY_NAME),
getProperty(LIB_WEBSITE_PROPERTY_NAME),
getProperty(LIB_GITURL_PROPERTY_NAME),
library.getName().substring(4),
getProperty(LIB_VERSION_PROPERTY_NAME, notSet),
getProperty(LIB_WEBSITE_PROPERTY_NAME, notSet),
getProperty(LIB_GITURL_PROPERTY_NAME, notSet),
authors,
getProperty(LIB_LICENSE_PROPERTY_NAME),
getProperty(LIB_DESCRIPTION_PROPERTY_NAME),
getProperty(LIB_SHORT_DESCRIPTION_PROPERTY_NAME),
getProperty(LIB_LICENSE_PROPERTY_NAME, notSet),
getProperty(LIB_DESCRIPTION_PROPERTY_NAME, notSet),
getProperty(LIB_SHORT_DESCRIPTION_PROPERTY_NAME, notSet),
library.getAllowURIAccess());
});
}
Expand Down Expand Up @@ -428,7 +428,12 @@ private String getMacroText(String name) {
private String getProperty(String name) {
var token = findLibrary(id);

return token.getProperty(name).toString();
Object prop = token.getProperty(name);
if (prop == null) {
return null;
} else {
return prop.toString();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2586,3 +2586,4 @@ library.error.libtoken.missing = Lib:Token can no longer be found.
library.error.addOnLibraryExists = Add-On Library with namespace {0} already exists. Do you want to replace it?
library.error.addOn.notText = Can't convert asset of type {0} to text.
library.error.addOn.noConfigFile = library.josn file not found in {0}.
library.property.value.notSpecified = Not Specified

0 comments on commit 76d4356

Please sign in to comment.