vertx-json-schema
vertx-json-schema copied to clipboard
OneOfValidatorFactory is throwing too many exception when checking all the options counts
Questions
Version
4.1.x and 4.3.8 it is the same behaviour
Context
I encountered an exception while using the yourkit profiler to see CPU hot spots.
The filling in of the stack traces is taking too much CPU. Expect we can suppress that or try to avoid the throwing of exceptions and instead return false. or else suppress the filling in of the large stack trace in the exception.
https://github.com/eclipse-vertx/vertx-json-schema/blob/135da5046be5538365bcf4090e2b8ba07a129838/src/main/java/io/vertx/json/schema/common/OneOfValidatorFactory.java#L51
Do you have a reproducer?
Using a json schema to validateSync, with a oneOf and many required options.
there is an example in this json schema: {"type":"object","properties":{"schema":{"type":"object","properties":{"A":{"type":"object","properties":{"ttl":{"type":"integer"},"ipV4":{"type":"string"}},"required":["ttl","ipV4"]},"AAAA":{"type":"object","properties":{"ttl":{"type":"integer"},"ipV6":{"type":"string"}}},"CNAME":{"type":"object","properties":{"ttl":{"type":"integer"},"dn":{"type":"string"}},"required":["ttl","dn"]},"NS":{"type":"object","properties":{"ttl":{"type":"integer"},"dn":{"type":"string"}},"required":["ttl","dn"]},"PTR":{"type":"object","properties":{"ttl":{"type":"integer"},"dn":{"type":"string"}},"required":["ttl","dn"]},"HINFO":{"type":"object","properties":{"ttl":{"type":"integer"},"cpu":{"type":"string"},"os":{"type":"string"}},"required":["ttl","cpu","os"]},"MX":{"type":"object","properties":{"ttl":{"type":"integer"},"preference":{"type":"integer"},"exchange":{"type":"string"}},"required":["ttl","preference","exchange"]},"NAPTR":{"type":"object","properties":{"ttl":{"type":"integer"},"order":{"type":"integer"},"preference":{"type":"integer"},"flags":{"type":"string"},"service":{"type":"string"},"regexp":{"type":"string"},"replacement":{"type":"string"}},"required":["ttl","order","preference"]},"SRV":{"type":"object","properties":{"ttl":{"type":"integer"},"priority":{"type":"integer"},"weight":{"type":"integer"},"port":{"type":"integer"},"target":{"type":"string"}},"required":["ttl","priority","weight","port","target"]},"TXT":{"type":"object","properties":{"ttl":{"type":"integer"},"txt":{"type":"string"}},"required":["ttl","txt"]}},"oneOf":[{"required":["A"]},{"required":["AAAA"]},{"required":["CNAME"]},{"required":["NS"]},{"required":["PTR"]},{"required":["HINFO"]},{"required":["MX"]},{"required":["NAPTR"]},{"required":["SRV"]},{"required":["TXT"]}]},"policy":{"type":"object","properties":{"priority":{"type":"integer"},"weight":{"type":"integer"},"effective-start":{"type":"string","format":"date-time"},"effective-end":{"type":"string","format":"date-time"},"tod-start":{"type":"string","format":"time"},"tod-end":{"type":"string","format":"time"},"dow":{"type":"object","properties":{"sun":{"type":"boolean","default":false},"mon":{"type":"boolean","default":false},"tue":{"type":"boolean","default":false},"wed":{"type":"boolean","default":false},"thu":{"type":"boolean","default":false},"fri":{"type":"boolean","default":false},"sat":{"type":"boolean","default":false}}},"timezone":{"type":"string"}}}},"required":["schema"]}
Reproducers are very helpful for contributors and will likely help them fixing your bug faster.
- Link to github project/gist
Steps to reproduce
Run the schema validateSync function with some like above example, and step thru debugger with each validationexception getting thrown.
Extra
- Anything that can be relevant such as OS version, JVM version
This is an optimization issue encountered in performance testing.
Hi,
this is an issue related to a component that is not longer maintained and removed in Vert.x 5. Because of this I will close this issue. Feel free to open a new issue, in case this problem also exists in the new latest Validator.