You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2018/10/04 13:38:19 UTC

cayenne git commit: Fix test random failure

Repository: cayenne
Updated Branches:
  refs/heads/master a8162dadf -> 7d9d2c00f


Fix test random failure


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/7d9d2c00
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/7d9d2c00
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/7d9d2c00

Branch: refs/heads/master
Commit: 7d9d2c00fcf8bc358d9cd197e50ef67c38d3c738
Parents: a8162da
Author: Nikita Timofeev <st...@gmail.com>
Authored: Thu Oct 4 16:38:15 2018 +0300
Committer: Nikita Timofeev <st...@gmail.com>
Committed: Thu Oct 4 16:38:15 2018 +0300

----------------------------------------------------------------------
 .../test/java/org/apache/cayenne/util/WeakValueMapTest.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/7d9d2c00/cayenne-server/src/test/java/org/apache/cayenne/util/WeakValueMapTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/util/WeakValueMapTest.java b/cayenne-server/src/test/java/org/apache/cayenne/util/WeakValueMapTest.java
index 6f24c37..8afd2c4 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/util/WeakValueMapTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/util/WeakValueMapTest.java
@@ -143,10 +143,15 @@ public class WeakValueMapTest {
     @Test
     public void testSerializationSupport() throws Exception {
         WeakValueMap<String, Object> map = new WeakValueMap<>();
+
+        // hold references so gc won't clean them
+        Integer val1 = Integer.valueOf(543);
+        TestSerializable val2 = new TestSerializable();
+
         map.put("key_1", 123);
         map.put("key_2", 42);
-        map.put("key_3", 543);
-        map.put("key_4", new TestSerializable());
+        map.put("key_3", val1);
+        map.put("key_4", val2);
         assertEquals(4, map.size());
 
         WeakValueMap<String, Object> clone = Util.cloneViaSerialization(map);