Skip to content

Commit

Permalink
COMMERCE-12878 Add null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardo-alberti authored and brianchandotcom committed Nov 22, 2023
1 parent 67a7e26 commit 3c91856
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public boolean hasCommerceChannel() throws PortalException {
(CommerceContext)_httpServletRequest.getAttribute(
CommerceWebKeys.COMMERCE_CONTEXT);

if (commerceContext == null) {
return false;
}

long commerceChannelId = commerceContext.getCommerceChannelId();

if (commerceChannelId > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,18 @@ protected boolean isSelected(CPOption cpOption, String fieldValue) {
}

private List<Facet> _getFacets() {
List<Facet> filledFacets = new ArrayList<>();

PortletSharedSearchResponse portletSharedSearchResponse =
_portletSharedSearchRequest.search(_renderRequest);

Facet facet = portletSharedSearchResponse.getFacet(
CPField.OPTION_NAMES);

if (facet == null) {
return Collections.emptyList();
}

List<Facet> filledFacets = new ArrayList<>();

FacetCollector facetCollector = facet.getFacetCollector();

ThemeDisplay themeDisplay = portletSharedSearchResponse.getThemeDisplay(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,15 @@ public void renderRequest(RenderRequest renderRequest) {
_portletSharedSearchResponse = _portletSharedSearchRequest.search(
_renderRequest);

List<Facet> filledFacets = new ArrayList<>();

Facet facet = _portletSharedSearchResponse.getFacet(
CPField.SPECIFICATION_NAMES);

if (facet == null) {
return Collections.emptyList();
}

List<Facet> filledFacets = new ArrayList<>();

FacetCollector facetCollector = facet.getFacetCollector();

PortletPreferences portletPreferences =
Expand Down

0 comments on commit 3c91856

Please sign in to comment.