Skip to content

Commit 55c48ab

Browse files
authored
0.66.1
- Fix enum range encoding / decoding - Fix connection reconnect timing - Suppress redundant reconnect failure logging - Update gradle wrapper
2 parents d074ad1 + 1995989 commit 55c48ab

File tree

12 files changed

+48
-58
lines changed

12 files changed

+48
-58
lines changed

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ subprojects {
55
apply plugin: 'maven'
66

77
group 'org.iot-dsa'
8-
version '0.66.0'
8+
version '0.66.1'
99

1010
targetCompatibility = JavaVersion.VERSION_1_8
1111
sourceCompatibility = JavaVersion.VERSION_1_8
@@ -27,12 +27,12 @@ subprojects {
2727
}
2828

2929
task sourcesJar(group: 'build', type: Jar, dependsOn: classes) {
30-
classifier = 'sources'
30+
archiveClassifier = 'sources'
3131
from sourceSets.main.allJava
3232
}
3333

3434
task javadocJar(type: Jar, dependsOn: javadoc) {
35-
classifier = 'javadoc'
35+
archiveClassifier = 'javadoc'
3636
from javadoc.destinationDir
3737
}
3838

@@ -60,5 +60,5 @@ allprojects {
6060
}
6161

6262
wrapper {
63-
gradleVersion = '5.5.1'
63+
gradleVersion = '5.6'
6464
}

dslink-v2-api/src/main/java/org/iot/dsa/conn/DSBaseConnection.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ protected boolean canConnect() {
9494
configOk();
9595
return true;
9696
} catch (Throwable x) {
97-
debug(debug() ? getPath() : null, x);
98-
configFault(DSException.makeMessage(x));
97+
if (!fault) {
98+
debug(x);
99+
configFault(DSException.makeMessage(x));
100+
}
99101
}
100102
return false;
101103
}

dslink-v2-api/src/main/java/org/iot/dsa/conn/DSConnection.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public abstract class DSConnection extends DSBaseConnection {
6363
// Instance Fields
6464
///////////////////////////////////////////////////////////////////////////
6565

66+
private long lastConnectAttempt = 0;
6667
private long lastPing;
6768
private long retryConnectMs = 0;
6869
protected DSInfo state = getInfo(STATE);
@@ -375,12 +376,13 @@ protected void updateState() {
375376
debug(debug() ? getPath() : null, x);
376377
}
377378
}
378-
} else {
379-
if (isEnabled() && getConnectionState().isDisconnected()) {
380-
if (getTimeInState() >= retryConnectMs) {
381-
retryConnectMs = Math.min(60000, retryConnectMs + getUpdateInterval());
382-
connect();
383-
}
379+
} else if (isEnabled() && getConnectionState().isDisconnected()) {
380+
long now = System.currentTimeMillis();
381+
long millis = now - lastConnectAttempt;
382+
if (millis >= retryConnectMs) {
383+
lastConnectAttempt = now;
384+
retryConnectMs = Math.min(60000, retryConnectMs + getUpdateInterval());
385+
connect();
384386
}
385387
}
386388
} finally {

dslink-v2-api/src/main/java/org/iot/dsa/logging/DSLogger.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public boolean debug() {
8383
* Log a finer message.
8484
*/
8585
public void debug(Object msg) {
86+
if (msg instanceof Throwable) {
87+
debug(null, (Throwable) msg);
88+
}
8689
if (msg != null) {
8790
getLogger().log(debug, string(msg));
8891
}
@@ -124,6 +127,9 @@ public boolean error() {
124127
* Log a severe message.
125128
*/
126129
public void error(Object msg) {
130+
if (msg instanceof Throwable) {
131+
error(null, (Throwable) msg);
132+
}
127133
if (msg != null) {
128134
getLogger().log(error, string(msg));
129135
}
@@ -172,6 +178,9 @@ public boolean info() {
172178
* Log an infrequent major lifecycle event.
173179
*/
174180
public void info(Object msg) {
181+
if (msg instanceof Throwable) {
182+
info(null, (Throwable) msg);
183+
}
175184
if (msg != null) {
176185
getLogger().log(info, string(msg));
177186
}
@@ -213,6 +222,9 @@ public boolean trace() {
213222
* Log a trace or verbose event.
214223
*/
215224
public void trace(Object msg) {
225+
if (msg instanceof Throwable) {
226+
trace(null, (Throwable) msg);
227+
}
216228
if (msg != null) {
217229
getLogger().log(trace, string(msg));
218230
}
@@ -261,6 +273,9 @@ public boolean warn() {
261273
* Log a trace or verbose event.
262274
*/
263275
public void warn(Object msg) {
276+
if (msg instanceof Throwable) {
277+
warn(null, (Throwable) msg);
278+
}
264279
if (msg != null) {
265280
getLogger().log(warn, string(msg));
266281
}

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/responder/DSInboundList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ private void fixRangeTypes(DSMap arg) {
648648
String type = arg.getString(DSMetadata.TYPE);
649649
if ("bool".equals(type)) {
650650
DSList range = (DSList) arg.remove(DSMetadata.BOOLEAN_RANGE);
651-
if ((range != null) || (range.size() == 2)) {
651+
if ((range != null) && (range.size() == 2)) {
652652
String utf8 = DSString.UTF8.toString();
653653
cacheBuf.setLength(0);
654654
cacheBuf.append(type);

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/v1/DS1LinkConnection.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ protected DSTransport makeTransport() {
112112
@Override
113113
protected void onStarted() {
114114
super.onStarted();
115-
setBrokerUri(makeHandshakeUri());
115+
String uri = makeHandshakeUri();
116+
if (uri != null) {
117+
setBrokerUri(uri);
118+
}
116119
debug(debug() ? "Broker URI " + getBrokerUri() : null);
117120
}
118121

@@ -175,7 +178,10 @@ private String makeHandshakeUri() {
175178
StringBuilder builder = new StringBuilder();
176179
DSLink link = getLink();
177180
String uri = link.getOptions().getBrokerUri();
178-
if ((uri == null) || uri.isEmpty() || !uri.contains("://")) {
181+
if ((uri == null) || uri.isEmpty()) {
182+
return null;
183+
}
184+
if (!uri.contains("://")) {
179185
throw new IllegalArgumentException("Invalid broker uri: " + uri);
180186
}
181187
builder.append(uri);

dslink-v2/src/test/java/org/iot/dsa/dslink/RequesterSubscriptionsReconnectTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private void doit(DSLink link) throws Exception {
3838
Assert.assertTrue(link.getConnection().isConnected());
3939
DSIRequester requester = link.getConnection().getRequester();
4040
requester.subscribe("/main/abc", DSLong.valueOf(0), new MyHandler());
41-
long end = System.currentTimeMillis() + 10000;
41+
long end = System.currentTimeMillis() + 15000;
4242
synchronized (mutex) {
4343
while (((testStatus == null) || (!testStatus.isOk()))
4444
&& (System.currentTimeMillis() < end)) {
@@ -49,12 +49,12 @@ private void doit(DSLink link) throws Exception {
4949
testStatus = null;
5050
link.getConnection().setEnabled(false);
5151
link.getConnection().disconnect();
52-
end = System.currentTimeMillis() + 10000;
52+
end = System.currentTimeMillis() + 15000;
5353
while (link.getConnection().isConnected() && (System.currentTimeMillis() < end)) {
5454
mutex.wait(100);
5555
}
5656
Assert.assertFalse(link.getConnection().isConnected());
57-
end = System.currentTimeMillis() + 10000;
57+
end = System.currentTimeMillis() + 15000;
5858
synchronized (mutex) {
5959
while (((testStatus == null) || (!testStatus.isDown()))
6060
&& (System.currentTimeMillis() < end)) {
@@ -65,9 +65,9 @@ private void doit(DSLink link) throws Exception {
6565
testStatus = null;
6666
link.getConnection().setEnabled(true);
6767
link.getConnection().connect();
68-
link.getConnection().waitForConnection(10000);
68+
link.getConnection().waitForConnection(15000);
6969
Assert.assertTrue(link.getConnection().isConnected());
70-
end = System.currentTimeMillis() + 10000;
70+
end = System.currentTimeMillis() + 15000;
7171
synchronized (mutex) {
7272
while (((testStatus == null) || (!testStatus.isOk()))
7373
&& (System.currentTimeMillis() < end)) {

dslink-v2/src/test/java/org/iot/dsa/dslink/StreamTableTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ public class StreamTableTest {
2727
// Fields
2828
// ------
2929

30-
private static boolean success = false;
31-
3230
// Methods
3331
// -------
3432

@@ -39,7 +37,6 @@ public void test() throws Exception {
3937
}
4038

4139
private void doit(DSLink link) throws Exception {
42-
success = false;
4340
Thread t = new Thread(link, "DSLink Runner");
4441
t.start();
4542
link.getConnection().waitForConnection(5000);

gradle/wrapper/gradle-wrapper.jar

-426 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)