Skip to content

unify-jdocs-1.7.0

Compare
Choose a tag to compare
@deepakarora3 deepakarora3 released this 15 Feb 20:14
· 1 commit to main since this release

Well, this is a fix to a day zero issue. We came across this as an incident in our internal system where we are using JDocs and so posting a fix for the community asap.

How do you know if you are impacted?

Let's say you are using name value pair in the getXXX and setXXX methods and using % so that the value comes from the variable arguments passed to the method but forget to specify the variable arguments like below:

d.getString("$.names[number=%].first_name"); // instead of d.getString("$.names[number=%].first_name", "Some Name");

The above will return null instead of throwing an exception. This is now fixed to throw an exception. Note that this was only happening if name value pairs were being used. If you were using [%] then you are not impacted.

I realize that this may break some running code and so the minor version upgrade.

There is a simple way to scan your code base to see if you have any such occurrences. You can use regular expressions to search for any occurrence of % that lies between [ and ] and ends with ). I used the following pattern to narrow down the list and confirm:

[.%.])

Based on comments, I can also look to release a version that can provide for an option to throw an exception or not in such cases (will be deprecated in the future) but really, I would not like to do this - it is better to fail fast, fix and move on rather than defer to the future.

Test suite is also updated.