Skip to content

Commit

Permalink
Send -1 instead Long.Max for leasetime by default
Browse files Browse the repository at this point in the history
  • Loading branch information
sancar committed Oct 5, 2020
1 parent 7f16ac3 commit 2d0c8b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ public boolean tryLock(@Nonnull K key) {

@Override
public boolean tryLock(@Nonnull K key, long time, @Nullable TimeUnit timeunit) throws InterruptedException {
return tryLock(key, time, timeunit, Long.MAX_VALUE, null);
return tryLock(key, time, timeunit, UNSET, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
package com.hazelcast.client.map;

import com.hazelcast.client.test.TestHazelcastFactory;
import com.hazelcast.config.Config;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.map.IMap;
import com.hazelcast.map.EntryProcessor;
import com.hazelcast.map.IMap;
import com.hazelcast.spi.properties.ClusterProperty;
import com.hazelcast.test.AssertTask;
import com.hazelcast.test.HazelcastParallelClassRunner;
import com.hazelcast.test.annotation.ParallelJVMTest;
Expand Down Expand Up @@ -54,7 +56,9 @@ public class ClientMapLockTest {

@Before
public void setup() {
hazelcastFactory.newHazelcastInstance();
Config config = new Config();
config.setProperty(ClusterProperty.LOCK_MAX_LEASE_TIME_SECONDS.getName(), String.valueOf(Long.MAX_VALUE / 1000));
hazelcastFactory.newHazelcastInstance(config);
client = hazelcastFactory.newHazelcastClient();
}

Expand All @@ -63,6 +67,12 @@ public void tearDown() {
hazelcastFactory.terminateAll();
}

@Test
public void testTryLock() {
IMap map = client.getMap(randomString());
assertTrue(map.tryLock("key"));
}

@Test(expected = NullPointerException.class)
public void testisLocked_whenKeyNull_fromSameThread() {
final IMap map = client.getMap(randomString());
Expand Down

0 comments on commit 2d0c8b1

Please sign in to comment.