Skip to content

REF-7: Support non-file resource URLs (WildFly/JBoss vfs:) in ResourceUtil (issue #80)#86

Open
thomasnymand wants to merge 1 commit into
masterfrom
feature/REF-7-resourceutil-vfs-url
Open

REF-7: Support non-file resource URLs (WildFly/JBoss vfs:) in ResourceUtil (issue #80)#86
thomasnymand wants to merge 1 commit into
masterfrom
feature/REF-7-resourceutil-vfs-url

Conversation

@thomasnymand

Copy link
Copy Markdown
Collaborator

Fixes #80

Summary

On WildFly/JBoss, loading resources failed with an IllegalArgumentException during the authentication flow.

Root cause: ResourceUtil.getResourceAsFile() only special-cased jar: URLs and converted every other URL with new File(url.toURI()). WildFly/JBoss serves classpath resources through its virtual file system, so the classloader returns vfs: / vfszip: URLs. new File(uri) requires a file: scheme and throws IllegalArgumentException: URI scheme is not "file" for those.

Fix

Extract a package-private toFile(URL, String) that:

  • uses a plain file: URL directly, and
  • stream-copies any other protocol (jar:, vfs:, vfszip:, ...) to a temporary file.

This generalizes the previous jar-only handling to any non-file: protocol, so no per-app-server special-casing is needed.

Test

ResourceUtilTest gets a new case that simulates a WildFly vfs: URL via a synthetic URLStreamHandler. It asserts that the old new File(url.toURI()) throws IllegalArgumentException (the #80 bug) and that toFile() resolves the same URL to a readable file with the original content. Existing jar: / classpath / external-file cases still pass.

Full suite: Tests run: 108, Failures: 0, Errors: 0.

🤖 Generated with Claude Code

…eUtil (issue #80)

ResourceUtil.getResourceAsFile only special-cased 'jar:' URLs and turned
every other URL into a File via new File(url.toURI()). On WildFly/JBoss
the classloader returns 'vfs:'/'vfszip:' URLs, for which that throws
IllegalArgumentException ("URI scheme is not 'file'"), breaking resource
loading during the authentication flow.

Extract a package-private toFile(URL, String) that uses a plain 'file:'
URL directly and stream-copies any other protocol (jar:, vfs:, vfszip:,
...) to a temporary file. Add a ResourceUtilTest case that simulates a
WildFly vfs: URL and verifies it resolves to a readable file.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

Illegal argument exception reading oiosaml.properties file in oiosaml3-3.2.1 version

1 participant