apache / apache/incubator-seata
saga模式复杂参数的入参问题:Task xxx input parameters assign failed
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26k
- Forks
- 8.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 4
Description
- I have searched the issues of this repository and believe that this is not a duplicate.
Ⅰ. Issue Description
我在编写saga状态机json时遇到了一个复杂入参的问题
官方给的复杂入参示例的方法
complexParameterMethod(String name,int age,People people,People[] peopleArraya,List peopleList,Map<String,People> peopleMap)第三个参数传的是一个People实体对象people
中,people包含一个List,泛型本身是People,
示例状态机的input中直接给这个list里的People赋值了
……
"childrenList":[
{
"name": "$.[people].name",
"age": "$.[people].age"
},
{
"name": "$.[people].name",
"age": "$.[people].age"
}
]
……
现在我的需求是接口只传一个VO vo对象,VO里有一个属性是一个List mylist,那么状态机里的Input中,我怎么写这个List中元素的表达式,去遍历mylist给元素MyObject的属性赋值?
Input:[
{
....
"mylist":[
{
"attribute1": "$.[vo].mylist.xxx.attribute1",
"attribute2": "$.[vo].mylist.xxx.attribute2"
},
{
...
...
}
]
....
}
]
"attribute1": "$.[vo].mylist.xxx.attribute1"中的xxx怎么写?
EL表达式可以通过索引访问
"attribute1": "$.[vo].mylist[0].attribute1",
如果这样写如何确定mylist里有几个元素?
并且如果不传mylist,会报expression:EL1012E:cannot index into a null value
请问这个复杂入参应该怎么写?
Ⅱ. Describe what happened
If there is an exception, please attach the exception trace:
Just paste your stack trace here!
Ⅲ. Describe what you expected to happen
Ⅳ. How to reproduce it (as minimally and precisely as possible)
- xxx
- xxx
- xxx
Ⅴ. Anything else we need to know?
Ⅵ. Environment:
- JDK version :
- OS :
- Others:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the saga state machine JSON input mapping around complexParameterMethod and the EL expressions used for nested List values. Reproduce the VO case with a populated and a missing mylist, then trace how parameter assignment handles indexing and null values. Done means the expected behavior for variable-length and absent lists is established and covered by an appropriate test or documented guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100