Skip to content

Commit 42d44d4

Browse files
authored
0.75.2
* Fix sending first message on connect. * Increase buffer sizes in small increments to decrease changes of OOM. * Lock Tyrus dependencies at 1.16 for now.
2 parents 475b50c + 45be819 commit 42d44d4

File tree

11 files changed

+39
-14
lines changed

11 files changed

+39
-14
lines changed

build.gradle

+1-1
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.75.1'
8+
version '0.75.2'
99

1010
targetCompatibility = JavaVersion.VERSION_1_8
1111
sourceCompatibility = JavaVersion.VERSION_1_8

dslink-v2-websocket/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependencies {
22
api project(':dslink-v2')
3-
implementation 'org.glassfish.tyrus.bundles:tyrus-standalone-client:[1.15,)'
3+
implementation 'org.glassfish.tyrus.bundles:tyrus-standalone-client:1.16'
44
}
55

66
artifacts {

dslink-v2/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dependencies {
22
api project(':dslink-v2-api')
3-
compileOnly 'org.glassfish.tyrus.bundles:tyrus-standalone-client:[1.15,)'
4-
testImplementation 'org.glassfish.tyrus.bundles:tyrus-standalone-client:[1.15,)'
3+
compileOnly 'org.glassfish.tyrus.bundles:tyrus-standalone-client:1.16'
4+
testImplementation 'org.glassfish.tyrus.bundles:tyrus-standalone-client:1.16'
55
testImplementation 'org.testng:testng:+'
66
testImplementation 'org.openjdk.jmh:jmh-core:+'
77
testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:+'

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/io/DSByteBuffer.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,11 @@ public byte[] toByteArray() {
618618
private void growBuffer(int minSize) {
619619
int size = buffer.length;
620620
while (size < minSize) {
621-
size *= 2;
621+
if (size < 1000000) {
622+
size *= 2;
623+
} else {
624+
size += 1000000;
625+
}
622626
}
623627
byte[] tmp = new byte[size];
624628
System.arraycopy(buffer, offset, tmp, 0, length);

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/io/DSCharBuffer.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ public int read(char[] buf, int off, int len) {
153153
private void growBuffer(int minSize) {
154154
int size = buffer.length;
155155
while (size < minSize) {
156-
size *= 2;
156+
if (size < 1000000) {
157+
size *= 2;
158+
} else {
159+
size += 1000000;
160+
}
157161
}
158162
char[] tmp = new char[size];
159163
System.arraycopy(buffer, offset, tmp, 0, length);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void close() {
9595
@Override
9696
public void close(Exception reason) {
9797
if (isOpen()) {
98-
getResponder().sendError(this, reason);
98+
getResponder().sendError(this, reason, false);
9999
}
100100
close();
101101
}

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ public DSStream removeRequest(Integer rid) {
9797

9898
public abstract void sendClose(int rid);
9999

100-
public abstract void sendError(DSInboundRequest req, Throwable reason);
100+
public void sendError(DSInboundRequest req, Throwable reason) {
101+
sendError(req, reason, true);
102+
}
103+
104+
public abstract void sendError(DSInboundRequest req, Throwable reason, boolean close);
101105

102106
public void sendResponse(OutboundMessage res) {
103107
session.enqueueOutgoingResponse(res);

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

+2
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ protected boolean hasPingToSend() {
125125
@Override
126126
protected void onConnected() {
127127
super.onConnected();
128+
lastMessageSent = 0;
128129
setRequesterAllowed(true); //Rick says Dart broker doesn't send this
129130
requester.onConnected();
130131
responder.onConnected();
132+
sendMessage();
131133
}
132134

133135
@Override

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ public void sendClose(int rid) {
128128
}
129129

130130
@Override
131-
public void sendError(DSInboundRequest req, Throwable reason) {
132-
sendResponse(new ErrorMessage(req.getRequestId(), reason));
131+
public void sendError(DSInboundRequest req, Throwable reason, boolean close) {
132+
sendResponse(new ErrorMessage(req.getRequestId(), reason).setClose(close));
133133
}
134134

135135
public void sendError(int rid, Throwable reason) {

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

+14-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
class ErrorMessage implements OutboundMessage {
1919

2020
private static String SERVER_ERROR = "serverError";
21+
22+
private boolean close = true;
2123
private String message;
2224
private Integer rid;
2325
private String type = SERVER_ERROR;
@@ -46,6 +48,14 @@ public boolean canWrite(DSSession session) {
4648
return true;
4749
}
4850

51+
/**
52+
* Whether or not to close the stream.
53+
*/
54+
public ErrorMessage setClose(boolean close) {
55+
this.close = close;
56+
return this;
57+
}
58+
4959
public ErrorMessage setType(String type) {
5060
this.type = type;
5161
return this;
@@ -54,9 +64,10 @@ public ErrorMessage setType(String type) {
5464
@Override
5565
public boolean write(DSSession session, MessageWriter writer) {
5666
DSIWriter out = writer.getWriter();
57-
out.beginMap()
58-
.key("rid").value(rid)
59-
.key("stream").value("closed");
67+
out.beginMap().key("rid").value(rid);
68+
if (close) {
69+
out.key("stream").value("closed");
70+
}
6071
out.key("error").beginMap()
6172
.key("type").value(type)
6273
.key("msg").value(message)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void sendClose(int rid) {
8383
}
8484

8585
@Override
86-
public void sendError(DSInboundRequest req, Throwable reason) {
86+
public void sendError(DSInboundRequest req, Throwable reason, boolean close) {
8787
sendResponse(new ErrorMessage(req, reason));
8888
}
8989

0 commit comments

Comments
 (0)