summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Trutz2011-05-18 01:43:24 (EDT)
committerChristian Trutz2011-05-18 01:43:24 (EDT)
commitb60ec6d685162477b6017a3a2ab15861601cc633 (patch)
treeb884f2bf56750f44abf304623d3c63603b50c349
parent015d4c89d10133b24989146885809c4b62105f47 (diff)
downloadegit-github-b60ec6d685162477b6017a3a2ab15861601cc633.zip
egit-github-b60ec6d685162477b6017a3a2ab15861601cc633.tar.gz
egit-github-b60ec6d685162477b6017a3a2ab15861601cc633.tar.bz2
[findbugs] Milestone#setDueOn copy date argument before setting itrefs/changes/52/3452/1
Change-Id: Iffec5d0279fc8e541c0a0808de2f751c7a6fb43e Signed-off-by: Christian Trutz <christian.trutz@gmail.com>
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MilestoneTest.java16
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Milestone.java2
2 files changed, 15 insertions, 3 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MilestoneTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MilestoneTest.java
index 4a8f644..38b45ae 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MilestoneTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MilestoneTest.java
@@ -12,14 +12,16 @@ package org.eclipse.egit.github.core.tests;
import static org.junit.Assert.assertTrue;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import java.util.Date;
import org.eclipse.egit.github.core.Milestone;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
/**
* Unit tests for {@link Milestone}
*/
@@ -45,4 +47,14 @@ public class MilestoneTest {
assertTrue(milestone.getDueOn().getTime() != 0);
}
+ @Test
+ public void setDueOn_ReferenceMutableObject()
+ throws IllegalAccessException, NoSuchFieldException {
+ Milestone milestone = new Milestone();
+ Date longTimeAgo = new Date(0L);
+ milestone.setDueOn(longTimeAgo);
+ longTimeAgo.setTime(10000L);
+ assertTrue(milestone.getDueOn().getTime() == 0L);
+ }
+
}
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Milestone.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Milestone.java
index d3d2379..6344ebe 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Milestone.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Milestone.java
@@ -58,7 +58,7 @@ public class Milestone {
* @param dueOn
*/
public void setDueOn(Date dueOn) {
- this.dueOn = dueOn;
+ this.dueOn = dueOn != null ? new Date(dueOn.getTime()) : null;
}
/**