Fix WindowsAclViews test failures There are some test failures on the 32-bit platforms. It seems the tests were having some issues serialzing and deserialzing SIDs correctly. This does not appear to be a 32-bit issue, so much as a GC issue. It looks like the SIDs were getting garbage collected because the only reference to them was a serialized Pointer in the ACE. This change adds caching of SIDs in a HashMap to the tests to avoid serializing and deserializing of SIDs. Code Review: https://codereview.appspot.com/132800043/
diff --git a/test/com/google/enterprise/adaptor/fs/TestWindowsAclViews.java b/test/com/google/enterprise/adaptor/fs/TestWindowsAclViews.java index 478593d..4247cb1 100644 --- a/test/com/google/enterprise/adaptor/fs/TestWindowsAclViews.java +++ b/test/com/google/enterprise/adaptor/fs/TestWindowsAclViews.java
@@ -39,6 +39,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; +import java.util.HashMap; import java.util.List; /** @@ -47,6 +48,9 @@ */ public class TestWindowsAclViews { + // Store the SIDs in a map to avoid serializing and deserializing them. + static HashMap<Long, AccountSid> sidMap = new HashMap<Long, AccountSid>(); + @Rule public final TemporaryFolder temp = new TemporaryFolder(); @@ -154,6 +158,7 @@ sid.write(); // See ACCESS_ACEStructure(Pointer p) constructor for mystery offsets. memory.setPointer(4 + 4, sid.getPointer()); + sidMap.put(Pointer.nativeValue(sid.getPointer()), sid); ace = new Ace(memory); assertEquals(ace.getSID().sid, sid.getPointer()); return ace; @@ -255,7 +260,7 @@ @Override Account getAccountBySid(WinNT.PSID sid) throws Win32Exception { - return new AccountSid(sid.sid).getAccount(); + return sidMap.get(Pointer.nativeValue(sid.sid)).getAccount(); } } }