Skip to content

Commit

Permalink
fix: del gmt modify time in session
Browse files Browse the repository at this point in the history
  • Loading branch information
xjlgod committed Dec 30, 2024
1 parent e651120 commit b193065
Showing 1 changed file with 0 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,24 @@ public void testBigDataWrite() throws Exception {
fileTransactionStoreManager = new FileTransactionStoreManager(seataFile.getAbsolutePath(), null);
BranchSession branchSessionA = Mockito.mock(BranchSession.class);
GlobalSession global = new GlobalSession();
global.setGmtModified(System.currentTimeMillis());
Mockito.when(branchSessionA.encode())
.thenReturn(createBigBranchSessionData(global, (byte) 'A'));
Mockito.when(branchSessionA.getApplicationData())
.thenReturn(new String(createBigApplicationData((byte) 'A')));
Mockito.when(branchSessionA.getGmtModified()).thenReturn(global.getGmtModified());
BranchSession branchSessionB = Mockito.mock(BranchSession.class);
Mockito.when(branchSessionB.encode())
.thenReturn(createBigBranchSessionData(global, (byte) 'B'));
Mockito.when(branchSessionB.getApplicationData())
.thenReturn(new String(createBigApplicationData((byte) 'B')));
Mockito.when(branchSessionB.getGmtModified()).thenReturn(global.getGmtModified());
Assertions.assertTrue(fileTransactionStoreManager.writeSession(TransactionStoreManager.LogOperation.BRANCH_ADD, branchSessionA));
Assertions.assertTrue(fileTransactionStoreManager.writeSession(TransactionStoreManager.LogOperation.BRANCH_ADD, branchSessionB));
List<TransactionWriteStore> list = fileTransactionStoreManager.readWriteStore(2000, false);
Assertions.assertNotNull(list);
Assertions.assertEquals(2, list.size());
BranchSession loadedBranchSessionA = (BranchSession) list.get(0).getSessionRequest();
Assertions.assertEquals(branchSessionA.getApplicationData(), loadedBranchSessionA.getApplicationData());
Assertions.assertEquals(branchSessionA.getGmtModified(), loadedBranchSessionA.getGmtModified());
BranchSession loadedBranchSessionB = (BranchSession) list.get(1).getSessionRequest();
Assertions.assertEquals(branchSessionB.getApplicationData(), loadedBranchSessionB.getApplicationData());
Assertions.assertEquals(branchSessionB.getGmtModified(), loadedBranchSessionB.getGmtModified());
} finally {
if (fileTransactionStoreManager != null) {
fileTransactionStoreManager.shutdown();
Expand All @@ -109,7 +104,6 @@ public void testFindTimeoutAndSave() throws Exception {
List<GlobalSession> timeoutSessions = new ArrayList<>();
for (int i = 0; i < 100; i++) {
GlobalSession globalSession = new GlobalSession("", "", "", 60000);
globalSession.setGmtModified(System.currentTimeMillis());
BranchSession branchSessionA = Mockito.mock(BranchSession.class);
Mockito.when(branchSessionA.encode())
.thenReturn(createBigBranchSessionData(globalSession, (byte) 'A'));
Expand Down Expand Up @@ -165,7 +159,6 @@ private byte[] createBigBranchSessionData(GlobalSession global, byte c) {
+ 4 // xidBytes.size
+ 1 // statusCode
+ 1 // lockstatus
+ 8 // gmtModified
+ 1; //branchType
String xid = global.getXid();
byte[] xidBytes = null;
Expand All @@ -190,7 +183,6 @@ private byte[] createBigBranchSessionData(GlobalSession global, byte c) {
}
byteBuffer.put((byte) 0);
byteBuffer.put((byte) 0);
byteBuffer.putLong(global.getGmtModified());
byteBuffer.put((byte) 0);
BufferUtils.flip(byteBuffer);
byte[] bytes = new byte[byteBuffer.limit()];
Expand Down

0 comments on commit b193065

Please sign in to comment.