Skip to content

Commit

Permalink
116609: Add try catch to init method in ProcessServiceImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
nona-luypaert committed Jul 29, 2024
1 parent 3bad77a commit 070fe68
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions dspace-api/src/main/java/org/dspace/scripts/ProcessServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,29 @@ public class ProcessServiceImpl implements ProcessService, InitializingBean {

@Override
public void afterPropertiesSet() throws Exception {
Context context = new Context();

// Processes that were running or scheduled when tomcat crashed, should be cleaned up during startup.
List<Process> processesToBeFailed = findByStatusAndCreationTimeOlderThan(
context, List.of(ProcessStatus.RUNNING, ProcessStatus.SCHEDULED), new Date());
for (Process process : processesToBeFailed) {
context.setCurrentUser(process.getEPerson());
// Fail the process.
log.info("Process with ID {} did not complete before tomcat shutdown, failing it now.", process.getID());
fail(context, process);
// But still attach its log to the process.
appendLog(process.getID(), process.getName(),
"Process did not complete before tomcat shutdown.",
ProcessLogLevel.ERROR);
createLogBitstream(context, process);
}
try {
Context context = new Context();

// Processes that were running or scheduled when tomcat crashed, should be cleaned up during startup.
List<Process> processesToBeFailed = findByStatusAndCreationTimeOlderThan(
context, List.of(ProcessStatus.RUNNING, ProcessStatus.SCHEDULED), new Date());
for (Process process : processesToBeFailed) {
context.setCurrentUser(process.getEPerson());
// Fail the process.
log.info("Process with ID {} did not complete before tomcat shutdown, failing it now.",
process.getID());
fail(context, process);
// But still attach its log to the process.
appendLog(process.getID(), process.getName(),
"Process did not complete before tomcat shutdown.",
ProcessLogLevel.ERROR);
createLogBitstream(context, process);
}

context.complete();
context.complete();
} catch (Exception e) {
log.error("Unable to clean up Processes: ", e);
}
}

@Override
Expand Down

0 comments on commit 070fe68

Please sign in to comment.