diff options
| author | Christian Trutz | 2011-05-18 05:43:24 +0000 |
|---|---|---|
| committer | Christian Trutz | 2011-05-18 05:43:24 +0000 |
| commit | b60ec6d685162477b6017a3a2ab15861601cc633 (patch) | |
| tree | b884f2bf56750f44abf304623d3c63603b50c349 | |
| parent | 015d4c89d10133b24989146885809c4b62105f47 (diff) | |
| download | egit-github-b60ec6d685162477b6017a3a2ab15861601cc633.tar.gz egit-github-b60ec6d685162477b6017a3a2ab15861601cc633.tar.xz egit-github-b60ec6d685162477b6017a3a2ab15861601cc633.zip | |
[findbugs] Milestone#setDueOn copy date argument before setting it
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.java | 16 | ||||
| -rw-r--r-- | org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/Milestone.java | 2 |
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 4a8f6447..38b45aea 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 d3d23790..6344ebea 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; } /** |
