Skip to content

Conversation

sathish2379
Copy link
Contributor

@sathish2379 sathish2379 commented May 3, 2024

Guidelines for Pull Requests

If you haven't yet read our code review guidelines, please do so, You can find them here.

Please confirm the following by adding an x for each item (turn [ ] into [x]).

  • I have removed all code style changes that are not necessary (e.g. changing blanks across the whole file that don’t need to be changed, adding empty lines in parts other than your own code)
  • I am not making any changes to files that don’t have any effect (e.g. imports added that don’t need to be added)
  • I do not have any sysout statements in my code or commented out code that isn’t needed anymore
  • I am not reformatting any files in the wrong format or without cause.
  • I am not changing file encoding or line endings to something else than UTF-8, LF
  • My pull request does not show an insane amount of files being changed although my ticket only requires a few files being changed
  • I have added Javadoc/documentation where appropriate
  • I have added test cases where appropriate
  • I have explained any part of my code/implementation decisions that is not be self-explanatory

Please provide a brief description of your ticket

... Put ticket description here and add link to ticket ...
Right now, a job is just marked as cancelled (for jobs that silently failed) but not aborted. The sync processor should check in regular intervals if the current job is still in progress or if it should be cancelled.
https://diging.atlassian.net/browse/CITE-132

Are there any other pull requests that this one depends on?

Here is the previous PR: #212

Anything else the reviewer needs to know?

... describe here ...

@diging-jenkins
Copy link

Can one of the admins verify this patch?

@sathish2379 sathish2379 requested a review from jdamerow May 3, 2024 20:03
jobRepo.save(job);

Future<String> result = new AsyncResult<String>(job.getId());
return result;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge with line 170

if (existingFuture != null && !existingFuture.isDone()) {
existingFuture.cancel(true);
futureMap.remove(groupId);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the job cancelled here?

return result;
}

private boolean checkIfThreadIsInterrupted(Thread thread, GroupSyncJob job, String groupId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not only check but also set the task to cancelled

job.setStatus(JobStatus.PREPARED);
jobRepo.save(job);
jobManager.addJob(job);
Thread currentThread = Thread.currentThread();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just do this in checkIfThreadIsInterrupted and remove the first parameter of the method.

@jdamerow jdamerow closed this May 14, 2024
@sathish2379 sathish2379 reopened this May 14, 2024

syncCitations(user, groupId, job, versions, counter);

if(checkIfThreadIsInterruptedAndCancelJob(job, groupId)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, now that I'm looking at this again, you will want to cancel the thread within the syncCitations and probably also syncCollections method. They are the long running methods that need to be cancelled if cancellation was requested. Otherwise, if there are 1000 citations to sync it would still go through all of them before cancelling.


private boolean checkIfThreadIsInterruptedAndCancelJob(GroupSyncJob job, String groupId) {
Thread thread = Thread.currentThread();
if(thread.isInterrupted()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge with 173

@Override
public void cancelJob(String jobId) {
Optional<GroupSyncJob> jobOptional = jobRepo.findById(jobId);
String groupId;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declare where needed

@jdamerow jdamerow closed this May 15, 2024
@sathish2379 sathish2379 reopened this May 22, 2024
@jdamerow
Copy link
Member

Make it so, Jenkins.

@diging-jenkins
Copy link

Jenkins successfully deployed Citesphere to be reviewed!

@jdamerow
Copy link
Member

Not sure why, but the items table for a group is now empty.

@jdamerow jdamerow closed this May 23, 2024
@jdamerow jdamerow reopened this Sep 26, 2025
@diging-jenkins
Copy link

Jenkins successfully deployed Citesphere to be reviewed!

@jdamerow
Copy link
Member

jdamerow commented Sep 26, 2025

java.lang.NullPointerException
	edu.asu.diging.citesphere.core.service.jobs.impl.SyncJobManager.cancelJob(SyncJobManager.java:83)
	edu.asu.diging.citesphere.web.user.CancelSyncJobController.cancel(CancelSyncJobController.java:19)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.base/java.lang.reflect.Method.invoke(Method.java:566)
	org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
	org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
	org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)

@jdamerow jdamerow closed this Sep 26, 2025
@diging-jenkins
Copy link

Jenkins successfully deployed Citesphere to be reviewed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants