Buggy code:
} } else { RProductLandingVariation1 . log . debug ( "<li>Primary<seq2seq4repair_space>CTA<seq2seq4repair_space>Links<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space><//li>" ) ; } } else if ( ! ( ctaOvtLinkElements . isEmpty ( ) ) ) { Element ctaOvtLinkElement = ctaOvtLinkElements . last ( ) ; if ( ctaOvtLinkElement != null ) { Element anchorOvtElement = ctaOvtLinkElement . getElementsByTag ( "a" ) . last ( ) ; if ( anchorOvtElement != null ) { primaryCTALinkText = anchorOvtElement . text ( ) ; primaryCTALinkUrl = anchorOvtElement . absUrl ( "href" ) ; if ( StringUtil . isBlank ( primaryCTALinkUrl ) ) { primaryCTALinkUrl = anchorOvtElement . attr ( "href" ) ; } RProductLandingVariation1 . log . debug ( ( ( "primaryCTALinkUrl" + primaryCTALinkText ) + "\n" ) ) ; RProductLandingVariation1 . log . debug ( ( ( "Before<seq2seq4repair_space>primaryCTALinkUrl" + primaryCTALinkUrl ) + "\n" ) ) ; primaryCTALinkUrl = FrameworkUtils . getLocaleReference ( primaryCTALinkUrl , urlMap , locale , sb ) ; RProductLandingVariation1 . log . debug ( ( ( "after<seq2seq4repair_space>primaryCTALinkUrl" + primaryCTALinkUrl ) + "\n" ) ) ; } else { RProductLandingVariation1 . log . debug ( "<li>Primary<seq2seq4repair_space>CTA<seq2seq4repair_space>Link<seq2seq4repair_space>anchor<seq2seq4repair_space>tag<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space><//li>" ) ; } } else { RProductLandingVariation1 . log . debug ( "<li>Primary<seq2seq4repair_space>CTA<seq2seq4repair_space>Link<seq2seq4repair_space>anchor<seq2seq4repair_space>tag<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space><//li>" ) ; } } else { RProductLandingVariation1 . log . debug ( "<li>Primary<seq2seq4repair_space>CTA<seq2seq4repair_space>Links<seq2seq4repair_space>section<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space><//li>" ) ; } RProductLandingVariation1 . log . debug ( ( ( "primaryCTATitle" + primaryCTATitle ) + "\n" ) ) ; RProductLandingVariation1 . log . debug ( ( ( "primaryCTADescription" + primaryCTADescription ) + "\n" ) ) ; RProductLandingVariation1 . log . debug ( ( ( "primaryCTALinkText" + primaryCTALinkText ) + "\n" ) ) ; RProductLandingVariation1 . log . debug ( ( ( "primaryCTALinkUrl" + primaryCTALinkUrl ) + "\n" ) ) ; if ( indexUpperLeftNode . hasNode ( "hero_tile" ) ) { Node primartCTANode = indexUpperLeftNode . getNode ( "hero_tile" ) ; if ( StringUtils . isNotBlank ( primaryCTATitle ) ) { primartCTANode . setProperty ( "title" , primaryCTATitle ) ; } else { sb . append ( PRIMARY_CTA_TITLE_NOT_FOUND ) ; RProductLandingVariation1 . log . debug ( ( "title<seq2seq4repair_space>property<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>set<seq2seq4repair_space>at<seq2seq4repair_space>" + ( primartCTANode . getPath ( ) ) ) ) ; } if ( StringUtils . isNotBlank ( primaryCTADescription ) ) { primartCTANode . setProperty ( "description" , primaryCTADescription ) ; } else { sb . append ( PRIMARY_CTA_DESCRIPTION_NOT_FOUND ) ; RProductLandingVariation1 . log . debug ( ( "description<seq2seq4repair_space>property<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>set<seq2seq4repair_space>at<seq2seq4repair_space>" + ( primartCTANode . getPath ( ) ) ) ) ; } if ( StringUtils . isNotBlank ( primaryCTALinkText ) ) { primartCTANode . setProperty ( "linktext" , primaryCTALinkText ) ; } else { sb . append ( PRIMARY_CTA_LINKTEXT_NOT_FOUND ) ; RProductLandingVariation1 . log . debug ( ( "linktext<seq2seq4repair_space>property<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>set<seq2seq4repair_space>at<seq2seq4repair_space>" + ( primartCTANode . getPath ( ) ) ) ) ; } if ( primartCTANode . hasNode ( "cta" ) ) { Node primartCTALinkUrlNode = primartCTANode . getNode ( "cta" ) ; if ( StringUtils . isNotBlank ( primaryCTALinkUrl ) ) { primartCTALinkUrlNode . setProperty ( "url" , primaryCTALinkUrl ) ; } else { sb . append ( PRIMARY_CTA_LINKURL_NOT_FOUND ) ; RProductLandingVariation1 . log . debug ( ( "url<seq2seq4repair_space>property<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>set<seq2seq4repair_space>at<seq2seq4repair_space>" + ( primartCTALinkUrlNode . getPath ( ) ) ) ) ; } } else { RProductLandingVariation1 . log . debug ( "<li>primary_cta_v2<seq2seq4repair_space>node<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>having<seq2seq4repair_space>linkurl<seq2seq4repair_space>node<//li>" ) ; } } else { RProductLandingVariation1 . log . debug ( "<li>primary_cta_v2<seq2seq4repair_space>node<seq2seq4repair_space>doesn't<seq2seq4repair_space>exists<//li>" ) ; } } else { RProductLandingVariation1 . log . debug ( "<li>CTA<seq2seq4repair_space>element<seq2seq4repair_space>not<seq2seq4repair_space>found.<//li>" ) ; } } else { sb . append ( PRIMARY_CTA_COMPONENT_INWEB_NOT_FOUND ) ; } } catch ( Exception e ) { RProductLandingVariation1 . log . debug ( ( ( "<li>Unable<seq2seq4repair_space>to<seq2seq4repair_space>update<seq2seq4repair_space>primary_cta_v2<seq2seq4repair_space>component." + e ) + "<//li>" ) ) ; } try { Node heroLargeNode = null ; NodeIterator heroPanelIterator = null ; if ( indexUpperRightNode . hasNode ( "carouselContents" ) ) { heroLargeNode = indexUpperRightNode . getNode ( "carouselContents" ) ; if ( heroLargeNode . hasNodes ( ) ) { heroPanelIterator = heroLargeNode . getNodes ( "hero_panel*" ) ; } } else { RProductLandingVariation1 . log . debug ( ( ( "<li>Node<seq2seq4repair_space>with<seq2seq4repair_space>name<seq2seq4repair_space>'carouselContents'<seq2seq4repair_space>doesn't<seq2seq4repair_space>exist<seq2seq4repair_space>under<seq2seq4repair_space>" + ( indexUpperRightNode . getPath ( ) ) ) + "<//li>" ) ) ; } Elements heroLargeElements = doc . select ( "div.c50-pilot" ) ; <START_BUG> if ( heroLargeElements != null ) { <END_BUG> Element heroLargeElement = heroLargeElements . first ( ) ; if ( heroLargeElement != null ) { Elements heroLargeFrameElements = heroLargeElement . select ( "div.frame" ) ; Node heroPanelNode = null ; if ( heroLargeFrameElements != null ) { if ( ( heroLargeFrameElements . size ( ) ) != ( heroLargeNode . getNodes ( "hero_panel*" ) . getSize ( ) ) ) { sb . append ( MISMATCH_IN_HERO_SLIDES ) ; } for ( Element ele : heroLargeFrameElements ) { String heroPanelTitle = "" ; String heroPanelDescription = "" ; String heroPanelLinkText = "" ; String heroPanellinkUrl = "" ; Elements heroTitleElements = ele . getElementsByTag ( "h2" ) ; if ( heroTitleElements != null ) { Element heroTitleElement = heroTitleElements . first ( ) ; if ( heroTitleElement != null ) { heroPanelTitle = heroTitleElement . text ( ) ; } else { RProductLandingVariation1 . log . debug ( "<li>Hero<seq2seq4repair_space>Panel<seq2seq4repair_space>element<seq2seq4repair_space>not<seq2seq4repair_space>having<seq2seq4repair_space>any<seq2seq4repair_space>title<seq2seq4repair_space>in<seq2seq4repair_space>it<seq2seq4repair_space><//li>" ) ; } } else { RProductLandingVariation1 . log . debug ( "<li>Hero<seq2seq4repair_space>Panel<seq2seq4repair_space>title<seq2seq4repair_space>element<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>found<//li>" ) ; } Elements heroDescriptionElements = ele . getElementsByTag ( "p" ) ; if ( heroDescriptionElements != null ) { Element heroDescriptionElement = heroDescriptionElements . first ( ) ; if ( heroDescriptionElement != null ) { heroPanelDescription = heroDescriptionElement . text ( ) ; } else { RProductLandingVariation1 . log . debug ( "<li>Hero<seq2seq4repair_space>Panel<seq2seq4repair_space>element<seq2seq4repair_space>not<seq2seq4repair_space>having<seq2seq4repair_space>any<seq2seq4repair_space>description<seq2seq4repair_space>in<seq2seq4repair_space>it<seq2seq4repair_space><//li>" ) ; } } else { RProductLandingVariation1 . log . debug ( "<li>Hero<seq2seq4repair_space>Panel<seq2seq4repair_space>para<seq2seq4repair_space>element<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space><//li>" ) ; } Elements heroPanelLinkTextElements = ele . getElementsByTag ( "b" ) ; if ( heroPanelLinkTextElements != null ) { Element heroPanelLinkTextElement = heroPanelLinkTextElements . first ( ) ; if ( heroPanelLinkTextElement != null ) { heroPanelLinkText = heroPanelLinkTextElement . text ( ) ; } else { RProductLandingVariation1 . log . debug ( "<li>Hero<seq2seq4repair_space>Panel<seq2seq4repair_space>element<seq2seq4repair_space>not<seq2seq4repair_space>having<seq2seq4repair_space>any<seq2seq4repair_space>linktext<seq2seq4repair_space>in<seq2seq4repair_space>it<seq2seq4repair_space><//li>" ) ; } } else { RProductLandingVariation1 . log . debug ( "<li>Hero<seq2seq4repair_space>Panel<seq2seq4repair_space>linktext<seq2seq4repair_space>element<seq2seq4repair_space>not<seq2seq4repair_space>found<seq2seq4repair_space><//li>" ) ; } Elements heroPanelLinkUrlElements = ele . getElementsByTag ( "a" ) ;

Fix:
if ( ! ( heroLargeElements . isEmpty ( ) ) ) {