| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9b965e2 commit 136b3ed
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,7 @@ plugins { | |||
| 3 | 3 | id "jacoco" | |
| 4 | 4 | id "maven-publish" | |
| 5 | 5 | id "signing" | |
| 6 | - id "com.github.spotbugs" version "5.0.0" | ||
| 6 | + id "com.github.spotbugs" version "6.4.8" | ||
| 7 | 7 | id "org.sonarqube" version "2.7.1" | |
| 8 | 8 | } | |
| 9 | 9 | ||
@@ -177,6 +177,7 @@ signing { | |||
| 177 | 177 | } | |
| 178 | 178 | ||
| 179 | 179 | spotbugsMain { | |
| 180 | + excludeFilter = file("spotbugs-exclude.xml") | ||
| 180 | 181 | reports { | |
| 181 | 182 | xml.required.set(true) | |
| 182 | 183 | html.required.set(true) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | + <FindBugsFilter> | ||
| 3 | + <Match> | ||
| 4 | + <Bug code="EI,EI2" /> | ||
| 5 | + </Match> | ||
| 6 | + <Match> | ||
| 7 | + <Class name="ch.loway.oss.ari4java.tools.http.NettyHttpClient" /> | ||
| 8 | + <Or> | ||
| 9 | + <Method name="setAutoReconnect" /> | ||
| 10 | + <Method name="setMaxReconnectCount" /> | ||
| 11 | + </Or> | ||
| 12 | + <Bug code="AT" /> | ||
| 13 | + </Match> | ||
| 14 | + </FindBugsFilter> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,9 +30,10 @@ public class ARI { | |||
| 30 | 30 | private HttpClient httpClient; | |
| 31 | 31 | private WsClient wsClient; | |
| 32 | 32 | private ActionEvents liveActionEvent = null; | |
| 33 | - private AriSubscriber subscriptions = new AriSubscriber(); | ||
| 33 | + private final AriSubscriber subscriptions = new AriSubscriber(); | ||
| 34 | 34 | private final CopyOnWriteArrayList<BaseAriAction> liveActionList = new CopyOnWriteArrayList<>(); | |
| 35 | - private static Logger logger = LoggerFactory.getLogger(ARI.class); | ||
| 35 | + private static final Logger logger = LoggerFactory.getLogger(ARI.class); | ||
| 36 | + private static final SecureRandom random = new SecureRandom(); | ||
| 36 | 37 | ||
| 37 | 38 | /** | |
| 38 | 39 | * Sets the client | |
@@ -469,7 +470,6 @@ public static void sleep(long ms) { | |||
| 469 | 470 | public static String getUID() { | |
| 470 | 471 | StringBuilder sb = new StringBuilder(20); | |
| 471 | 472 | sb.append("a4j"); | |
| 472 | - SecureRandom random = new SecureRandom(); | ||
| 473 | 473 | for (int n = 0; n < 15; n++) { | |
| 474 | 474 | if ((n % 5) == 0) { | |
| 475 | 475 | sb.append("."); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ | |||
| 9 | 9 | import java.util.Arrays; | |
| 10 | 10 | import java.util.Map; | |
| 11 | 11 | ||
| 12 | - public class HTTPLogger { | ||
| 12 | + public final class HTTPLogger { | ||
| 13 | 13 | ||
| 14 | 14 | private HTTPLogger() { | |
| 15 | 15 | throw new IllegalStateException("Utility class"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,7 @@ | |||
| 35 | 35 | import java.net.URISyntaxException; | |
| 36 | 36 | import java.util.List; | |
| 37 | 37 | import java.util.concurrent.TimeUnit; | |
| 38 | + import java.util.concurrent.atomic.AtomicInteger; | ||
| 38 | 39 | ||
| 39 | 40 | /** | |
| 40 | 41 | * HTTP and WebSocket client implementation based on netty.io. | |
@@ -71,7 +72,7 @@ public class NettyHttpClient implements HttpClient, WsClient { | |||
| 71 | 72 | private String wsEventsUrl; | |
| 72 | 73 | private List<HttpParam> wsEventsParamQuery; | |
| 73 | 74 | private WsClientConnection wsClientConnection; | |
| 74 | - private int reconnectCount = 0; | ||
| 75 | + private final AtomicInteger reconnectCount = new AtomicInteger(0); | ||
| 75 | 76 | private int maxReconnectCount = 10; // -1 = infinite reconnect attempts | |
| 76 | 77 | private ChannelFuture wsChannelFuture; | |
| 77 | 78 | private ScheduledFuture<?> wsPingTimer = null; | |
@@ -481,7 +482,7 @@ public void operationComplete(ChannelFuture future) throws Exception { | |||
| 481 | 482 | logger.debug("WS connected..."); | |
| 482 | 483 | // start a ping and reset reconnect counter | |
| 483 | 484 | startPing(); | |
| 484 | - reconnectCount = 0; | ||
| 485 | + reconnectCount.set(0); | ||
| 485 | 486 | if (!group.isShuttingDown()) { | |
| 486 | 487 | group.execute(callback::onChReadyToWrite); | |
| 487 | 488 | } | |
@@ -612,7 +613,7 @@ public void reconnectWs(Throwable cause) { | |||
| 612 | 613 | wsPingTimer = null; | |
| 613 | 614 | } | |
| 614 | 615 | ||
| 615 | - if (!autoReconnect || (maxReconnectCount > -1 && reconnectCount >= maxReconnectCount)) { | ||
| 616 | + if (!autoReconnect || (maxReconnectCount > -1 && reconnectCount.get() >= maxReconnectCount)) { | ||
| 616 | 617 | logger.warn("Cannot connect: {} - executing failure callback", cause.getMessage()); | |
| 617 | 618 | if (!group.isShuttingDown()) { | |
| 618 | 619 | group.execute(() -> wsCallback.onFailure(cause)); | |
@@ -624,9 +625,9 @@ public void reconnectWs(Throwable cause) { | |||
| 624 | 625 | if (!group.isShuttingDown()) { | |
| 625 | 626 | // schedule reconnect after a 2,5,10 seconds | |
| 626 | 627 | long[] timeouts = {2L, 5L, 10L}; | |
| 627 | - long timeout = reconnectCount >= timeouts.length ? timeouts[timeouts.length - 1] : timeouts[reconnectCount]; | ||
| 628 | - reconnectCount++; | ||
| 629 | - logger.error("WS Connect Error: {}, reconnecting in {} seconds... try: {}", cause.getMessage(), timeout, reconnectCount); | ||
| 628 | + long timeout = reconnectCount.get() >= timeouts.length ? timeouts[timeouts.length - 1] : timeouts[reconnectCount.get()]; | ||
| 629 | + reconnectCount.incrementAndGet(); | ||
| 630 | + logger.error("WS Connect Error: {}, reconnecting in {} seconds... try: {}", cause.getMessage(), timeout, reconnectCount.get()); | ||
| 630 | 631 | shutDownGroup.schedule(() -> { | |
| 631 | 632 | try { | |
| 632 | 633 | // 1st close up | |
| Back | FazBrowse Home | New Git URL |
0 commit comments