Skip to content

Commit

Permalink
update load build condition
Browse files Browse the repository at this point in the history
  • Loading branch information
DevChu committed May 27, 2016
1 parent 7b22bed commit 19202a7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion zk/src/org/zkoss/zk/ui/impl/AbstractWebApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
*/
package org.zkoss.zk.ui.impl;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -393,7 +396,21 @@ public void sessionDestroyed(Session sess) {
public static synchronized String loadBuild() {
if (_build == null) {
final String FILE = "/metainfo/zk/build";
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(FILE);
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream is = null;
try {
Enumeration<URL> en = cl.getResources(FILE.substring(1)); // should not start with "/"
while (en.hasMoreElements()) {
URL url = en.nextElement();
String path = url.getPath();
if (path != null && (path.contains("zk.jar!" + FILE) || path.matches("(.*)zk-\\d.*\\.jar\\!" + FILE))) { //the filename of jar might change
is = url.openStream();
break;
}
}
} catch (IOException e) {
//do nothing
}
if (is == null) {
is = AbstractWebApp.class.getResourceAsStream(FILE);
if (is == null)
Expand Down

0 comments on commit 19202a7

Please sign in to comment.