Skip to content

Commit 479bfe9

Browse files
committed
Merge pull request #26 from DevFactory/release/private-methods-that-dont-access-instance-data-should-be-static-fix-1
Fixing squid:S2325 -"private" methods that don't access instance data should be "static"
2 parents 98a9d4e + 89f2e36 commit 479bfe9

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/main/java/org/audit4j/core/schedule/Schedulers.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public enum ExecutorType {
5353
*/
5454
public static Schedulers newDefault() {
5555
createSingleton();
56-
instance.increaseNoOfSchedullers();
56+
Schedulers.increaseNoOfSchedullers();
5757
instance.setCurrentScheduler(new ConcurrentTaskScheduler());
5858
return instance;
5959
}
@@ -67,7 +67,7 @@ public static Schedulers newDefault() {
6767
*/
6868
public static Schedulers newThreadPoolScheduler(int poolSize) {
6969
createSingleton();
70-
instance.increaseNoOfSchedullers();
70+
Schedulers.increaseNoOfSchedullers();
7171
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
7272
CustomizableThreadFactory factory = new CustomizableThreadFactory();
7373
scheduler.initializeExecutor(factory, new RejectedExecutionHandler() {
@@ -99,8 +99,8 @@ public static Schedulers stop(String schedulerId) {
9999
throw new IllegalStateException("No schedulers match with given id.");
100100
}
101101
future.cancel(true);
102-
instance.decreaseNoOfSchedullers();
103-
instance.decreaseNoOfRunningSchedullers();
102+
Schedulers.decreaseNoOfSchedullers();
103+
Schedulers.decreaseNoOfRunningSchedullers();
104104

105105
return instance;
106106
}
@@ -119,8 +119,8 @@ public static Schedulers stopAll() {
119119
for (Entry<String, ScheduledFuture<?>> entry : instance.runningSchedullers.entrySet()) {
120120
ScheduledFuture<?> future = entry.getValue();
121121
future.cancel(true);
122-
instance.decreaseNoOfSchedullers();
123-
instance.decreaseNoOfRunningSchedullers();
122+
Schedulers.decreaseNoOfSchedullers();
123+
Schedulers.decreaseNoOfRunningSchedullers();
124124
}
125125

126126
return instance;
@@ -138,9 +138,9 @@ public String schedule(TriggerTask task) {
138138
throw new IllegalStateException("New scheduler should be crea");
139139
}
140140
ScheduledFuture<?> future = getCurrentScheduler().schedule(task.getRunnable(), task.getTrigger());
141-
String id = getUUID();
141+
String id = Schedulers.getUUID();
142142
runningSchedullers.put(id, future);
143-
increaseNoOfRunningSchedullers();
143+
Schedulers.increaseNoOfRunningSchedullers();
144144
setCurrentScheduler(null);
145145
return id;
146146
}
@@ -154,9 +154,9 @@ public String schedule(TriggerTask task) {
154154
*/
155155
public String schedule(Trigger trigger, Runnable task) {
156156
ScheduledFuture<?> future = getCurrentScheduler().schedule(task, trigger);
157-
String id = getUUID();
157+
String id = Schedulers.getUUID();
158158
runningSchedullers.put(id, future);
159-
increaseNoOfRunningSchedullers();
159+
Schedulers.increaseNoOfRunningSchedullers();
160160
setCurrentScheduler(null);
161161
return id;
162162
}
@@ -173,28 +173,28 @@ public static TaskRegistrar taskRegistry() {
173173
/**
174174
* Increase no of schedullers.
175175
*/
176-
private synchronized void increaseNoOfSchedullers() {
176+
private static synchronized void increaseNoOfSchedullers() {
177177
noOfSchedullers++;
178178
}
179179

180180
/**
181181
* Increase no of running schedullers.
182182
*/
183-
private synchronized void increaseNoOfRunningSchedullers() {
183+
private static synchronized void increaseNoOfRunningSchedullers() {
184184
noOfRunningSchedullers++;
185185
}
186186

187187
/**
188188
* Decrease no of schedullers.
189189
*/
190-
private synchronized void decreaseNoOfSchedullers() {
190+
private static synchronized void decreaseNoOfSchedullers() {
191191
noOfSchedullers--;
192192
}
193193

194194
/**
195195
* Decrease no of running schedullers.
196196
*/
197-
private synchronized void decreaseNoOfRunningSchedullers() {
197+
private static synchronized void decreaseNoOfRunningSchedullers() {
198198
noOfRunningSchedullers--;
199199
}
200200

@@ -203,7 +203,7 @@ private synchronized void decreaseNoOfRunningSchedullers() {
203203
*
204204
* @return the uuid
205205
*/
206-
private synchronized String getUUID() {
206+
private static synchronized String getUUID() {
207207
return String.valueOf(UUID.randomUUID().getLeastSignificantBits());
208208
}
209209

0 commit comments

Comments
 (0)