Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OneOfValidatorFactory is throwing too many exception when checking all the options counts #91

Open
pantinor opened this issue Feb 23, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@pantinor
Copy link

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.

if (validCount > 1) throw ValidationException.create("More than one schema valid", "oneOf", in);

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
@pantinor pantinor added the bug Something isn't working label Feb 23, 2023
@pantinor
Copy link
Author

This is an optimization issue encountered in performance testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant