From 8b232cd2b854b161f4a4879df5a2d9d13444074d Mon Sep 17 00:00:00 2001 From: "igor.petrenko" Date: Tue, 27 Feb 2024 19:35:04 +0200 Subject: [PATCH] OAP-246 fix: java.nio.file.FileSystemNotFoundException --- .../HoconFactoryWithSystemProperties.java | 30 ++++++++++++------- pom.xml | 2 +- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/oap-stdlib/src/main/java/oap/json/HoconFactoryWithSystemProperties.java b/oap-stdlib/src/main/java/oap/json/HoconFactoryWithSystemProperties.java index cc84aa04a4..691be8a8ff 100644 --- a/oap-stdlib/src/main/java/oap/json/HoconFactoryWithSystemProperties.java +++ b/oap-stdlib/src/main/java/oap/json/HoconFactoryWithSystemProperties.java @@ -56,18 +56,26 @@ protected HoconTreeTraversingParser _createParser( Reader r, IOContext ctxt ) th var options = ConfigParseOptions.defaults(); Object rawContent = ctxt.contentReference().getRawContent(); - if( rawContent instanceof URL urlContext ) { - URL parentURL = Paths.get( urlContext.toURI() ).getParent().toUri().toURL(); + log.trace( "rawContent {} rawContentClazz {}", rawContent, rawContent.getClass() ); - options = options.setClassLoader( new URLClassLoader( new URL[] { parentURL } ) ); - } else if( rawContent instanceof File fileContext ) { - URL parentURL = Paths.get( fileContext.toURI() ).getParent().toUri().toURL(); - - options = options.setClassLoader( new URLClassLoader( new URL[] { parentURL } ) ); - } else if( rawContent instanceof URI uriContext ) { - URL parentURL = Paths.get( uriContext ).getParent().toUri().toURL(); - - options = options.setClassLoader( new URLClassLoader( new URL[] { parentURL } ) ); + switch( rawContent ) { + case URL urlContext -> { + URL parentURL = urlContext.toURI().resolve( "" ).toURL(); + log.trace( "parentURL {}", parentURL ); + options = options.setClassLoader( new URLClassLoader( new URL[] { parentURL } ) ); + } + case File fileContext -> { + URL parentURL = Paths.get( fileContext.toURI() ).getParent().toUri().toURL(); + log.trace( "parentURL {}", parentURL ); + options = options.setClassLoader( new URLClassLoader( new URL[] { parentURL } ) ); + } + case URI uriContext -> { + URL parentURL = uriContext.resolve( "" ).toURL(); + log.trace( "parentURL {}", parentURL ); + options = options.setClassLoader( new URLClassLoader( new URL[] { parentURL } ) ); + } + default -> { + } } diff --git a/pom.xml b/pom.xml index 4911e72d90..47b0bf71ed 100644 --- a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ - 21.15.2 + 21.15.3 21.0.0 21.0.1