From 56d4538613509121daa4b5eeafa4039a495ff272 Mon Sep 17 00:00:00 2001
From: Brian de Alwis <bsd@mt.ca>
Date: Tue, 22 Aug 2017 10:07:43 -0400
Subject: [PATCH] Apply patch https://git.eclipse.org/c/56954/7 to
 org.eclipse.core.jobs

---
 .../eclipse/core/internal/jobs/ThreadJob.java |  8 ++++--
 .../eclipse/core/internal/jobs/ThreadJob.java |  8 ++++--
 .../META-INF/MANIFEST.MF                      |  2 +-
 .../oxygen/org.eclipse.core.jobs/pom.xml      | 28 -------------------
 .../eclipse/core/internal/jobs/ThreadJob.java |  8 ++++--
 5 files changed, 16 insertions(+), 38 deletions(-)
 delete mode 100644 third_party/patches/oxygen/org.eclipse.core.jobs/pom.xml

diff --git a/third_party/patches/mars/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java b/third_party/patches/mars/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
index 1567ac0bcd..aa107693a2 100644
--- a/third_party/patches/mars/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
+++ b/third_party/patches/mars/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
@@ -288,9 +288,11 @@ else if (state != Job.NONE)
 		} finally {
 			if (interrupted)
 				Thread.currentThread().interrupt();
-			//only update the lock state if we ended up using the thread job that was given to us
-			waitEnd(threadJob, threadJob == result, monitor);
-			if (threadJob == result) {
+			ISchedulingRule resultRule = result.getRule();
+			ISchedulingRule threadJobRule = threadJob.getRule();
+			boolean containsRule = resultRule != null && threadJobRule != null && resultRule.contains(threadJobRule);
+			waitEnd(threadJob, containsRule, monitor);
+			if (containsRule) {
 				if (waiting)
 					manager.implicitJobs.removeWaiting(threadJob);
 			}
diff --git a/third_party/patches/neon/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java b/third_party/patches/neon/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
index 1567ac0bcd..aa107693a2 100644
--- a/third_party/patches/neon/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
+++ b/third_party/patches/neon/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
@@ -288,9 +288,11 @@ else if (state != Job.NONE)
 		} finally {
 			if (interrupted)
 				Thread.currentThread().interrupt();
-			//only update the lock state if we ended up using the thread job that was given to us
-			waitEnd(threadJob, threadJob == result, monitor);
-			if (threadJob == result) {
+			ISchedulingRule resultRule = result.getRule();
+			ISchedulingRule threadJobRule = threadJob.getRule();
+			boolean containsRule = resultRule != null && threadJobRule != null && resultRule.contains(threadJobRule);
+			waitEnd(threadJob, containsRule, monitor);
+			if (containsRule) {
 				if (waiting)
 					manager.implicitJobs.removeWaiting(threadJob);
 			}
diff --git a/third_party/patches/oxygen/org.eclipse.core.jobs/META-INF/MANIFEST.MF b/third_party/patches/oxygen/org.eclipse.core.jobs/META-INF/MANIFEST.MF
index 782b367148..c9d818f85f 100644
--- a/third_party/patches/oxygen/org.eclipse.core.jobs/META-INF/MANIFEST.MF
+++ b/third_party/patches/oxygen/org.eclipse.core.jobs/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: org.eclipse.core.jobs patched for bug 478634
 Bundle-SymbolicName: org.eclipse.core.jobs; singleton:=true
-Bundle-Version: 3.9.1.qualifier
+Bundle-Version: 3.9.0.v20170322-0013
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
 Export-Package: org.eclipse.core.internal.jobs;x-internal:=true,
diff --git a/third_party/patches/oxygen/org.eclipse.core.jobs/pom.xml b/third_party/patches/oxygen/org.eclipse.core.jobs/pom.xml
deleted file mode 100644
index 70d888f2be..0000000000
--- a/third_party/patches/oxygen/org.eclipse.core.jobs/pom.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Copyright (c) 2012, 2015 Eclipse Foundation and others.
-  All rights reserved. This program and the accompanying materials
-  are made available under the terms of the Eclipse Distribution License v1.0
-  which accompanies this distribution, and is available at
-  http://www.eclipse.org/org/documents/edl-v10.php
- 
-  Contributors:
-     Igor Fedorenko - initial implementation
-     Lars Vogel <Lars.Vogel@gmail.com> - Bug 432078
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <artifactId>eclipse.platform.runtime</artifactId>
-    <groupId>eclipse.platform.runtime</groupId>
-    <version>4.7.1-SNAPSHOT</version>
-    <relativePath>../../</relativePath>
-  </parent>
-  <groupId>org.eclipse.core</groupId>
-  <artifactId>org.eclipse.core.jobs</artifactId>
-  <version>3.9.1-SNAPSHOT</version>
-  <packaging>eclipse-plugin</packaging>
-  <properties>
-    <code.ignoredWarnings>-warn:-deprecation,raw,unchecked</code.ignoredWarnings>
-  </properties>
-</project>
diff --git a/third_party/patches/oxygen/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java b/third_party/patches/oxygen/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
index 5f87980755..63e656d5b9 100644
--- a/third_party/patches/oxygen/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
+++ b/third_party/patches/oxygen/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/ThreadJob.java
@@ -303,9 +303,11 @@ else if (state != Job.NONE)
 				manager.getLockManager().removeLockWaitThread(currentThread, threadJob.getRule());
 			}
 		} finally {
-			//only update the lock state if we ended up using the thread job that was given to us
-			waitEnd(threadJob, threadJob == result, monitor);
-			if (threadJob == result) {
+			ISchedulingRule resultRule = result.getRule();
+			ISchedulingRule threadJobRule = threadJob.getRule();
+			boolean containsRule = resultRule != null && threadJobRule != null && resultRule.contains(threadJobRule);
+			waitEnd(threadJob, containsRule, monitor);
+			if (containsRule) {
 				if (waiting)
 					manager.implicitJobs.removeWaiting(threadJob);
 			}