mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
Merge pull request #1050 from JerryFoundation/v5-dev
1. 在使用阻塞等待获取锁的方式中,必须在try代码块之外,并且在加锁方法与try代码块之间没有任何可能抛出异常的方法调用,避免加锁成功后…
This commit is contained in:
commit
cf1c96592c
@ -105,7 +105,7 @@ public class ConcurrentHashSet<E> extends AbstractSet<E> implements java.io.Seri
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return map.remove(o) == PRESENT;
|
||||
return PRESENT.equals(map.remove(o));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,65 +22,78 @@ public class DelegatedExecutorService extends AbstractExecutorService {
|
||||
e = executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullableProblems")
|
||||
public void execute(Runnable command) {
|
||||
e.execute(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
e.shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullableProblems")
|
||||
public List<Runnable> shutdownNow() {
|
||||
return e.shutdownNow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShutdown() {
|
||||
return e.isShutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTerminated() {
|
||||
return e.isTerminated();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullableProblems")
|
||||
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
return e.awaitTermination(timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullableProblems")
|
||||
public Future<?> submit(Runnable task) {
|
||||
return e.submit(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullableProblems")
|
||||
public <T> Future<T> submit(Callable<T> task) {
|
||||
return e.submit(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullableProblems")
|
||||
public <T> Future<T> submit(Runnable task, T result) {
|
||||
return e.submit(task, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullableProblems")
|
||||
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
|
||||
return e.invokeAll(tasks);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullableProblems")
|
||||
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
|
||||
throws InterruptedException {
|
||||
return e.invokeAll(tasks, timeout, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullableProblems")
|
||||
public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
|
||||
throws InterruptedException, ExecutionException {
|
||||
return e.invokeAny(tasks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
|
||||
throws InterruptedException, ExecutionException, TimeoutException {
|
||||
return e.invokeAny(tasks, timeout, unit);
|
||||
|
@ -52,8 +52,8 @@ public class TaskTable implements Serializable {
|
||||
*/
|
||||
public TaskTable add(String id, CronPattern pattern, Task task) {
|
||||
final Lock writeLock = lock.writeLock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
try {
|
||||
if (ids.contains(id)) {
|
||||
throw new CronException("Id [{}] has been existed!", id);
|
||||
}
|
||||
@ -75,8 +75,8 @@ public class TaskTable implements Serializable {
|
||||
*/
|
||||
public List<String> getIds() {
|
||||
final Lock readLock = lock.readLock();
|
||||
try {
|
||||
readLock.lock();
|
||||
try {
|
||||
return Collections.unmodifiableList(this.ids);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
@ -91,8 +91,8 @@ public class TaskTable implements Serializable {
|
||||
*/
|
||||
public List<CronPattern> getPatterns() {
|
||||
final Lock readLock = lock.readLock();
|
||||
try {
|
||||
readLock.lock();
|
||||
try {
|
||||
return Collections.unmodifiableList(this.patterns);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
@ -107,8 +107,8 @@ public class TaskTable implements Serializable {
|
||||
*/
|
||||
public List<Task> getTasks() {
|
||||
final Lock readLock = lock.readLock();
|
||||
try {
|
||||
readLock.lock();
|
||||
try {
|
||||
return Collections.unmodifiableList(this.tasks);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
@ -122,8 +122,8 @@ public class TaskTable implements Serializable {
|
||||
*/
|
||||
public void remove(String id) {
|
||||
final Lock writeLock = lock.writeLock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
try {
|
||||
final int index = ids.indexOf(id);
|
||||
if (index > -1) {
|
||||
tasks.remove(index);
|
||||
@ -146,8 +146,8 @@ public class TaskTable implements Serializable {
|
||||
*/
|
||||
public boolean updatePattern(String id, CronPattern pattern) {
|
||||
final Lock writeLock = lock.writeLock();
|
||||
try {
|
||||
writeLock.lock();
|
||||
try {
|
||||
final int index = ids.indexOf(id);
|
||||
if (index > -1) {
|
||||
patterns.set(index, pattern);
|
||||
@ -168,8 +168,8 @@ public class TaskTable implements Serializable {
|
||||
*/
|
||||
public Task getTask(int index) {
|
||||
final Lock readLock = lock.readLock();
|
||||
try {
|
||||
readLock.lock();
|
||||
try {
|
||||
return tasks.get(index);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
@ -200,8 +200,8 @@ public class TaskTable implements Serializable {
|
||||
*/
|
||||
public CronPattern getPattern(int index) {
|
||||
final Lock readLock = lock.readLock();
|
||||
try {
|
||||
readLock.lock();
|
||||
try {
|
||||
return patterns.get(index);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
@ -250,8 +250,8 @@ public class TaskTable implements Serializable {
|
||||
*/
|
||||
public void executeTaskIfMatch(long millis) {
|
||||
final Lock readLock = lock.readLock();
|
||||
try {
|
||||
readLock.lock();
|
||||
try {
|
||||
executeTaskIfMatchInternal(millis);
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
|
@ -140,8 +140,8 @@ public class RC4 implements Serializable {
|
||||
*/
|
||||
public byte[] crypt(final byte[] msg) {
|
||||
final ReadLock readLock = this.lock.readLock();
|
||||
readLock.lock();
|
||||
byte[] code;
|
||||
readLock.lock();
|
||||
try {
|
||||
final int[] sbox = this.sbox.clone();
|
||||
code = new byte[msg.length];
|
||||
|
Loading…
x
Reference in New Issue
Block a user