From ec489fb3362bebba5c06a8910cd7b2d8d85ca6c1 Mon Sep 17 00:00:00 2001 From: Netta Gavrieli Date: Tue, 30 Jul 2013 10:22:50 +0300 Subject: [PATCH] Java - Fixed loading native libraries from paths that contain international characters. This fixes Hyperic bug https://jira.hyperic.com/browse/HQ-4227 --- .../hyperic_jni/src/org/hyperic/jni/ArchLoader.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchLoader.java b/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchLoader.java index 6a4fd8c3..c44fb5cd 100644 --- a/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchLoader.java +++ b/bindings/java/hyperic_jni/src/org/hyperic/jni/ArchLoader.java @@ -17,6 +17,7 @@ package org.hyperic.jni; import java.io.File; +import java.io.UnsupportedEncodingException; import java.util.StringTokenizer; import java.net.URL; import java.net.URLClassLoader; @@ -315,7 +316,16 @@ public class ArchLoader { if ((file != null) && ((file = file.getParentFile()) != null)) { - String dir = URLDecoder.decode(file.toString()); + String dir; + try { + // Passing UTF-8 according to the recommendation in the URLDecoder.decode JavaDoc. + dir = URLDecoder.decode(file.toString(), "UTF-8"); + } catch (UnsupportedEncodingException e) { + String msg = "Unsupported encoding in file name: " + file.toString(); + ArchLoaderException archLoaderException = new ArchLoaderException(msg); + archLoaderException.initCause(e); + throw archLoaderException; + } if (findNativeLibrary(dir, libName)) { return dir; }