Skip to content

Commit a247c83

Browse files
committed
Fix: duplicate of HeaderOptions with request tag
1 parent fa5f36c commit a247c83

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

coap-core/src/main/java/com/mbed/coap/packet/HeaderOptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ public HeaderOptions duplicate() {
199199
opts.block2Res = block2Res;
200200
opts.size2Res = size2Res;
201201
opts.echo = echo;
202+
opts.requestTag = requestTag;
202203

203204
return opts;
204205
}

coap-core/src/test/java/com/mbed/coap/packet/HeaderOptionsTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ public void testMultipleHeaders() throws IOException, CoapException {
9191
hdr.setUriHost("uri-host");
9292
hdr.setUriPort(5683);
9393
hdr.setUriQuery("par1=dupa&par2=dupa2");
94-
hdr.setEcho(decodeHex("0102030405060708090a"));
95-
hdr.setRequestTag(Opaque.of("tag-0001"));
9694
hdr.put(36, Opaque.variableUInt((1357)));
9795

9896
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -105,6 +103,8 @@ public void testMultipleHeaders() throws IOException, CoapException {
105103
System.out.println(hdr2);
106104
assertTrue(hdr.equals(hdr2));
107105

106+
// duplicate
107+
assertEquals(hdr, hdr.duplicate());
108108
}
109109

110110
@Test
@@ -171,13 +171,17 @@ public void testMultipleExHeaders() throws IOException, CoapException {
171171
hdr.setBlock1Req(new BlockOption(2, BlockSize.S_16, true));
172172
hdr.setBlock2Res(new BlockOption(4, BlockSize.S_1024, false));
173173
hdr.setObserve(4321);
174+
hdr.setEcho(decodeHex("0102030405060708090a"));
175+
hdr.setRequestTag(Opaque.of("tag-0001"));
174176

175177
HeaderOptions hdr2 = deserialize(serialize(hdr));
176178

177179
System.out.println(hdr);
178180
System.out.println(hdr2);
179-
assertTrue(hdr.equals(hdr2));
181+
assertEquals(hdr, hdr2);
180182

183+
// duplicate
184+
assertEquals(hdr, hdr.duplicate());
181185
}
182186

183187
@Test

0 commit comments

Comments
 (0)