File tree 3 files changed +31
-3
lines changed
amazon-kinesis-client/src
main/java/software/amazon/kinesis/leases
test/java/software/amazon/kinesis/leases
3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,7 @@ protected Lease(Lease lease) {
163
163
lease .childShardIds (),
164
164
lease .pendingCheckpointState (),
165
165
lease .hashKeyRangeForLease ());
166
+ checkpointOwner (lease .checkpointOwner );
166
167
}
167
168
168
169
@ Deprecated
@@ -458,8 +459,6 @@ public void leaseOwner(String leaseOwner) {
458
459
* @return A deep copy of this object.
459
460
*/
460
461
public Lease copy () {
461
- final Lease lease = new Lease (this );
462
- lease .checkpointOwner (this .checkpointOwner );
463
- return lease ;
462
+ return new Lease (this );
464
463
}
465
464
}
Original file line number Diff line number Diff line change 10
10
import org .mockito .runners .MockitoJUnitRunner ;
11
11
import software .amazon .kinesis .retrieval .kpl .ExtendedSequenceNumber ;
12
12
13
+ import static org .junit .Assert .assertEquals ;
13
14
import static org .junit .Assert .assertFalse ;
14
15
import static org .junit .Assert .assertTrue ;
15
16
@@ -109,6 +110,15 @@ public void testIsEligibleForGracefulShutdownFalse_shutdownRequested_assertFalse
109
110
assertFalse (shutdownRequestedLease .isEligibleForGracefulShutdown ());
110
111
}
111
112
113
+ @ Test
114
+ public void testCopyingLease () {
115
+ final String checkpointOwner = "checkpointOwner" ;
116
+ final Lease original = new Lease ();
117
+ original .checkpointOwner (checkpointOwner );
118
+ final Lease copy = original .copy ();
119
+ assertEquals (checkpointOwner , copy .checkpointOwner ());
120
+ }
121
+
112
122
private static Lease createLease (String leaseOwner , String leaseKey , long lastCounterIncrementNanos ) {
113
123
final Lease lease = new Lease ();
114
124
lease .checkpoint (new ExtendedSequenceNumber ("checkpoint" ));
Original file line number Diff line number Diff line change
1
+ package software .amazon .kinesis .leases ;
2
+
3
+ import org .junit .jupiter .api .Test ;
4
+
5
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
6
+
7
+ class MultiStreamLeaseTest {
8
+
9
+ @ Test
10
+ void testCopyingMultiStreamLease () {
11
+ final String checkpointOwner = "checkpointOwner" ;
12
+ final MultiStreamLease original = new MultiStreamLease ();
13
+ original .checkpointOwner (checkpointOwner );
14
+ original .streamIdentifier ("identifier" );
15
+ original .shardId ("shardId" );
16
+ final MultiStreamLease copy = original .copy ();
17
+ assertEquals (checkpointOwner , copy .checkpointOwner ());
18
+ }
19
+ }
You can’t perform that action at this time.
0 commit comments