Closed FearThe1337 closed 6 years ago
I'd suggest you just move to the UK - it'll fix all your timezone and locale bugs ;-)
I'm currently trying to get the last of the FLAC audio length bits done. When that's sorted, I'll try turning on the Forbidden APIs checks, and fix up all the things that flags. Hopefully one of those should fix this locale assumption bug
It is not the only test in this case: all tests with assertions on duration could fail because the String.format method is locale-aware. One quickfix is to use String.format on the left side of the assertion too. And I'm not sure forcing the Locale is a good idea. Quickfix in pull request #28
As the original author of the test, I'm sorry for this locale dependency. Quickfix looks good to me.
I'm in two minds about what's the "least surprising" behaviour here
If we want to keep it returning mostly-local formatted time, then @croger42's fix to the unit tests looks correct. (I'd be minded to put in a helper method to shorten the code it a bit, but that's it!)
However... In Apache Tika we've tended to force all our formatting stuff to be locale-independant by default, which would mean changing OggAudioStatistics
to use Locale.ROOT
or similar when doing the format, so it's always the same. That's also what adding the Forbidden API checks (long forgotten about, sorry!) would lean towards, as that generally prevents you from using default-locale methods implicitly
As apparently the main two non-UK / non-US users of the method, what do you both think? :)
To me the root problem is that getDuration() uses the default-locale. Suggestion: let add/change it to getDuration(Locale l) which uses the one the user asks for. Tests can force UK locale for instance.
@andrm I've hopefully done that in d82dbda75e26f6cebf00f5e26a8a637282015c51 , does the test now work correctly (and expectedly!) for you?
Works well, tested it with several locale settings.
Can you please look at 989a72a and https://github.com/andrm/VorbisJava/commit/c540c858e0784789de741d2ced7f4c213ec44709 ? I think that's better and we keep backwards compatibility. Sorry for not doing a pull request, my repo is messed up.
Great, thanks for everyone's help on this, and sorry it took so long to solve!
Hi,
When attempting to build:
I'm assuming it's because of a system locale setting. Full stack trace: