Repository: syncope Updated Branches: refs/heads/master 016b441a1 -> 0e908289a
[SYNCOPE-660]Merge from 1_2_X Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/0e908289 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/0e908289 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/0e908289 Branch: refs/heads/master Commit: 0e908289a61dc61387f4d4cd5ba0dd0a76f33b10 Parents: 016b441 Author: giacomolm <[email protected]> Authored: Mon Jun 22 13:02:41 2015 +0200 Committer: giacomolm <[email protected]> Committed: Mon Jun 22 13:02:41 2015 +0200 ---------------------------------------------------------------------- .../persistence-jpa/src/main/resources/content.xml | 5 +++++ .../persistence/jpa/inner/PlainSchemaTest.java | 2 +- .../persistence-jpa/src/test/resources/content.xml | 5 +++++ .../provisioning/java/job/AbstractTaskJob.java | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/0e908289/core/persistence-jpa/src/main/resources/content.xml ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/main/resources/content.xml b/core/persistence-jpa/src/main/resources/content.xml index 20b2ebc..caba10e 100644 --- a/core/persistence-jpa/src/main/resources/content.xml +++ b/core/persistence-jpa/src/main/resources/content.xml @@ -80,6 +80,11 @@ under the License. <CPlainAttr id="11" owner_id="1" schema_name="log.lastlogindate"/> <CPlainAttrValue id="11" attribute_id="11" booleanValue="1"/> + <PlainSchema name="tasks.interruptMaxRetries" type="Long" + mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/> + <CPlainAttr id="12" owner_id="1" schema_name="tasks.interruptMaxRetries"/> + <CPlainAttrValue id="12" attribute_id="12" longValue="20"/> + <!-- For usage with admin console --> <PlainSchema name="admin.user.layout" type="String" mandatoryCondition="false" multivalue="1" uniqueConstraint="0" readonly="0"/> http://git-wip-us.apache.org/repos/asf/syncope/blob/0e908289/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainSchemaTest.java ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainSchemaTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainSchemaTest.java index 119ae6d..b7c7ecc 100644 --- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainSchemaTest.java +++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/inner/PlainSchemaTest.java @@ -47,7 +47,7 @@ public class PlainSchemaTest extends AbstractTest { @Test public void findAll() { List<PlainSchema> schemas = plainSchemaDAO.findAll(); - assertEquals(42, schemas.size()); + assertEquals(43, schemas.size()); } @Test http://git-wip-us.apache.org/repos/asf/syncope/blob/0e908289/core/persistence-jpa/src/test/resources/content.xml ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/resources/content.xml b/core/persistence-jpa/src/test/resources/content.xml index 8b4740a..ffbd42f 100644 --- a/core/persistence-jpa/src/test/resources/content.xml +++ b/core/persistence-jpa/src/test/resources/content.xml @@ -78,6 +78,11 @@ under the License. <CPlainAttr id="11" owner_id="1" schema_name="log.lastlogindate"/> <CPlainAttrValue id="11" attribute_id="11" booleanValue="1"/> + <PlainSchema name="tasks.interruptMaxRetries" type="Long" + mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/> + <CPlainAttr id="12" owner_id="1" schema_name="tasks.interruptMaxRetries"/> + <CPlainAttrValue id="12" attribute_id="12" longValue="20"/> + <!-- For usage with admin console --> <PlainSchema name="admin.user.layout" type="String" mandatoryCondition="false" multivalue="1" uniqueConstraint="0" readonly="0"/> http://git-wip-us.apache.org/repos/asf/syncope/blob/0e908289/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/AbstractTaskJob.java ---------------------------------------------------------------------- diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/AbstractTaskJob.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/AbstractTaskJob.java index 688ca99..4c49655 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/AbstractTaskJob.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/AbstractTaskJob.java @@ -33,6 +33,7 @@ import org.apache.syncope.core.persistence.api.entity.task.TaskExec; import org.apache.syncope.core.provisioning.api.job.TaskJob; import org.apache.syncope.core.misc.AuditManager; import org.apache.syncope.core.misc.ExceptionUtils2; +import org.apache.syncope.core.persistence.api.dao.ConfDAO; import org.apache.syncope.core.provisioning.api.notification.NotificationManager; import org.quartz.DisallowConcurrentExecution; import org.quartz.JobExecutionContext; @@ -81,6 +82,12 @@ public abstract class AbstractTaskJob implements TaskJob { private TaskExecDAO taskExecDAO; /** + * Configuration DAO. + */ + @Autowired + private ConfDAO confDAO; + + /** * Notification manager. */ @Autowired @@ -197,6 +204,16 @@ public abstract class AbstractTaskJob implements TaskJob { LOG.info("Interrupting job time {} ", (new SimpleDateFormat(SyncopeConstants.DEFAULT_DATE_PATTERN, Locale. getDefault())).format(new Date())); thread.interrupt(); + if (thread.isAlive()) { + long maxRetry = confDAO.find("tasks.interruptMaxRetries", "0").getValues().get(0).getLongValue(); + for (int i = 0; i <= maxRetry && thread.isAlive(); i++) { + thread.interrupt(); + } + //if the thread is still alive, it should be available in the next stop + if (thread.isAlive()) { + this.runningThread.set(thread); + } + } } else { LOG.warn("Unable to retrieve the right thread related to the current job execution"); }
