[MDSAL-29] Incorrect use of format strings in generated code when backing type is an array Created: 12/Jun/14 Updated: 09/Mar/18 Resolved: 13/Jan/17 |
|
| Status: | Resolved |
| Project: | mdsal |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | ||
| Reporter: | Rob Adams | Assignee: | Jakub Toth |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: Linux |
||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Description |
|
Yangtools will currently generate code like: throw new IllegalArgumentException(String.format("Invalid length: {}, expected: {}.", value, lengthConstraints)); This is incorrect since {} is a slf4j-style format specifier when you want a format string. |
| Comments |
| Comment by Rob Adams [ 13/Jun/14 ] |
|
The attached patch fixes the format string bug, but when I apply, the unit tests fail because of an apparent different bug. Failed tests: test(org.opendaylight.yangtools.sal.java.api.generator.test.TypedefCompilationTest): expected:<Invalid length: abcd[, expected: [[5‥11]]].> but was:<Invalid length: abcd[e, expected: [[6‥10]]].> |
| Comment by Rob Adams [ 13/Jun/14 ] |
|
Attachment 1193.patch has been added with description: Fixes format bug |
| Comment by Rob Adams [ 13/Jun/14 ] |
|
The failed test was not a real bug but a bug in the unit test that was masked by the previous format string bug. |
| Comment by Dana Kutenicsova [ 25/Jul/14 ] |
|
Reopening with low priority, as the format string does not return useful value, when the value is an array. Quoting findbugs warning: 'One of the arguments being formatted with a format string is an array. This will be formatted using a fairly useless format, such as [I@304282, which doesn't actually show the contents of the array. Consider wrapping the array using Arrays.asList(...) before handling it off to a formatted.' |
| Comment by Tony Tkacik [ 13/Nov/14 ] |
|
Added as blocking issue for Topic: Decrease Technical Debt. |
| Comment by Martin Ciglan [ 12/Jan/17 ] |
|
fix needs cherry-pick to Boron |