Commit c0fd2f7
authored
Java: avoid provider resource extraction when library already exists in onnxruntime.native.path (microsoft#27668)
## Summary
Fixes the Java native provider loading flow so that
`extractProviderLibrary` checks
`onnxruntime.native.path` before attempting extraction from classpath
resources.
Previously, when a provider library was already present in
`onnxruntime.native.path`,
the Java loader could still attempt `extractFromResources(...)` first,
and only fall
back to the configured native path afterwards. This caused an
unnecessary extraction
attempt even though the library was already available on disk.
This change updates the lookup order to:
1. Return immediately if the provider was already marked as ready
2. Check whether the provider library already exists in
`onnxruntime.native.path`
3. Only if not found there, attempt extraction from classpath resources
## Tests
Added a regression test covering the case where the requested provider
library already
exists in `onnxruntime.native.path`.
The test verifies that:
- `extractProviderLibrary(...)` returns `true`
- extraction from resources is not attempted in that case
A small test-only hook was added to observe calls to
`extractFromResources(...)` so the
regression can be validated directly and deterministically.
## Issue
Fixes microsoft#276551 parent 44e8b38 commit c0fd2f7
1 file changed
Lines changed: 11 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
310 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
311 | 320 | | |
312 | 321 | | |
313 | 322 | | |
314 | 323 | | |
315 | 324 | | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
| 325 | + | |
330 | 326 | | |
331 | 327 | | |
332 | 328 | | |
| |||
0 commit comments