Skip to content

Commit d518814

Browse files
authored
Fix getResult() when no nmk contigencies (#146)
Signed-off-by: Etienne Homer <[email protected]>
1 parent d8fe922 commit d518814

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/org/gridsuite/securityanalysis/server/service/SecurityAnalysisResultService.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,10 @@ public SecurityAnalysisStatus findStatus(UUID resultUuid) {
287287
return securityAnalysisResult.get().getStatus();
288288
}
289289

290+
private static Page<?> emptyPage(Pageable pageable) {
291+
return new PageImpl<>(List.of(), pageable, 0);
292+
}
293+
290294
@Transactional(readOnly = true)
291295
public Page<ContingencyEntity> findContingenciesPage(UUID resultUuid, List<ResourceFilterDTO> resourceFilters, Pageable pageable) {
292296
Objects.requireNonNull(resultUuid);
@@ -308,7 +312,8 @@ public Page<ContingencyEntity> findContingenciesPage(UUID resultUuid, List<Resou
308312
);
309313

310314
if (!uuidPage.hasContent()) {
311-
return Page.empty();
315+
// Since springboot 3.2, the return value of Page.empty() is not serializable. See https://github.com/spring-projects/spring-data-commons/issues/2987
316+
return (Page<ContingencyEntity>) emptyPage(pageable);
312317
} else {
313318
List<UUID> uuids = uuidPage.map(ContingencyRepository.EntityUuid::getUuid).toList();
314319
// Then we fetch the main entities data for each UUID
@@ -341,7 +346,8 @@ public Page<SubjectLimitViolationEntity> findSubjectLimitViolationsPage(UUID res
341346
);
342347

343348
if (!uuidPage.hasContent()) {
344-
return Page.empty();
349+
// Since springboot 3.2, the return value of Page.empty() is not serializable. See https://github.com/spring-projects/spring-data-commons/issues/2987
350+
return (Page<SubjectLimitViolationEntity>) emptyPage(pageable);
345351
} else {
346352
List<UUID> uuids = uuidPage.map(u -> u.getId()).toList();
347353
// Then we fetch the main entities data for each UUID

0 commit comments

Comments
 (0)