156 |
|
*/ |
157 |
|
public void testWriteLockInterruptibly_Interrupted() { |
158 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
159 |
– |
lock.writeLock().lock(); |
159 |
|
Thread t = new Thread(new Runnable() { |
160 |
|
public void run() { |
161 |
|
try { |
162 |
|
lock.writeLock().lockInterruptibly(); |
163 |
< |
threadShouldThrow(); |
163 |
> |
lock.writeLock().unlock(); |
164 |
> |
lock.writeLock().lockInterruptibly(); |
165 |
> |
lock.writeLock().unlock(); |
166 |
|
} catch(InterruptedException success){} |
167 |
|
} |
168 |
|
}); |
169 |
|
try { |
170 |
+ |
lock.writeLock().lock(); |
171 |
|
t.start(); |
172 |
|
t.interrupt(); |
173 |
|
lock.writeLock().unlock(); |
178 |
|
} |
179 |
|
|
180 |
|
/** |
181 |
< |
* timed write-trylock is interruptible |
181 |
> |
* timed write-tryLock is interruptible |
182 |
|
*/ |
183 |
|
public void testWriteTryLock_Interrupted() { |
184 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
187 |
|
public void run() { |
188 |
|
try { |
189 |
|
lock.writeLock().tryLock(1000,TimeUnit.MILLISECONDS); |
188 |
– |
threadShouldThrow(); |
190 |
|
} catch(InterruptedException success){} |
191 |
|
} |
192 |
|
}); |
210 |
|
public void run() { |
211 |
|
try { |
212 |
|
lock.readLock().lockInterruptibly(); |
212 |
– |
threadShouldThrow(); |
213 |
|
} catch(InterruptedException success){} |
214 |
|
} |
215 |
|
}); |
224 |
|
} |
225 |
|
|
226 |
|
/** |
227 |
< |
* timed read-trylock is interruptible |
227 |
> |
* timed read-tryLock is interruptible |
228 |
|
*/ |
229 |
|
public void testReadTryLock_Interrupted() { |
230 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
248 |
|
|
249 |
|
|
250 |
|
/** |
251 |
< |
* write-trylock fails if locked |
251 |
> |
* write-tryLock fails if locked |
252 |
|
*/ |
253 |
|
public void testWriteTryLockWhenLocked() { |
254 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
268 |
|
} |
269 |
|
|
270 |
|
/** |
271 |
< |
* read-trylock fails if locked |
271 |
> |
* read-tryLock fails if locked |
272 |
|
*/ |
273 |
|
public void testReadTryLockWhenLocked() { |
274 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
378 |
|
|
379 |
|
|
380 |
|
/** |
381 |
< |
* Read trylock succeeds if readlocked but not writelocked |
381 |
> |
* Read tryLock succeeds if readlocked but not writelocked |
382 |
|
*/ |
383 |
|
public void testTryLockWhenReadLocked() { |
384 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
401 |
|
|
402 |
|
|
403 |
|
/** |
404 |
< |
* write trylock fails when readlocked |
404 |
> |
* write tryLock fails when readlocked |
405 |
|
*/ |
406 |
|
public void testWriteTryLockWhenReadLocked() { |
407 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
423 |
|
|
424 |
|
|
425 |
|
/** |
426 |
< |
* write timed trylock times out if locked |
426 |
> |
* write timed tryLock times out if locked |
427 |
|
*/ |
428 |
|
public void testWriteTryLock_Timeout() { |
429 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
447 |
|
} |
448 |
|
|
449 |
|
/** |
450 |
< |
* read timed trylock times out if write-locked |
450 |
> |
* read timed tryLock times out if write-locked |
451 |
|
*/ |
452 |
|
public void testReadTryLock_Timeout() { |
453 |
|
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
938 |
|
} |
939 |
|
|
940 |
|
/** |
941 |
+ |
* hasWaiters throws NPE if null |
942 |
+ |
*/ |
943 |
+ |
public void testHasWaitersNPE() { |
944 |
+ |
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
945 |
+ |
try { |
946 |
+ |
lock.hasWaiters(null); |
947 |
+ |
shouldThrow(); |
948 |
+ |
} catch (NullPointerException success) { |
949 |
+ |
} catch (Exception ex) { |
950 |
+ |
unexpectedException(); |
951 |
+ |
} |
952 |
+ |
} |
953 |
+ |
|
954 |
+ |
/** |
955 |
+ |
* getWaitQueueLength throws NPE if null |
956 |
+ |
*/ |
957 |
+ |
public void testGetWaitQueueLengthNPE() { |
958 |
+ |
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
959 |
+ |
try { |
960 |
+ |
lock.getWaitQueueLength(null); |
961 |
+ |
shouldThrow(); |
962 |
+ |
} catch (NullPointerException success) { |
963 |
+ |
} catch (Exception ex) { |
964 |
+ |
unexpectedException(); |
965 |
+ |
} |
966 |
+ |
} |
967 |
+ |
|
968 |
+ |
|
969 |
+ |
/** |
970 |
+ |
* getWaitingThreads throws NPE if null |
971 |
+ |
*/ |
972 |
+ |
public void testGetWaitingThreadsNPE() { |
973 |
+ |
final PublicReentrantReadWriteLock lock = new PublicReentrantReadWriteLock(); |
974 |
+ |
try { |
975 |
+ |
lock.getWaitingThreads(null); |
976 |
+ |
shouldThrow(); |
977 |
+ |
} catch (NullPointerException success) { |
978 |
+ |
} catch (Exception ex) { |
979 |
+ |
unexpectedException(); |
980 |
+ |
} |
981 |
+ |
} |
982 |
+ |
|
983 |
+ |
/** |
984 |
|
* hasWaiters throws IAE if not owned |
985 |
|
*/ |
986 |
|
public void testHasWaitersIAE() { |