adobe / aem-core-cif-components

A set of configurations and components to get you started with AEM Commerce development
Apache License 2.0
102 stars 80 forks source link

CIF-2985: prevent NPE when given alternative is null #967

Closed buuhuu closed 1 year ago

buuhuu commented 1 year ago

Description

When the list of alternatives passed to the UrlFormatBase#selectUrlPath() contains a null reference a NPE is thrown. While this should not happen, it seems that it could with the BreadcrumbImpl's product query:

Caused by: java.lang.NullPointerException: null
    at com.adobe.cq.commerce.core.components.internal.services.urlformats.UrlFormatBase.selectUrlPath(UrlFormatBase.java:134) [com.adobe.commerce.cif.core-cif-components-core:2.10.0]
    at com.adobe.cq.commerce.core.components.internal.models.v1.breadcrumb.BreadcrumbImpl.fetchProductBreadcrumbs(BreadcrumbImpl.java:302) [com.adobe.commerce.cif.core-cif-components-core:2.10.0]
    at com.adobe.cq.commerce.core.components.internal.models.v1.breadcrumb.BreadcrumbImpl.populateItems(BreadcrumbImpl.java:169) [com.adobe.commerce.cif.core-cif-components-core:2.10.0]
    at com.adobe.cq.commerce.core.components.internal.models.v1.breadcrumb.BreadcrumbImpl.getItems(BreadcrumbImpl.java:119) [com.adobe.commerce.cif.core-cif-components-core:2.10.0]

Related Issue

CIF-2985

Motivation and Context

How Has This Been Tested?

Unit Tests

Screenshots (if appropriate):

Types of changes

Checklist:

codecov[bot] commented 1 year ago

Codecov Report

Merging #967 (3f13f26) into master (cd5b127) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##             master     #967   +/-   ##
=========================================
  Coverage     89.15%   89.15%           
- Complexity     2211     2212    +1     
=========================================
  Files           354      354           
  Lines          9985     9987    +2     
  Branches       1437     1438    +1     
=========================================
+ Hits           8902     8904    +2     
  Misses          787      787           
  Partials        296      296           
Flag Coverage Δ
integration 51.78% <0.00%> (-0.02%) :arrow_down:
jest 86.68% <ø> (ø)
karma 95.53% <ø> (ø)
unittests 87.43% <100.00%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ts/internal/services/urlformats/UrlFormatBase.java 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more