summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2013-03-26 12:03:27 (EDT)
committer Steffen Pingel2013-04-04 17:41:34 (EDT)
commit1353774792b8ca148346d32c92cae8dabba8c2bb (patch)
treeefc8668c431ba4eaa0bb332d885361932c818ab9
parent74d575e678df92fbd0d4d243502561a1266b74cc (diff)
downloadorg.eclipse.mylyn.commons-1353774792b8ca148346d32c92cae8dabba8c2bb.zip
org.eclipse.mylyn.commons-1353774792b8ca148346d32c92cae8dabba8c2bb.tar.gz
org.eclipse.mylyn.commons-1353774792b8ca148346d32c92cae8dabba8c2bb.tar.bz2
always return a background monitor from Policy#backgroundMonitorFor
Policy#backgroundMonitorFor does not return a background monitor if the passed monitor is null. In that case it returns a new NullProgressMonitor, which is not expected. Change-Id: I4f10f84ed5d7e036dc314f4def87d49d3e0ae749
-rw-r--r--org.eclipse.mylyn.commons.net/src/org/eclipse/mylyn/commons/net/Policy.java2
-rw-r--r--org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/operations/OperationUtilTest.java6
2 files changed, 6 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.commons.net/src/org/eclipse/mylyn/commons/net/Policy.java b/org.eclipse.mylyn.commons.net/src/org/eclipse/mylyn/commons/net/Policy.java
index 123a408..6299565 100644
--- a/org.eclipse.mylyn.commons.net/src/org/eclipse/mylyn/commons/net/Policy.java
+++ b/org.eclipse.mylyn.commons.net/src/org/eclipse/mylyn/commons/net/Policy.java
@@ -65,7 +65,7 @@ public class Policy {
*/
public static IProgressMonitor backgroundMonitorFor(IProgressMonitor monitor) {
if (monitor == null) {
- return new NullProgressMonitor();
+ monitor = new NullProgressMonitor();
}
return new BackgroundProgressMonitor(monitor);
}
diff --git a/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/operations/OperationUtilTest.java b/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/operations/OperationUtilTest.java
index 420bcbd..0ecf854 100644
--- a/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/operations/OperationUtilTest.java
+++ b/org.eclipse.mylyn.commons.tests/src/org/eclipse/mylyn/commons/tests/operations/OperationUtilTest.java
@@ -32,10 +32,14 @@ public class OperationUtilTest extends TestCase {
assertFalse(OperationUtil.isBackgroundMonitor(new NullProgressMonitor()));
}
- public void testIsBackgroundMonitorBackgroundMonitor() {
+ public void testIsBackgroundMonitorBackgroundMonitorForNullProgressMonitor() {
assertTrue(OperationUtil.isBackgroundMonitor(Policy.backgroundMonitorFor(new NullProgressMonitor())));
}
+ public void testIsBackgroundMonitorBackgroundMonitorForNull() {
+ assertTrue(OperationUtil.isBackgroundMonitor(Policy.backgroundMonitorFor(null)));
+ }
+
public void testIsBackgroundMonitorOperationMonitorNull() {
assertFalse(OperationUtil.isBackgroundMonitor(OperationUtil.convert(null)));
}