@@ -68,6 +68,7 @@ private ApiClient getPcaClient() {
6868 // To determine this, DXA first tries the regular Page and if it doesn't exist, it appends /index.html and tries again.
6969 // TODO: The above should be handled by GraphQL (See CRQ-11703)
7070 public <T > T loadPage (Class <T > type , PageRequestDto pageRequest , ContentType contentType ) throws ContentProviderException {
71+ T result = null ;
7172 try {
7273 JsonNode pageNode = getPcaClient ().getPageModelData (
7374 GraphQLUtils .convertUriToGraphQLContentNamespace (pageRequest .getUriType ()),
@@ -79,7 +80,7 @@ public <T> T loadPage(Class<T> type, PageRequestDto pageRequest, ContentType con
7980 ContentIncludeMode .INCLUDE_DATA_AND_RENDER ,
8081 null
8182 );
82- T result = mapToType (type , pageNode );
83+ result = mapToType (type , pageNode );
8384 // result may be 'null' starting from Jackson 2.18.3, so checking for this condition
8485 if (result == null ) {
8586 String pathToDefaults = normalizePathToDefaults (pageRequest .getPath (), true );
@@ -95,10 +96,6 @@ public <T> T loadPage(Class<T> type, PageRequestDto pageRequest, ContentType con
9596 null );
9697 result = mapToType (type , pageNode );
9798 }
98- if (log .isTraceEnabled ()) {
99- log .trace ("Loaded '{}' for pageRequest '{}'" , result , pageRequest );
100- }
101- return result ;
10299 }
103100 catch (IOException e ) {
104101 // Keeping this for users who may override the Jackson version and utilize a version prior to 2.18.3
@@ -115,11 +112,7 @@ public <T> T loadPage(Class<T> type, PageRequestDto pageRequest, ContentType con
115112 PageInclusion .valueOf (pageRequest .getIncludePages ().toString ()),
116113 ContentIncludeMode .INCLUDE_DATA_AND_RENDER ,
117114 null );
118- T result = mapToType (type , node );
119- if (log .isTraceEnabled ()) {
120- log .trace ("Loaded '{}' for pageRequest '{}'" , result , pageRequest );
121- }
122- return result ;
115+ result = mapToType (type , node );
123116 }
124117 catch (IOException ex ) {
125118 if (log .isTraceEnabled ()) {
@@ -128,6 +121,13 @@ public <T> T loadPage(Class<T> type, PageRequestDto pageRequest, ContentType con
128121 throw new PageNotFoundException ("Unable to load page, by request " + pageRequest , ex );
129122 }
130123 }
124+ if (log .isTraceEnabled ()) {
125+ log .trace ("Loaded '{}' for pageRequest '{}'" , result , pageRequest );
126+ }
127+ if (result == null ) {
128+ throw new PageNotFoundException ("Unable to load page (retrieved 'null'), by request " + pageRequest );
129+ }
130+ return result ;
131131 }
132132
133133 public <T > T loadPage (Class <T > type , String namespace , int publicationId , int pageId , ContentType contentType , DataModelType modelType , PageInclusion pageInclusion , ContextData contextData ) throws ContentProviderException {
0 commit comments