Skip to content

fix failing afn:sprintf tests that fails on nb-NO - #4373

Open
OyvindLGjesdal wants to merge 1 commit into
apache:mainfrom
OyvindLGjesdal:fix-failing-afn-sprintf-tests-when-nb-no-locale
Open

OyvindLGjesdal wants to merge 1 commit into
apache:mainfrom
OyvindLGjesdal:fix-failing-afn-sprintf-tests-when-nb-no-locale

Conversation

@OyvindLGjesdal

Copy link
Copy Markdown
Contributor

GitHub issue resolved #4372

Pull request Description:


  • Tests are included.
  • Documentation change and updates are provided for the Apache Jena website
  • Commits have been squashed to remove intermediate development commit messages.
  • Key commit messages start with the issue number (GH-xxxx)

By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the Contributor's Agreement.


See the Apache Jena "Contributing" guide.

@Test public void exprSprintf_14() { test("afn:sprintf('%020d', 1)",NodeValue.makeString("00000000000000000001")); }
@Test public void exprSprintf_15() { test("afn:sprintf('%200d', 1)",NodeValue.makeString(StringUtils.repeat(' ', 199) + "1")); }
// check that sprintf does not depend on the JVM default locale
@Test public void exprSprintf_16() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't thread safe.

Locale.setDefault sets the JVM wide Locale for all threads so it (briefly) modifies everywhere in the JVM. Tests can run in parallel.

I can't think of a way to check afn:sprintf that doesn't fall back to the same situation the other tests have. They format and test for the . decimal form.

Of course, if someone is running n?-NO moderately regularly, the check happens!

What if "nb-NO" isn't available? I think the Java runtime library creates a Locale with defaults.
(Could check Locale.availableLocales())

@OyvindLGjesdal OyvindLGjesdal Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess removing test-16 and reporting if something breaks works. Claude suggests it would silently pass without checking on missing locale:

On a runtime without Norwegian locale data, the formatter would fall back to root formatting and print ., so the test would pass without checking anything.

@OyvindLGjesdal
OyvindLGjesdal force-pushed the fix-failing-afn-sprintf-tests-when-nb-no-locale branch from 013e295 to 63653c0 Compare November 1, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failing tests on Locale nb-no

2 participants