Skip to content

Commit

Permalink
Fix loading of properties from jar bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
johnthuss committed Jul 7, 2014
1 parent 36c9364 commit 1027548
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.regex.Pattern;

import javax.xml.parsers.DocumentBuilderFactory;

Expand Down Expand Up @@ -737,12 +738,15 @@ private void collectMainProps(String userName) {
URL userPropertiesPath = null;
String mainBundleName = NSProperties._mainBundleName();

// Look for a jar file name like: myapp[-1.0][-SNAPSHOT].jar
Pattern mainBundleJarPattern = Pattern.compile("\\b" + mainBundleName.toLowerCase() + "[-\\.\\d]*(snapshot)?\\.jar");

while (jarBundles.hasMoreElements()) {
URL url = jarBundles.nextElement();

String urlAsString = url.toString();

if (urlAsString.contains(mainBundleName + ".jar")) {
if (mainBundleJarPattern.matcher(urlAsString.toLowerCase()).find()) {
try {
propertiesPath = new URL(URLDecoder.decode(urlAsString, CharEncoding.UTF_8));
userPropertiesPath = new URL(propertiesPath.toExternalForm() + userName);
Expand Down

0 comments on commit 1027548

Please sign in to comment.