I am using WSO2SP version 4.3.0 with regex extension : siddhi-execution-regex-4.1.2.jar. My code was working fine but whenever i restart my wso2sp instance i start getting error "Exception occurred when converting Text message to Siddhi Event in the stream transactionstream1 of siddhi text input mapper. java.lang.StackOverflowError " I have to restart wso2sp multiple times to get this working,which is not a viable solution. I am also sending text message via http using extension siddhi-io-http-1.0.40.jar. Text map extension : siddhi-map-text-1.1.2.jar and siddhi-map-text-1.0.22.jar
Test source :
@source(type = 'http', receiver.url = 'http://localhost:5005/text',
@map(type='text',fail.on.missing.attribute='false', regex.A=""""(after)":("(\\"|[^"])*"|\[("(\\"|[^"])*"(,"(\\"|[^"])*")*)?\])""",
@attributes(payload = 'A[2]')))
define stream transactionstream1(payload string);
Test Text:
curl -X POST \
http://localhost:5005/text \
-H 'content-type: application/json' \
-d '{"schema":{"type":"struct","fields":[{"type":"string","optional":false,"field":"id"}],"optional":false,"name":"db.db.Key"},"payload":{"id":"{ \"$oid\" : \"dafeafwe3\"}"}} {"schema":{"type":"struct","fields":[{"type":"string","optional":true,"name":"io.debezium.data.Json","version":1,"field":"after"},{"type":"string","optional":true,"name":"io.debezium.data.Json","version":1,"field":"patch"},{"type":"struct","fields":[{"type":"string","optional":false,"field":"version"},{"type":"string","optional":false,"field":"connector"},{"type":"string","optional":false,"field":"name"},{"type":"int64","optional":false,"field":"ts_ms"},{"type":"string","optional":true,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"true,last,false"},"default":"false","field":"snapshot"},{"type":"string","optional":false,"field":"db"},{"type":"string","optional":false,"field":"rs"},{"type":"string","optional":false,"field":"collection"},{"type":"int32","optional":false,"field":"ord"},{"type":"int64","optional":true,"field":"h"}],"optional":false,"name":"io.debezium.connector.mongo.Source","field":"source"},{"type":"string","optional":true,"field":"op"},{"type":"int64","optional":true,"field":"ts_ms"}],"optional":false,"name":"db.db.collection.Envelope"},"payload":{"after":"{\"_id\": {\"$oid\": \"54444342fdsfsdfs\"},\"code\": \"42432432423\",\"name\": \"name1\",\"desc\": \"description\",\"transRefId\": \"cgvvjbjhvjy6979yjbv\",\"origAmount\": 1000,\"amount\": 1000,\"currency\": \"USD\",\"redeemedCashcode\": \"\",\"sender\": {\"id\": \"342edesfsfes\",\"name\": \"rose\",\"phone\": \"123456789\"},\"receiver\": {\"id\": \"fr3wfwrw342\",\"name\": \"daass\",\"phone\": \"453452423\",\"client\": \"CLIENT2\"}}}'
Part of Stack trace:
ERROR {org.wso2.extension.siddhi.map.text.sourcemapper.TextSourceMapper}Exception occurred when converting Text message {"type":"string","optional":false,"field":"id"}],"optional":false,"name":"db.db.Key"},"payload":{"id":"{ \"$oid\" : \"dafeafwe3\"}"}} {"schema":{"type":"struct","fields":[{"type":"string","optional":true,"name":"io.debezium.data.Json","version":1,"field":"after"},{"type":"string","optional":true,"name":"io.debezium.data.Json","version":1,"field":"patch"},{"type":"struct","fields":[{"type":"string","optional":false,"field":"version"},{"type":"string","optional":false,"field":"connector"},{"type":"string","optional":false,"field":"name"},{"type":"int64","optional":false,"field":"ts_ms"},{"type":"string","optional":true,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"true,last,false"},"default":"false","field":"snapshot"},{"type":"string","optional":false,"field":"db"},{"type":"string","optional":false,"field":"rs"},{"type":"string","optional":false,"field":"collection"},{"type":"int32","optional":false,"field":"ord"},{"type":"int64","optional":true,"field":"h"}],"optional":false,"name":"io.debezium.connector.mongo.Source","field":"source"},{"type":"string","optional":true,"field":"op"},{"type":"int64","optional":true,"field":"ts_ms"}],"optional":false,"name":"db.db.collection.Envelope"},"payload":{"after":"{\"_id\": {\"$oid\": \"54444342fdsfsdfs\"},\"code\": \"42432432423\",\"name\": \"name1\",\"desc\": \"description\",\"transRefId\": \"cgvvjbjhvjy6979yjbv\",\"origAmount\": 1000,\"amount\": 1000,\"currency\": \"USD\",\"redeemedCashcode\": \"\",\"sender\": {\"id\": \"342edesfsfes\",\"name\": \"rose\",\"phone\": \"123456789\"},\"receiver\": {\"id\": \"fr3wfwrw342\",\"name\": \"daass\",\"phone\": \"453452423\",\"client\": \"CLIENT2\"}}},"op":"r","ts_ms":1575862492251}} to Siddhi Event in the stream transactionstream1 of siddhi text input mapper. java.lang.StackOverflowError
at java.util.regex.Pattern$Branch.match(Pattern.java:4606)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4660)
at java.util.regex.Pattern$Loop.match(Pattern.java:4787)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4719)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4570)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3779)
at java.util.regex.Pattern$Branch.match(Pattern.java:4606)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4660)
at java.util.regex.Pattern$Loop.match(Pattern.java:4787)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4719)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4570)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3779)
at java.util.regex.Pattern$Branch.match(Pattern.java:4606)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4660)
at java.util.regex.Pattern$Loop.match(Pattern.java:4787)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4719)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4570)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3779)
at java.util.regex.Pattern$Branch.match(Pattern.java:4606)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4660)
at java.util.regex.Pattern$Loop.match(Pattern.java:4787)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4719)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4570)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3779)
at java.util.regex.Pattern$Branch.match(Pattern.java:4606)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4660)
at java.util.regex.Pattern$Loop.match(Pattern.java:4787)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4719)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4570)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3779)
at java.util.regex.Pattern$Branch.match(Pattern.java:4606)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4660)
at java.util.regex.Pattern$Loop.match(Pattern.java:4787)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4719)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4570)
at java.util.regex.Pattern$Slice.match(Pattern.java:3974)
at java.util.regex.Pattern$Branch.match(Pattern.java:4606)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4660)
at java.util.regex.Pattern$Loop.match(Pattern.java:4787)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4719)
at java.util.regex.Pattern$BranchConn.match(Pattern.java:4570)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3779)
at java.util.regex.Pattern$Branch.match(Pattern.java:4606)
at java.util.regex.Pattern$GroupHead.match(Pattern.java:4660)
at java.util.regex.Pattern$Loop.match(Pattern.java:4787)
at java.util.regex.Pattern$GroupTail.match(Pattern.java:4719)
Is there a version compatible issue ? How do i resolve this permanently ?
It seems like this behavior is related to Java notoriously doesn't liking alternations in certain circumstances where there are potential backtrack problems.
So, this part ("(\"|[^"])"|[("(\"|[^"])"(,"(\"|[^"])"))?])" creates an undo burden on the backtrack mechanism.
Please try updating the regex as below to reduce the impact of the implementation flaw which causes StackOverflowError.
(after)":("(\\"|[|]|[^"])*+")
Please refer Sporadic Stack Overflow error in java Matcher for more details.