Skip to content

Commit 777b986

Browse files
Throw NGPageRestorationException from the page cache
1 parent fbe3382 commit 777b986

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

ng-appserver/src/main/java/ng/appserver/NGComponentRequestHandler.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,9 @@ public NGResponse handleRequest( NGRequest request ) {
6464
}
6565

6666
// Now let's try to restore the page from the cache, using the contextID provided by the URL
67+
// If no page is found (page probably pushed out of the session's page cache), NGPageRestorationException is thrown.
6768
final NGComponent originalPage = session.pageCache().restorePageFromCache( originatingContextID );
6869

69-
// No page found in cache. If this happens, the page has probably been pushed out of the session's page cache.
70-
if( originalPage == null ) {
71-
throw new NGPageRestorationException( request, "No page found in the page cache for contextID %s. The page has probably been pushed out of the session's page cache".formatted( originatingContextID ) );
72-
}
73-
7470
// Since we're working with the page we can safely assume it's become relevant again, so we give it another shot at life by moving it to the top of the page cache
7571
session.pageCache().retainPageWithContextIDInCache( originatingContextID );
7672

ng-appserver/src/main/java/ng/appserver/NGPageCache.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,8 @@ public NGComponent restorePageFromCache( final String contextID ) {
140140

141141
final NGPageCacheEntry cacheEntry = _allEntries.get( contextID );
142142

143-
// FIXME: This might actually be the right place to throw a page restoration error // Hugi 2024-09-30
144143
if( cacheEntry == null ) {
145-
throw new IllegalStateException( "No cached page was found for contextID '%s'".formatted( contextID ) );
144+
throw new NGPageRestorationException( "No page found in the page cache for contextID '%s'. The page has probably been pushed out of the session's page cache".formatted( contextID ) );
146145
}
147146

148147
return cacheEntry.page();

ng-appserver/src/main/java/ng/appserver/NGPageRestorationException.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22

33
public class NGPageRestorationException extends RuntimeException {
44

5-
private final NGRequest _request;
6-
7-
public NGPageRestorationException( NGRequest request, String message ) {
5+
public NGPageRestorationException( String message ) {
86
super( message );
9-
_request = request;
10-
}
11-
12-
public NGRequest request() {
13-
return _request;
147
}
158
}

0 commit comments

Comments
 (0)