This is an automated email from the ASF dual-hosted git repository.

pzampino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git


The following commit(s) were added to refs/heads/master by this push:
     new d21cf8f63 KNOX-3047 - Classpath extension for optional dependencies 
(#925)
d21cf8f63 is described below

commit d21cf8f63944afdd5d4ffa0236a16cd788d9a14a
Author: hanicz <[email protected]>
AuthorDate: Thu Aug 1 17:45:14 2024 +0200

    KNOX-3047 - Classpath extension for optional dependencies (#925)
---
 .../src/main/resources/META-INF/launcher.cfg                |  2 +-
 .../main/java/org/apache/knox/gateway/launcher/Command.java | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/gateway-server-launcher/src/main/resources/META-INF/launcher.cfg 
b/gateway-server-launcher/src/main/resources/META-INF/launcher.cfg
index 3554a23da..5a0c262d9 100644
--- a/gateway-server-launcher/src/main/resources/META-INF/launcher.cfg
+++ b/gateway-server-launcher/src/main/resources/META-INF/launcher.cfg
@@ -13,6 +13,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 main.class = org.apache.knox.gateway.GatewayServer
-class.path = ../conf;../lib/*.jar;../dep/*.jar;../ext;../ext/*.jar
+class.path = 
../conf;../lib/*.jar;../dep/*.jar;../ext;../ext/*.jar;/usr/share/java/*.jar
 GATEWAY_HOME=${launcher.dir}/..
 log4j.configurationFile=${GATEWAY_HOME}/conf/${launcher.name}-log4j2.xml
diff --git 
a/gateway-util-launcher/src/main/java/org/apache/knox/gateway/launcher/Command.java
 
b/gateway-util-launcher/src/main/java/org/apache/knox/gateway/launcher/Command.java
index 9eb57754a..f0a3b4945 100644
--- 
a/gateway-util-launcher/src/main/java/org/apache/knox/gateway/launcher/Command.java
+++ 
b/gateway-util-launcher/src/main/java/org/apache/knox/gateway/launcher/Command.java
@@ -115,7 +115,7 @@ class Command {
     StringTokenizer parser = new StringTokenizer( classPath, CLASS_PATH_DELIM, 
false );
     while( parser.hasMoreTokens() ) {
       String libPath = parser.nextToken().trim();
-      File libFile = new File( base, libPath );
+      File libFile = loadFileByPath( base, libPath );
       if( libFile.canRead() && ( libFile.isFile() || libFile.isDirectory() ) ) 
{
         urls.add( libFile.toURI().toURL() );
       } else if( libPath.endsWith( "*" ) || libPath.endsWith( "*.jar" ) ) {
@@ -131,6 +131,17 @@ class Command {
     return urls;
   }
 
+  /* KNOX-3047 */
+  private static File loadFileByPath( File base, String libPath ) {
+    File file;
+    if( libPath.startsWith( "/" ) ) {
+      file = new File( libPath );
+    } else {
+      file = new File( base, libPath );
+    }
+    return file;
+  }
+
   private static class WildcardFilenameFilter implements FilenameFilter {
     private static String SAFE = new String( new char[]{ (char)0 } );
 

Reply via email to