Skip to content

Commit 04d6bae

Browse files
committed
lint(app, android): lint fixes for task executor
1 parent 99f8d2c commit 04d6bae

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

packages/app/android/src/main/java/io/invertase/firebase/common/TaskExecutorService.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*
1818
*/
1919

20-
import io.invertase.firebase.common.ReactNativeFirebaseJSON;
21-
2220
import java.util.HashMap;
2321
import java.util.Map;
2422
import java.util.Set;
@@ -36,7 +34,7 @@ public class TaskExecutorService {
3634
private final String name;
3735
private final int maximumPoolSize;
3836
private final int keepAliveSeconds;
39-
private static Map<String, ExecutorService> executors = new HashMap<>();
37+
private static final Map<String, ExecutorService> executors = new HashMap<>();
4038

4139
TaskExecutorService(String name) {
4240
this.name = name;
@@ -73,27 +71,25 @@ public ExecutorService getExecutor(boolean isTransactional, String identifier) {
7371
}
7472

7573
private ExecutorService getNewExecutor(boolean isTransactional) {
76-
if (isTransactional == true) {
74+
if (isTransactional) {
7775
return Executors.newSingleThreadExecutor();
7876
} else {
79-
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, maximumPoolSize, keepAliveSeconds, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
77+
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, maximumPoolSize, keepAliveSeconds, TimeUnit.SECONDS, new SynchronousQueue<>());
8078
threadPoolExecutor.setRejectedExecutionHandler(executeInFallback);
8179
return threadPoolExecutor;
8280
}
8381
}
8482

85-
private RejectedExecutionHandler executeInFallback = new RejectedExecutionHandler() {
86-
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
87-
if (executor.isShutdown() || executor.isTerminated() || executor.isTerminating()) {
88-
return;
89-
}
90-
ExecutorService fallbackExecutor = getTransactionalExecutor();
91-
fallbackExecutor.execute(r);
92-
};
83+
private final RejectedExecutionHandler executeInFallback = (r, executor) -> {
84+
if (executor.isShutdown() || executor.isTerminated() || executor.isTerminating()) {
85+
return;
86+
}
87+
ExecutorService fallbackExecutor = getTransactionalExecutor();
88+
fallbackExecutor.execute(r);
9389
};
9490

9591
public String getExecutorName(boolean isTransactional, String identifier) {
96-
if (isTransactional == true) {
92+
if (isTransactional) {
9793
return name + "TransactionalExecutor" + identifier;
9894
}
9995
return name + "Executor" + identifier;
@@ -102,10 +98,10 @@ public String getExecutorName(boolean isTransactional, String identifier) {
10298
public void shutdown() {
10399
Set<String> existingExecutorNames = executors.keySet();
104100
for (String executorName : existingExecutorNames) {
105-
if (executorName.startsWith(name) == false) {
101+
if (!executorName.startsWith(name)) {
106102
existingExecutorNames.remove(executorName);
107103
} else {
108-
removeExecutor(executorName);
104+
removeExecutor(executorName);
109105
}
110106
}
111107
}

0 commit comments

Comments
 (0)