Skip to content

Commit 046163e

Browse files
authored
Merge branch 'main' into timeout-duration
2 parents a5e1a4d + 2feb378 commit 046163e

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

datadictionary/datadictionary.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ func Parse(path string) (*DataDictionary, error) {
315315
func ParseSrc(xmlSrc io.Reader) (*DataDictionary, error) {
316316
doc := new(XMLDoc)
317317
decoder := xml.NewDecoder(xmlSrc)
318+
decoder.CharsetReader = func(encoding string, input io.Reader) (io.Reader, error) {
319+
return input, nil
320+
}
321+
318322
if err := decoder.Decode(doc); err != nil {
319323
return nil, errors.Wrapf(err, "problem parsing XML file")
320324
}

filestore.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os"
2323
"path"
2424
"strconv"
25+
"strings"
2526
"time"
2627

2728
"github.com/pkg/errors"
@@ -213,15 +214,15 @@ func (store *fileStore) populateCache() (creationTimePopulated bool, err error)
213214
}
214215

215216
if senderSeqNumBytes, err := ioutil.ReadFile(store.senderSeqNumsFname); err == nil {
216-
if senderSeqNum, err := strconv.Atoi(string(senderSeqNumBytes)); err == nil {
217+
if senderSeqNum, err := strconv.Atoi(strings.Trim(string(senderSeqNumBytes), "\r\n")); err == nil {
217218
if err = store.cache.SetNextSenderMsgSeqNum(senderSeqNum); err != nil {
218219
return creationTimePopulated, errors.Wrap(err, "cache set next sender")
219220
}
220221
}
221222
}
222223

223224
if targetSeqNumBytes, err := ioutil.ReadFile(store.targetSeqNumsFname); err == nil {
224-
if targetSeqNum, err := strconv.Atoi(string(targetSeqNumBytes)); err == nil {
225+
if targetSeqNum, err := strconv.Atoi(strings.Trim(string(targetSeqNumBytes), "\r\n")); err == nil {
225226
if err = store.cache.SetNextTargetMsgSeqNum(targetSeqNum); err != nil {
226227
return creationTimePopulated, errors.Wrap(err, "cache set next target")
227228
}

filestore_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ import (
1919
"fmt"
2020
"os"
2121
"path"
22+
"strconv"
2223
"strings"
2324
"testing"
2425
"time"
2526

27+
assert2 "github.com/stretchr/testify/assert"
2628
"github.com/stretchr/testify/require"
2729
"github.com/stretchr/testify/suite"
2830
)
@@ -62,3 +64,14 @@ func (suite *FileStoreTestSuite) TearDownTest() {
6264
func TestFileStoreTestSuite(t *testing.T) {
6365
suite.Run(t, new(FileStoreTestSuite))
6466
}
67+
68+
func TestStringParse(t *testing.T) {
69+
assert := assert2.New(t)
70+
i, err := strconv.Atoi(strings.Trim("00005\n", "\r\n"))
71+
assert.Nil(err)
72+
assert.Equal(5, i)
73+
74+
i, err = strconv.Atoi(strings.Trim("00006\r", "\r\n"))
75+
assert.Nil(err)
76+
assert.Equal(6, i)
77+
}

validation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ func validateVisitGroupField(fieldDef *datadictionary.FieldDef, fieldStack []Tag
246246
if childDefs[0].Required() {
247247
return fieldStack, RequiredTagMissing(Tag(childDefs[0].Tag()))
248248
}
249+
fieldStack = fieldStack[1:]
249250
}
250251

251252
childDefs = childDefs[1:]

0 commit comments

Comments
 (0)