Skip to content

Commit c443e80

Browse files
committed
deal with this era problem - must not be null but can be a mandatory parameter anyway...
1 parent 4e06df5 commit c443e80

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/net/sharksystem/asap/protocol/ASAP_Modem_Impl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,23 @@ public class ASAP_Modem_Impl implements ASAP_1_0 {
2020
public void offer(CharSequence peer, CharSequence format, CharSequence channel, int era,
2121
OutputStream os, boolean signed) throws IOException, ASAPException {
2222

23+
if(era < 0) throw new ASAPException("era must be a non-negative value: " + era);
2324
OfferPDU_Impl.sendPDU(peer, format, channel, era, os, signed);
2425
}
2526

2627
@Override
2728
public void offer(CharSequence peer, CharSequence format, CharSequence channel,
2829
OutputStream os, boolean signed) throws IOException, ASAPException {
29-
this.offer(peer, format, channel, -1, os, signed);
30+
this.offer(peer, format, channel, 0, os, signed);
3031
}
3132

3233
@Override
3334
public void interest(CharSequence peer, CharSequence sourcePeer, CharSequence format,
3435
CharSequence channel, int eraFrom, int eraTo, OutputStream os, boolean signed)
3536
throws IOException, ASAPException {
3637

38+
// TODO - should throw an exception!
39+
//if(eraFrom < 0 || eraTo < 0) throw new ASAPException("era must be a non-negative value: from|to): " + eraFrom + "|" + eraTo);
3740
InterestPDU_Impl.sendPDU(peer, sourcePeer, format, channel, eraFrom, eraTo, os, signed);
3841
}
3942

@@ -58,6 +61,7 @@ public void assimilate(CharSequence peer, CharSequence recipientPeer, CharSequen
5861
OutputStream os, boolean signed) throws IOException, ASAPException {
5962

6063
if(data == null || data.length == 0) throw new ASAPException("data must not be null");
64+
if(era < 0) throw new ASAPException("era must be a non-negative value: " + era);
6165

6266
this.assimilate(peer, recipientPeer, format, channel, era, data.length, offsets,
6367
new ByteArrayInputStream(data), os, signed);

0 commit comments

Comments
 (0)