logbook: StackOverflow for JsonBodyFilter
Using a debugger, I built a function that will reproduce it (this is inside com.monese.card.service.config.logbook.JsonBodyFilters#replace
inside delegate
lambda):
public static void main(String[] args) {
//com.monese.card.service.config.logbook.JsonBodyFilters#replace
String STRING = "(?:\"(?:[^\"\\\\]|\\\\.)*\")";
String value = STRING;
final Pattern pattern = compile("(?<key>\"(?<property>.*?)\"\\s*:\\s*)(" + value + "|null)");
String body = "{\"variables\":{},\"query\":\"\\n query IntrospectionQuery {\\n __schema {\\n queryType { name }\\n mutationType { name }\\n subscriptionType { name }\\n types {\\n ...FullType\\n }\\n directives {\\n name\\n description\\n locations\\n args {\\n ...InputValue\\n }\\n }\\n }\\n }\\n\\n fragment FullType on __Type {\\n kind\\n name\\n description\\n fields(includeDeprecated: true) {\\n name\\n description\\n args {\\n ...InputValue\\n }\\n type {\\n ...TypeRef\\n }\\n isDeprecated\\n deprecationReason\\n }\\n inputFields {\\n ...InputValue\\n }\\n interfaces {\\n ...TypeRef\\n }\\n enumValues(includeDeprecated: true) {\\n name\\n description\\n isDeprecated\\n deprecationReason\\n }\\n possibleTypes {\\n ...TypeRef\\n }\\n }\\n\\n fragment InputValue on __InputValue {\\n name\\n description\\n type { ...TypeRef }\\n defaultValue\\n }\\n\\n fragment TypeRef on __Type {\\n kind\\n name\\n ofType {\\n kind\\n name\\n ofType {\\n kind\\n name\\n ofType {\\n kind\\n name\\n ofType {\\n kind\\n name\\n ofType {\\n kind\\n name\\n ofType {\\n kind\\n name\\n ofType {\\n kind\\n name\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n }\\n \"}";
pattern.matcher(body).find();
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (2 by maintainers)
@Sam-Kruglov Thanks for the issue and the test/input! 🎉
So I took another look and your code sample inlined patterns that are no longer in use.
There is a test case in the master that covers your sample input and it passes ✔️
https://github.com/zalando/logbook/blob/54054d6d147a55f06d0f9ca484d24478657c046a/logbook-json/src/test/java/org/zalando/logbook/json/JsonBodyFiltersTest.java#L173-L182
https://github.com/zalando/logbook/blob/54054d6d147a55f06d0f9ca484d24478657c046a/logbook-json/src/test/resources/huge-json-value.json#L1-L4