This is an automated email from the ASF dual-hosted git repository. jleroux pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/trunk by this push: new b5cad1d Improved: Fix some bugs Spotbugs reports (OFBIZ-12386) b5cad1d is described below commit b5cad1d5e19135600a63f973b04828f6f6496c43 Author: Jacques Le Roux <jacques.le.r...@les7arts.com> AuthorDate: Thu Dec 9 11:59:29 2021 +0100 Improved: Fix some bugs Spotbugs reports (OFBIZ-12386) In PricatParseExcelHtmlThread::storePricatFile try to fixes a possible null dereferencement but does not work (weird). The error is NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE In OpenApiUtil::getSchemaForEntity fixes a possible null dereferencement --- .../ofbiz/pricat/PricatParseExcelHtmlThread.java | 22 ++++++++++++---------- .../org/apache/ofbiz/ws/rs/util/OpenApiUtil.java | 4 +++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java b/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java index 20e3b73..6c5aa8c 100644 --- a/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java +++ b/pricat/src/main/java/org/apache/ofbiz/pricat/PricatParseExcelHtmlThread.java @@ -41,9 +41,6 @@ import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; -import org.apache.ofbiz.htmlreport.AbstractReportThread; -import org.apache.ofbiz.htmlreport.InterfaceReport; -import org.apache.ofbiz.pricat.sample.SamplePricatParser; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.FileUtil; import org.apache.ofbiz.base.util.UtilDateTime; @@ -56,8 +53,11 @@ import org.apache.ofbiz.entity.GenericEntityException; import org.apache.ofbiz.entity.GenericValue; import org.apache.ofbiz.entity.condition.EntityCondition; import org.apache.ofbiz.entity.condition.EntityOperator; -import org.apache.ofbiz.entity.util.EntityUtil; import org.apache.ofbiz.entity.util.EntityQuery; +import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.htmlreport.AbstractReportThread; +import org.apache.ofbiz.htmlreport.InterfaceReport; +import org.apache.ofbiz.pricat.sample.SamplePricatParser; import org.apache.ofbiz.service.LocalDispatcher; /** @@ -238,12 +238,14 @@ public class PricatParseExcelHtmlThread extends AbstractReportThread { pricatFi = fi; pricatBytes = pricatFi.get(); Path path = Paths.get(fi.getName()); - pricatFile = new File(InterfacePricatParser.TEMP_FILES_FOLDER + userLoginId + "/" + path.getFileName().toString()); - FileOutputStream fos = new FileOutputStream(pricatFile); - fos.write(pricatBytes); - fos.flush(); - fos.close(); - session.setAttribute(PRICAT_FILE, pricatFile.getAbsolutePath()); + if (path != null && path.getFileName() != null) { + pricatFile = new File(InterfacePricatParser.TEMP_FILES_FOLDER + userLoginId + "/" + path.getFileName().toString()); + FileOutputStream fos = new FileOutputStream(pricatFile); + fos.write(pricatBytes); + fos.flush(); + fos.close(); + session.setAttribute(PRICAT_FILE, pricatFile.getAbsolutePath()); + } } } return true; diff --git a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java index 9f679f6..27066aa 100644 --- a/rest-api/src/main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java +++ b/rest-api/src/main/java/org/apache/ofbiz/ws/rs/util/OpenApiUtil.java @@ -381,7 +381,9 @@ public final class OpenApiUtil { } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } - dataSchema.addProperties(fieldNm, schema.description(fieldNm)); + if (schemaClass != null) { + dataSchema.addProperties(fieldNm, schema.description(fieldNm)); + } } return dataSchema; }