@@ -24,6 +24,7 @@ public class ASAPServiceMessage {
2424 private byte [] message = null ;
2525 private String readableName ;
2626 private boolean persistent ;
27+ private boolean eraNotSet = false ;
2728
2829 public String toString () {
2930 StringBuilder sb = new StringBuilder ();
@@ -285,8 +286,12 @@ private void parseASAPMessage(Bundle msgData, boolean mandatory) throws ASAPExce
285286 private void parseEra (Bundle msgData , boolean mandatory ) throws ASAPException {
286287 this .era = msgData .getInt (ASAPServiceMethods .ERA_TAG , ERA_TAG_NOT_SET );
287288
288- if (mandatory && this .era == ERA_TAG_NOT_SET ) {
289- throw new ASAPException ("era must be set" );
289+ if (this .era == ERA_TAG_NOT_SET ) {
290+ if (mandatory ) throw new ASAPException ("era must be set" );
291+ else {
292+ this .eraNotSet = true ;
293+ this .era = 0 ;
294+ }
290295 }
291296 }
292297
@@ -334,8 +339,15 @@ public boolean isRecipientsListSet() {
334339
335340 public CharSequence getURI () { return this .uri ; }
336341
337- public int getEra () { return this .era ; }
338- public boolean isEraSet () { return this .era != ERA_TAG_NOT_SET ; }
342+ public int getEra () {
343+ if (this .era < 0 ) {
344+ Log .d (this .getLogStart (), "era must not be negative - replace with 0: " + this .era );
345+ this .eraNotSet = true ;
346+ this .era = 0 ;
347+ }
348+ return this .era ;
349+ }
350+ public boolean isEraSet () { return !this .eraNotSet ; }
339351
340352 public byte [] getASAPMessage () { return this .message ; }
341353 public boolean isASAPMessageSet () { return this .message != null && this .message .length > 0 ;}
0 commit comments