You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/05/04 13:31:33 UTC
[plc4x] branch develop updated: refactor(plc4go): code QC
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new 61a7ff02d1 refactor(plc4go): code QC
61a7ff02d1 is described below
commit 61a7ff02d10a6bf13caad64f572c4327b84db6c0
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu May 4 15:31:25 2023 +0200
refactor(plc4go): code QC
---
plc4go/internal/ads/Browser.go | 2 +-
plc4go/internal/ads/Connection.go | 2 +-
plc4go/internal/ads/DriverContext.go | 2 +-
plc4go/internal/ads/TagHandler.go | 18 ++++++++---------
plc4go/internal/ads/TagHandler_test.go | 30 ++++++++++++++--------------
plc4go/internal/ads/Writer.go | 2 +-
plc4go/internal/cbus/Query.go | 2 +-
plc4go/internal/cbus/Query_test.go | 2 +-
plc4go/internal/cbus/Tag.go | 14 ++++++-------
plc4go/internal/cbus/Tag_test.go | 14 ++++++-------
plc4go/internal/modbus/Tag.go | 2 +-
plc4go/internal/s7/Tag.go | 2 +-
plc4go/internal/simulated/Tag.go | 2 +-
plc4go/spi/RequestTransactionManager_test.go | 5 -----
plc4go/spi/Tracer.go | 24 ++++++++--------------
plc4go/spi/default/DefaultCodec_test.go | 6 +++---
plc4go/spi/model/DefaultArrayInfo.go | 6 +++---
plc4go/spi/model/DefaultPlcDiscoveryItem.go | 2 +-
plc4go/spi/utils/Misc_test.go | 2 +-
plc4go/spi/utils/WorkerPool_test.go | 3 ++-
plc4go/spi/values/PlcWCHAR.go | 4 ++--
plc4go/spi/values/PlcWSTRING.go | 4 ++--
22 files changed, 69 insertions(+), 81 deletions(-)
diff --git a/plc4go/internal/ads/Browser.go b/plc4go/internal/ads/Browser.go
index bb4b2a8c80..04ed5e7117 100644
--- a/plc4go/internal/ads/Browser.go
+++ b/plc4go/internal/ads/Browser.go
@@ -108,7 +108,7 @@ func (m *Connection) filterDataTypes(parentName string, currentType driverModel.
if len(remainingAddressSegments) == 0 {
arrayInfo := []apiModel.ArrayInfo{}
for _, ai := range currentType.GetArrayInfo() {
- arrayInfo = append(arrayInfo, internalModel.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &internalModel.DefaultArrayInfo{
LowerBound: ai.GetLowerBound(),
UpperBound: ai.GetUpperBound(),
})
diff --git a/plc4go/internal/ads/Connection.go b/plc4go/internal/ads/Connection.go
index 121b0ceab3..e63e936a97 100644
--- a/plc4go/internal/ads/Connection.go
+++ b/plc4go/internal/ads/Connection.go
@@ -319,7 +319,7 @@ func (m *Connection) resolveSymbolicAddress(ctx context.Context, addressParts []
if len(addressParts) == 0 {
var arrayInfo []apiModel.ArrayInfo
for _, adsArrayInfo := range curDataType.GetArrayInfo() {
- arrayInfo = append(arrayInfo, internalModel.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &internalModel.DefaultArrayInfo{
LowerBound: adsArrayInfo.GetLowerBound(),
UpperBound: adsArrayInfo.GetUpperBound(),
})
diff --git a/plc4go/internal/ads/DriverContext.go b/plc4go/internal/ads/DriverContext.go
index edae1f4065..19bdc1302c 100644
--- a/plc4go/internal/ads/DriverContext.go
+++ b/plc4go/internal/ads/DriverContext.go
@@ -163,7 +163,7 @@ func (m *DriverContext) getArrayInfoForDataTypeTableEntry(entry driverModel.AdsD
LowerBound: adsArrayInfo.GetLowerBound(),
UpperBound: adsArrayInfo.GetUpperBound(),
}
- arrayInfos = append(arrayInfos, arrayInfo)
+ arrayInfos = append(arrayInfos, &arrayInfo)
}
return arrayInfos
}
diff --git a/plc4go/internal/ads/TagHandler.go b/plc4go/internal/ads/TagHandler.go
index 70c1ba1784..f21f77fc88 100644
--- a/plc4go/internal/ads/TagHandler.go
+++ b/plc4go/internal/ads/TagHandler.go
@@ -140,7 +140,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: endElement,
})
@@ -153,7 +153,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: startElement + numElements,
})
@@ -162,7 +162,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
LowerBound: 0,
UpperBound: numElements,
})
@@ -240,7 +240,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: endElement,
})
@@ -253,7 +253,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: startElement + numElements,
})
@@ -262,7 +262,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
LowerBound: 0,
UpperBound: numElements,
})
@@ -295,7 +295,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: endElement,
})
@@ -308,7 +308,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
LowerBound: startElement,
UpperBound: startElement + numElements,
})
@@ -317,7 +317,7 @@ func (m TagHandler) ParseTag(query string) (apiModel.PlcTag, error) {
if err != nil {
return nil, fmt.Errorf("error parsing array info: %s, got error: %v", currentSegment, err)
}
- arrayInfo = append(arrayInfo, model2.DefaultArrayInfo{
+ arrayInfo = append(arrayInfo, &model2.DefaultArrayInfo{
LowerBound: 0,
UpperBound: numElements,
})
diff --git a/plc4go/internal/ads/TagHandler_test.go b/plc4go/internal/ads/TagHandler_test.go
index 8e487af9da..52434ae45d 100644
--- a/plc4go/internal/ads/TagHandler_test.go
+++ b/plc4go/internal/ads/TagHandler_test.go
@@ -113,7 +113,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 0,
UpperBound: 42,
},
@@ -133,7 +133,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 0,
UpperBound: 42,
},
@@ -153,7 +153,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 0,
UpperBound: 42,
},
@@ -173,7 +173,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 0,
UpperBound: 42,
},
@@ -193,7 +193,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.SymbolicPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 0,
UpperBound: 42,
},
@@ -211,7 +211,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 42,
},
@@ -231,7 +231,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 42,
},
@@ -251,7 +251,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 42,
},
@@ -271,7 +271,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 42,
},
@@ -291,7 +291,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.SymbolicPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 42,
},
@@ -309,7 +309,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 65,
},
@@ -329,7 +329,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 65,
},
@@ -349,7 +349,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 65,
},
@@ -369,7 +369,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.DirectPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 65,
},
@@ -389,7 +389,7 @@ func TestTagHandler_ParseQuery(t *testing.T) {
want: model2.SymbolicPlcTag{
PlcTag: model2.PlcTag{
ArrayInfo: []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 23,
UpperBound: 65,
},
diff --git a/plc4go/internal/ads/Writer.go b/plc4go/internal/ads/Writer.go
index 7634c6d130..a628f43f91 100644
--- a/plc4go/internal/ads/Writer.go
+++ b/plc4go/internal/ads/Writer.go
@@ -320,7 +320,7 @@ func (m *Connection) serializePlcValue(dataType driverModel.AdsDataTypeTableEntr
}
var childArrayInfo []apiModel.ArrayInfo
for _, adsArrayInfo := range childDataType.GetArrayInfo() {
- childArrayInfo = append(childArrayInfo, internalModel.DefaultArrayInfo{
+ childArrayInfo = append(childArrayInfo, &internalModel.DefaultArrayInfo{
LowerBound: adsArrayInfo.GetLowerBound(),
UpperBound: adsArrayInfo.GetUpperBound(),
})
diff --git a/plc4go/internal/cbus/Query.go b/plc4go/internal/cbus/Query.go
index c5e204dff8..7f8ce933fb 100644
--- a/plc4go/internal/cbus/Query.go
+++ b/plc4go/internal/cbus/Query.go
@@ -76,7 +76,7 @@ func (u unitInfoQuery) GetArrayInfo() []apiModel.ArrayInfo {
return []apiModel.ArrayInfo{}
}
return []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(u.numElements),
},
diff --git a/plc4go/internal/cbus/Query_test.go b/plc4go/internal/cbus/Query_test.go
index 27fbdb33d2..fe00f7db6d 100644
--- a/plc4go/internal/cbus/Query_test.go
+++ b/plc4go/internal/cbus/Query_test.go
@@ -84,7 +84,7 @@ func Test_unitInfoQuery_GetArrayInfo(t *testing.T) {
numElements: 2,
},
want: []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: 2,
},
diff --git a/plc4go/internal/cbus/Tag.go b/plc4go/internal/cbus/Tag.go
index e5cda0912f..a4e18dcfc8 100644
--- a/plc4go/internal/cbus/Tag.go
+++ b/plc4go/internal/cbus/Tag.go
@@ -286,7 +286,7 @@ func (s statusTag) GetValueType() apiValues.PlcValueType {
func (s statusTag) GetArrayInfo() []apiModel.ArrayInfo {
if s.numElements != 1 {
return []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(s.numElements),
},
@@ -427,7 +427,7 @@ func (c calRecallTag) GetValueType() apiValues.PlcValueType {
func (c calRecallTag) GetArrayInfo() []apiModel.ArrayInfo {
if c.count != 1 {
return []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(c.count),
},
@@ -494,7 +494,7 @@ func (c calIdentifyTag) GetValueType() apiValues.PlcValueType {
func (c calIdentifyTag) GetArrayInfo() []apiModel.ArrayInfo {
if c.numElements != 1 {
return []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(c.numElements),
},
@@ -561,7 +561,7 @@ func (c calGetStatusTag) GetValueType() apiValues.PlcValueType {
func (c calGetStatusTag) GetArrayInfo() []apiModel.ArrayInfo {
if c.count != 1 {
return []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(c.count),
},
@@ -636,7 +636,7 @@ func (s salTag) GetValueType() apiValues.PlcValueType {
func (s salTag) GetArrayInfo() []apiModel.ArrayInfo {
if s.numElements != 1 {
return []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(s.numElements),
},
@@ -717,7 +717,7 @@ func (s salMonitorTag) GetValueType() apiValues.PlcValueType {
func (s salMonitorTag) GetArrayInfo() []apiModel.ArrayInfo {
if s.numElements != 1 {
return []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(s.numElements),
},
@@ -795,7 +795,7 @@ func (m mmiMonitorTag) GetValueType() apiValues.PlcValueType {
func (m mmiMonitorTag) GetArrayInfo() []apiModel.ArrayInfo {
if m.numElements != 1 {
return []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(m.numElements),
},
diff --git a/plc4go/internal/cbus/Tag_test.go b/plc4go/internal/cbus/Tag_test.go
index 7fefc48bfa..2270136230 100644
--- a/plc4go/internal/cbus/Tag_test.go
+++ b/plc4go/internal/cbus/Tag_test.go
@@ -291,7 +291,7 @@ func Test_calGetStatusTag_GetArrayInfo(t *testing.T) {
{
name: "get array info",
want: []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{},
+ &spiModel.DefaultArrayInfo{},
},
},
{
@@ -607,7 +607,7 @@ func Test_calIdentifyTag_GetArrayInfo(t *testing.T) {
{
name: "get empty array info",
want: []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{},
+ &spiModel.DefaultArrayInfo{},
},
},
{
@@ -880,7 +880,7 @@ func Test_calRecallTag_GetArrayInfo(t *testing.T) {
{
name: "empty array info",
want: []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{},
+ &spiModel.DefaultArrayInfo{},
},
},
{
@@ -1388,7 +1388,7 @@ func Test_mmiMonitorTag_GetArrayInfo(t *testing.T) {
{
name: "mmi monitor tag",
want: []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{},
+ &spiModel.DefaultArrayInfo{},
},
},
{
@@ -1704,7 +1704,7 @@ func Test_salMonitorTag_GetArrayInfo(t *testing.T) {
{
name: "get empty array info",
want: []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{},
+ &spiModel.DefaultArrayInfo{},
},
},
{
@@ -2014,7 +2014,7 @@ func Test_salTag_GetArrayInfo(t *testing.T) {
{
name: "get empty array info",
want: []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{},
+ &spiModel.DefaultArrayInfo{},
},
},
{
@@ -2415,7 +2415,7 @@ func Test_statusTag_GetArrayInfo(t *testing.T) {
{
name: "get empty array info",
want: []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{},
+ &spiModel.DefaultArrayInfo{},
},
},
{
diff --git a/plc4go/internal/modbus/Tag.go b/plc4go/internal/modbus/Tag.go
index 64296943ed..0a5d9aff26 100644
--- a/plc4go/internal/modbus/Tag.go
+++ b/plc4go/internal/modbus/Tag.go
@@ -88,7 +88,7 @@ func (m modbusTag) GetValueType() values.PlcValueType {
func (m modbusTag) GetArrayInfo() []model.ArrayInfo {
if m.Quantity != 1 {
return []model.ArrayInfo{
- model3.DefaultArrayInfo{
+ &model3.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(m.Quantity),
},
diff --git a/plc4go/internal/s7/Tag.go b/plc4go/internal/s7/Tag.go
index 664d011de1..4c01472234 100644
--- a/plc4go/internal/s7/Tag.go
+++ b/plc4go/internal/s7/Tag.go
@@ -100,7 +100,7 @@ func (m plcTag) GetValueType() values.PlcValueType {
func (m plcTag) GetArrayInfo() []model.ArrayInfo {
if m.NumElements != 1 {
return []model.ArrayInfo{
- model2.DefaultArrayInfo{
+ &model2.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(m.NumElements),
},
diff --git a/plc4go/internal/simulated/Tag.go b/plc4go/internal/simulated/Tag.go
index dfebcdb3e6..a9fca79db0 100644
--- a/plc4go/internal/simulated/Tag.go
+++ b/plc4go/internal/simulated/Tag.go
@@ -78,7 +78,7 @@ func (t simulatedTag) GetValueType() values.PlcValueType {
func (t simulatedTag) GetArrayInfo() []apiModel.ArrayInfo {
if t.Quantity != 1 {
return []apiModel.ArrayInfo{
- spiModel.DefaultArrayInfo{
+ &spiModel.DefaultArrayInfo{
LowerBound: 0,
UpperBound: uint32(t.Quantity),
},
diff --git a/plc4go/spi/RequestTransactionManager_test.go b/plc4go/spi/RequestTransactionManager_test.go
index 0a590bef89..29b6e52cdd 100644
--- a/plc4go/spi/RequestTransactionManager_test.go
+++ b/plc4go/spi/RequestTransactionManager_test.go
@@ -25,7 +25,6 @@ import (
"github.com/apache/plc4x/plc4go/spi/utils"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
- "sync"
"testing"
"time"
)
@@ -380,9 +379,7 @@ func Test_requestTransactionManager_submitTransaction(t *testing.T) {
runningRequests []*requestTransaction
numberOfConcurrentRequests int
transactionId int32
- transactionMutex sync.RWMutex
workLog list.List
- workLogMutex sync.RWMutex
executor utils.Executor
}
type args struct {
@@ -410,9 +407,7 @@ func Test_requestTransactionManager_submitTransaction(t *testing.T) {
runningRequests: tt.fields.runningRequests,
numberOfConcurrentRequests: tt.fields.numberOfConcurrentRequests,
transactionId: tt.fields.transactionId,
- transactionMutex: tt.fields.transactionMutex,
workLog: tt.fields.workLog,
- workLogMutex: tt.fields.workLogMutex,
executor: tt.fields.executor,
}
r.submitTransaction(tt.args.handle)
diff --git a/plc4go/spi/Tracer.go b/plc4go/spi/Tracer.go
index 774dc0a2a3..f1ea2f696b 100644
--- a/plc4go/spi/Tracer.go
+++ b/plc4go/spi/Tracer.go
@@ -101,25 +101,17 @@ func (t *Tracer) FilterTraces(traces []TraceEntry, connectionIdFilter string, tr
var result []TraceEntry
traceFiltering:
for _, trace := range traces {
- if connectionIdFilter != "" {
- if trace.ConnectionId != connectionIdFilter {
- continue traceFiltering
- }
+ if connectionIdFilter != "" && trace.ConnectionId != connectionIdFilter {
+ continue traceFiltering
}
- if transactionIdFilter != "" {
- if trace.TransactionId != transactionIdFilter {
- continue traceFiltering
- }
+ if transactionIdFilter != "" && trace.TransactionId != transactionIdFilter {
+ continue traceFiltering
}
- if operationFilter != "" {
- if trace.Operation != operationFilter {
- continue traceFiltering
- }
+ if operationFilter != "" && trace.Operation != operationFilter {
+ continue traceFiltering
}
- if messageFilter != "" {
- if trace.Message != messageFilter {
- continue traceFiltering
- }
+ if messageFilter != "" && trace.Message != messageFilter {
+ continue traceFiltering
}
result = append(result, trace)
}
diff --git a/plc4go/spi/default/DefaultCodec_test.go b/plc4go/spi/default/DefaultCodec_test.go
index 2e78e352af..c9014d7c4c 100644
--- a/plc4go/spi/default/DefaultCodec_test.go
+++ b/plc4go/spi/default/DefaultCodec_test.go
@@ -274,7 +274,7 @@ func TestWithCustomMessageHandler(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- assert.Equalf(t, tt.want, WithCustomMessageHandler(tt.args.customMessageHandler), "WithCustomMessageHandler(%v)", tt.args.customMessageHandler)
+ assert.Equalf(t, tt.want, WithCustomMessageHandler(tt.args.customMessageHandler), "WithCustomMessageHandler(func())")
})
}
}
@@ -493,7 +493,7 @@ func Test_defaultCodec_Expect(t *testing.T) {
running: tt.fields.running,
customMessageHandling: tt.fields.customMessageHandling,
}
- tt.wantErr(t, m.Expect(tt.args.ctx, tt.args.acceptsMessage, tt.args.handleMessage, tt.args.handleError, tt.args.ttl), fmt.Sprintf("Expect(%v, %v, %v, %v, %v)", tt.args.ctx, tt.args.acceptsMessage, tt.args.handleMessage, tt.args.handleError, tt.args.ttl))
+ tt.wantErr(t, m.Expect(tt.args.ctx, tt.args.acceptsMessage, tt.args.handleMessage, tt.args.handleError, tt.args.ttl), fmt.Sprintf("Expect(%v, func(), func(), func(), %v)", tt.args.ctx, tt.args.ttl))
})
}
}
@@ -765,7 +765,7 @@ func Test_defaultCodec_SendRequest(t *testing.T) {
running: tt.fields.running,
customMessageHandling: tt.fields.customMessageHandling,
}
- tt.wantErr(t, m.SendRequest(tt.args.ctx, tt.args.message, tt.args.acceptsMessage, tt.args.handleMessage, tt.args.handleError, tt.args.ttl), fmt.Sprintf("SendRequest(%v, %v, %v, %v, %v, %v)", tt.args.ctx, tt.args.message, tt.args.acceptsMessage, tt.args.handleMessage, tt.args.handleError, tt.args.ttl))
+ tt.wantErr(t, m.SendRequest(tt.args.ctx, tt.args.message, tt.args.acceptsMessage, tt.args.handleMessage, tt.args.handleError, tt.args.ttl), fmt.Sprintf("SendRequest(%v, %v, func(), func(), func(), %v)", tt.args.ctx, tt.args.message, tt.args.ttl))
})
}
}
diff --git a/plc4go/spi/model/DefaultArrayInfo.go b/plc4go/spi/model/DefaultArrayInfo.go
index d8a8d12d58..09540ded5f 100644
--- a/plc4go/spi/model/DefaultArrayInfo.go
+++ b/plc4go/spi/model/DefaultArrayInfo.go
@@ -25,14 +25,14 @@ type DefaultArrayInfo struct {
UpperBound uint32
}
-func (t DefaultArrayInfo) GetSize() uint32 {
+func (t *DefaultArrayInfo) GetSize() uint32 {
return t.UpperBound - t.LowerBound
}
-func (t DefaultArrayInfo) GetLowerBound() uint32 {
+func (t *DefaultArrayInfo) GetLowerBound() uint32 {
return t.LowerBound
}
-func (t DefaultArrayInfo) GetUpperBound() uint32 {
+func (t *DefaultArrayInfo) GetUpperBound() uint32 {
return t.UpperBound
}
diff --git a/plc4go/spi/model/DefaultPlcDiscoveryItem.go b/plc4go/spi/model/DefaultPlcDiscoveryItem.go
index 6f8e08bfb7..6cb3f4dd35 100644
--- a/plc4go/spi/model/DefaultPlcDiscoveryItem.go
+++ b/plc4go/spi/model/DefaultPlcDiscoveryItem.go
@@ -82,7 +82,7 @@ func (d *DefaultPlcDiscoveryItem) GetAttributes() map[string]apiValues.PlcValue
func (d *DefaultPlcDiscoveryItem) GetConnectionUrl() string {
options := ""
if d.Options != nil {
- flatOptions := []string{}
+ var flatOptions []string
for k, vl := range d.Options {
for _, v := range vl {
flatOptions = append(flatOptions, url.QueryEscape(k)+"="+url.QueryEscape(v))
diff --git a/plc4go/spi/utils/Misc_test.go b/plc4go/spi/utils/Misc_test.go
index 7bfa8be8a0..80791758dd 100644
--- a/plc4go/spi/utils/Misc_test.go
+++ b/plc4go/spi/utils/Misc_test.go
@@ -97,7 +97,7 @@ func TestInlineIf(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- assert.Equalf(t, tt.want, InlineIf(tt.args.test, tt.args.a, tt.args.b), "InlineIf(%v, %v, %v)", tt.args.test, tt.args.a, tt.args.b)
+ assert.Equalf(t, tt.want, InlineIf(tt.args.test, tt.args.a, tt.args.b), "InlineIf(%v, func(), func())", tt.args.test)
})
}
}
diff --git a/plc4go/spi/utils/WorkerPool_test.go b/plc4go/spi/utils/WorkerPool_test.go
index 06a000037e..ade30c2fb7 100644
--- a/plc4go/spi/utils/WorkerPool_test.go
+++ b/plc4go/spi/utils/WorkerPool_test.go
@@ -445,7 +445,8 @@ func Test_future_AwaitCompletion(t *testing.T) {
{
name: "completes not int time",
args: args{ctx: func() context.Context {
- deadline, _ := context.WithDeadline(context.Background(), time.Now().Add(30*time.Millisecond))
+ deadline, cancel := context.WithDeadline(context.Background(), time.Now().Add(30*time.Millisecond))
+ t.Cleanup(cancel)
return deadline
}()},
completer: func(f *future) {
diff --git a/plc4go/spi/values/PlcWCHAR.go b/plc4go/spi/values/PlcWCHAR.go
index d9ce75793c..df5b92f75a 100644
--- a/plc4go/spi/values/PlcWCHAR.go
+++ b/plc4go/spi/values/PlcWCHAR.go
@@ -49,7 +49,7 @@ func (m PlcWCHAR) IsString() bool {
}
func (m PlcWCHAR) GetString() string {
- return string(m.value)
+ return m.value
}
func (m PlcWCHAR) GetPlcValueType() apiValues.PlcValueType {
@@ -65,7 +65,7 @@ func (m PlcWCHAR) Serialize() ([]byte, error) {
}
func (m PlcWCHAR) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error {
- return writeBuffer.WriteString("PlcWCHAR", uint32(16), "UTF-16", string(m.value))
+ return writeBuffer.WriteString("PlcWCHAR", uint32(16), "UTF-16", m.value)
}
func (m PlcWCHAR) String() string {
diff --git a/plc4go/spi/values/PlcWSTRING.go b/plc4go/spi/values/PlcWSTRING.go
index f49dd6073e..f5c583ff76 100644
--- a/plc4go/spi/values/PlcWSTRING.go
+++ b/plc4go/spi/values/PlcWSTRING.go
@@ -49,7 +49,7 @@ func (m PlcWSTRING) IsString() bool {
}
func (m PlcWSTRING) GetString() string {
- return string(m.value)
+ return m.value
}
func (m PlcWSTRING) GetPlcValueType() apiValues.PlcValueType {
@@ -65,7 +65,7 @@ func (m PlcWSTRING) Serialize() ([]byte, error) {
}
func (m PlcWSTRING) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error {
- return writeBuffer.WriteString("PlcSTRING", uint32(len(m.value)*8), "UTF-8", string(m.value))
+ return writeBuffer.WriteString("PlcSTRING", uint32(len(m.value)*8), "UTF-8", m.value)
}
func (m PlcWSTRING) String() string {