Skip to content

Commit 9f00aca

Browse files
authored
0.22.0
Status changs. Fix handshake with token. Fix max string size in msgpack.
1 parent 2b5c118 commit 9f00aca

File tree

11 files changed

+216
-93
lines changed

11 files changed

+216
-93
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'java'
22
apply plugin: 'maven'
33

44
group 'org.iot.dsa'
5-
version '0.21.0'
5+
version '0.22.0'
66

77
sourceCompatibility = 1.6
88
targetCompatibility = 1.6

dslink-core/src/main/java/com/acuity/iot/dsa/dslink/io/msgpack/MsgpackWriter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ private CharBuffer getCharBuffer(CharSequence arg) {
6565
tmp += 1024;
6666
}
6767
charBuffer = CharBuffer.allocate(tmp);
68-
} else if (charBuffer.length() < len) {
69-
int tmp = charBuffer.length();
68+
} else if (charBuffer.capacity() < len) {
69+
int tmp = charBuffer.capacity();
7070
while (tmp < len) {
7171
tmp += 1024;
7272
}
@@ -298,7 +298,8 @@ protected void writeNull() throws IOException {
298298

299299
private void writeString(CharSequence arg) throws IOException {
300300
CharBuffer chars = getCharBuffer(arg);
301-
ByteBuffer strBuffer = getStringBuffer(chars.position() * (int) encoder.maxBytesPerChar());
301+
ByteBuffer strBuffer = getStringBuffer(
302+
chars.length() * (int) encoder.maxBytesPerChar());
302303
encoder.encode(chars, strBuffer, false);
303304
int len = strBuffer.position();
304305
if (len < (1 << 5)) {

dslink-core/src/main/java/com/acuity/iot/dsa/dslink/protocol/v1/DS1ConnectionInit.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ void initializeConnection() throws Exception {
9898
if (in != null) {
9999
in.close();
100100
}
101+
101102
}
102103
}
103104

dslink-core/src/main/java/com/acuity/iot/dsa/dslink/protocol/v2/DS2MessageReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public int getBodyLength() {
8282
* reuse the same char buffer.
8383
*/
8484
private CharBuffer getCharBuffer(int size) {
85-
if ((charBuffer == null) || (charBuffer.length() < size)) {
85+
if ((charBuffer == null) || (charBuffer.capacity() < size)) {
8686
int tmp = 1024;
8787
while (tmp < size) {
8888
tmp += 1024;

dslink-core/src/main/java/com/acuity/iot/dsa/dslink/protocol/v2/DS2MessageWriter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ private CharBuffer getCharBuffer(CharSequence arg) {
117117
tmp += 1024;
118118
}
119119
charBuffer = CharBuffer.allocate(tmp);
120-
} else if (charBuffer.length() < len) {
121-
int tmp = charBuffer.length();
120+
} else if (charBuffer.capacity() < len) {
121+
int tmp = charBuffer.capacity();
122122
while (tmp < len) {
123123
tmp += 1024;
124124
}
@@ -245,7 +245,7 @@ public DS2MessageWriter write(DSBinaryTransport out) {
245245
public void writeString(CharSequence str) {
246246
CharBuffer chars = getCharBuffer(str);
247247
ByteBuffer strBuffer = getStringBuffer(
248-
chars.position() * (int) utf8encoder.maxBytesPerChar());
248+
chars.length() * (int) utf8encoder.maxBytesPerChar());
249249
utf8encoder.encode(chars, strBuffer, false);
250250
body.putShort((short) strBuffer.position(), false);
251251
body.put(strBuffer);
@@ -257,7 +257,7 @@ public void writeString(CharSequence str) {
257257
public void writeString(CharSequence str, DSByteBuffer buf) {
258258
CharBuffer chars = getCharBuffer(str);
259259
ByteBuffer strBuffer = getStringBuffer(
260-
chars.position() * (int) utf8encoder.maxBytesPerChar());
260+
chars.length() * (int) utf8encoder.maxBytesPerChar());
261261
utf8encoder.encode(chars, strBuffer, false);
262262
buf.putShort((short) strBuffer.position(), false);
263263
buf.put(strBuffer);

dslink-core/src/main/java/org/iot/dsa/dslink/DSLinkConfig.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,24 +168,23 @@ private DSMap getConfigMap(String name, boolean create) {
168168
map = new DSMap();
169169
setDslinkJson(map);
170170
}
171-
map = map.getMap("configs");
172-
if (map == null) {
171+
DSMap configs = map.getMap("configs");
172+
if (configs == null) {
173173
if (!create) {
174174
return null;
175175
}
176-
DSMap tmp = new DSMap();
177-
map.put("configs", tmp);
178-
map = tmp;
176+
configs = new DSMap();
177+
map.put("configs", configs);
179178
}
180-
DSMap tmp = map.getMap(name);
181-
if (tmp == null) {
179+
DSMap config = configs.getMap(name);
180+
if (config == null) {
182181
if (!create) {
183182
return null;
184183
}
185-
tmp = new DSMap();
186-
map.put(name, tmp);
184+
config = new DSMap();
185+
configs.put(name, config);
187186
}
188-
return tmp;
187+
return config;
189188
}
190189

191190
public String getDsaVersion() {
@@ -531,6 +530,7 @@ public DSLinkConfig setMainType(Class clazz) {
531530
* Overrides dslink.json.
532531
*/
533532
public DSLinkConfig setToken(String arg) {
533+
token = arg;
534534
return setConfig(CFG_AUTH_TOKEN, arg);
535535
}
536536

0 commit comments

Comments
 (0)