From 71d045d69f68cc66b63b29d371a5c98f9363066a Mon Sep 17 00:00:00 2001 From: Faye Duxovni Date: Thu, 9 Jun 2022 02:11:09 -0400 Subject: [PATCH] Set valid default value for tsourcepos in v1.23 ParsedLedgerTransaction If tsourcepos is an empty list, attempting to add a transaction will be rejected by the server, which is expecting a pair of values. This sets it to a well-formed default value which the server will accept. --- .../mobileledger/json/v1_23/ParsedLedgerTransaction.java | 6 ++++++ .../net/ktnx/mobileledger/json/v1_23/ParsedSourcePos.java | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/ktnx/mobileledger/json/v1_23/ParsedLedgerTransaction.java b/app/src/main/java/net/ktnx/mobileledger/json/v1_23/ParsedLedgerTransaction.java index fe0a2809..59d17635 100644 --- a/app/src/main/java/net/ktnx/mobileledger/json/v1_23/ParsedLedgerTransaction.java +++ b/app/src/main/java/net/ktnx/mobileledger/json/v1_23/ParsedLedgerTransaction.java @@ -43,6 +43,12 @@ public class ParsedLedgerTransaction implements net.ktnx.mobileledger.json.Parse private List> ttags = new ArrayList<>(); private List tsourcepos = new ArrayList<>(); public ParsedLedgerTransaction() { + ParsedSourcePos startPos = new ParsedSourcePos(); + ParsedSourcePos endPos = new ParsedSourcePos(); + endPos.setSourceLine(2); + + tsourcepos.add(startPos); + tsourcepos.add(endPos); } public static ParsedLedgerTransaction fromLedgerTransaction(LedgerTransaction tr) { ParsedLedgerTransaction result = new ParsedLedgerTransaction(); diff --git a/app/src/main/java/net/ktnx/mobileledger/json/v1_23/ParsedSourcePos.java b/app/src/main/java/net/ktnx/mobileledger/json/v1_23/ParsedSourcePos.java index 6a62f8dd..b3ea5db6 100644 --- a/app/src/main/java/net/ktnx/mobileledger/json/v1_23/ParsedSourcePos.java +++ b/app/src/main/java/net/ktnx/mobileledger/json/v1_23/ParsedSourcePos.java @@ -18,9 +18,9 @@ package net.ktnx.mobileledger.json.v1_23; class ParsedSourcePos { - private String sourceName; - private int sourceLine; - private int sourceColumn; + private String sourceName = ""; + private int sourceLine = 1; + private int sourceColumn = 1; public ParsedSourcePos() { } public String getSourceName() { -- 2.39.5