Fix checkpointOwner copy issue for multistream lease (#1401)
This commit is contained in:
parent
b154acf7f5
commit
3facf303bf
3 changed files with 31 additions and 3 deletions
|
|
@ -163,6 +163,7 @@ public class Lease {
|
|||
lease.childShardIds(),
|
||||
lease.pendingCheckpointState(),
|
||||
lease.hashKeyRangeForLease());
|
||||
checkpointOwner(lease.checkpointOwner);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
|
@ -458,8 +459,6 @@ public class Lease {
|
|||
* @return A deep copy of this object.
|
||||
*/
|
||||
public Lease copy() {
|
||||
final Lease lease = new Lease(this);
|
||||
lease.checkpointOwner(this.checkpointOwner);
|
||||
return lease;
|
||||
return new Lease(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import software.amazon.kinesis.retrieval.kpl.ExtendedSequenceNumber;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
|
@ -109,6 +110,15 @@ public class LeaseTest {
|
|||
assertFalse(shutdownRequestedLease.isEligibleForGracefulShutdown());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyingLease() {
|
||||
final String checkpointOwner = "checkpointOwner";
|
||||
final Lease original = new Lease();
|
||||
original.checkpointOwner(checkpointOwner);
|
||||
final Lease copy = original.copy();
|
||||
assertEquals(checkpointOwner, copy.checkpointOwner());
|
||||
}
|
||||
|
||||
private static Lease createLease(String leaseOwner, String leaseKey, long lastCounterIncrementNanos) {
|
||||
final Lease lease = new Lease();
|
||||
lease.checkpoint(new ExtendedSequenceNumber("checkpoint"));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package software.amazon.kinesis.leases;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class MultiStreamLeaseTest {
|
||||
|
||||
@Test
|
||||
void testCopyingMultiStreamLease() {
|
||||
final String checkpointOwner = "checkpointOwner";
|
||||
final MultiStreamLease original = new MultiStreamLease();
|
||||
original.checkpointOwner(checkpointOwner);
|
||||
original.streamIdentifier("identifier");
|
||||
original.shardId("shardId");
|
||||
final MultiStreamLease copy = original.copy();
|
||||
assertEquals(checkpointOwner, copy.checkpointOwner());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue