-
Notifications
You must be signed in to change notification settings - Fork 43
[DROOLS-7608] EAP 7.4.15 VFS changes make drools PMML tests fail #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,11 @@ | |
import java.lang.ref.WeakReference; | ||
import java.lang.reflect.Method; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
import java.net.URLDecoder; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.Enumeration; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
|
@@ -194,6 +197,7 @@ private static void fetchKModuleFromSpring(URL kModuleUrl) { | |
} | ||
|
||
private static InternalKieModule fetchKModule(URL url, String fixedURL) { | ||
log.info( "fetchKModule url=" + url + " fixedURL=" + fixedURL); | ||
if ( url.getPath().endsWith("-spring.xml")) { | ||
// the entire kmodule creation is happening in the kie-spring module, | ||
// hence we force a null return | ||
|
@@ -274,6 +278,7 @@ private static boolean isJarFile(String urlPathToAdd, String rootPath) { | |
} | ||
|
||
private static String getPomPropertiesFromZipFile(String rootPath) { | ||
log.info("getPomPropertiesFromZipFile : rootPath = " + rootPath); | ||
File actualZipFile = new File( rootPath ); | ||
if ( !actualZipFile.exists() ) { | ||
if (rootPath.indexOf(".jar!") > 0) { | ||
|
@@ -303,7 +308,7 @@ private static String getPomPropertiesFromZipFile(String rootPath) { | |
} | ||
|
||
private static String getPomPropertiesFromZipStream(String rootPath) { | ||
|
||
log.info("getPomPropertiesFromZipStream : rootPath = " + rootPath); | ||
rootPath = rootPath.substring( rootPath.lastIndexOf( '!' ) + 1 ); | ||
// read jar file from uber-jar | ||
InputStream in = ClasspathKieProject.class.getResourceAsStream(rootPath); | ||
|
@@ -395,9 +400,10 @@ public static String fixURLFromKProjectPath(URL url) { | |
urlType = urlPath.substring( 0, | ||
colonIndex ); | ||
} | ||
|
||
urlPath = url.getPath(); | ||
|
||
log.info("fixURLFromKProjectPath: url=" + urlPath); | ||
|
||
if ( "jar".equals( urlType ) ) { | ||
// switch to using getPath() instead of toExternalForm() | ||
if ( urlPath.indexOf( '!' ) > 0 ) { | ||
|
@@ -464,14 +470,18 @@ private static String getPathForVFS(URL url) { | |
log.warn( "Found virtual file " + url + " but org.jboss.vfs.VFS is not available on the classpath" ); | ||
} | ||
} | ||
log.info("getPathForVFS: m=" + m + " m2=" + m2); | ||
|
||
if (m == null || m2 == null) { | ||
return url.getPath(); | ||
} | ||
|
||
String path = null; | ||
try { | ||
Object virtualFile = m2.invoke(null, url.toURI()); | ||
log.info("virtualFile=" + virtualFile); | ||
File f = (File)m.invoke( m2.invoke(null, url.toURI()) ); | ||
log.info("f=" + f); | ||
path = f.getPath(); | ||
} catch (Exception e) { | ||
log.error( "Error when reading virtual file from " + url.toString(), e ); | ||
|
@@ -489,6 +499,8 @@ private static String getPathForVFS(URL url) { | |
int kModulePos = urlString.length() - ("/" + KieModuleModelImpl.KMODULE_JAR_PATH).length(); | ||
boolean isInJar = urlString.substring(kModulePos - 4, kModulePos).equals(".jar"); | ||
|
||
log.info(" isInJar=" + isInJar + " kModulePos=" + kModulePos + " urlString=" + urlString + " path=" + path); | ||
|
||
try { | ||
if (isInJar && path.contains("contents" + File.separator)) { | ||
String jarName = urlString.substring(0, kModulePos); | ||
|
@@ -500,6 +512,28 @@ private static String getPathForVFS(URL url) { | |
path = path.substring( 0, path.length() - ("/" + KieModuleModelImpl.KMODULE_JAR_PATH).length() ); | ||
} | ||
|
||
if (!Files.exists(Paths.get(path))) { | ||
log.info("path : " + path + " --- does not exist"); | ||
log.info("fallback for EAP 7.14.5"); | ||
try { | ||
Method m3 = Class.forName("org.jboss.vfs.VFS").getDeclaredMethod("getMount", Class.forName("org.jboss.vfs.VirtualFile")); | ||
m3.setAccessible(true); | ||
Method m4 = Class.forName("org.jboss.vfs.VFS$Mount").getDeclaredMethod("getFileSystem"); | ||
m4.setAccessible(true); | ||
Method m5 = Class.forName("org.jboss.vfs.spi.FileSystem").getMethod("getMountSource"); | ||
|
||
Object virtualFile = m2.invoke(null, url.toURI()); | ||
Object mount = m3.invoke(null, virtualFile); | ||
Object fileSystem = m4.invoke(mount); | ||
log.info("fileSystem : " + fileSystem); | ||
File mountSource = (File) m5.invoke(fileSystem); | ||
log.info("mountSource : " + mountSource); | ||
path = mountSource.getPath(); | ||
} catch (Exception e) { | ||
e.printStackTrace(System.out); | ||
} | ||
} | ||
Comment on lines
+515
to
+535
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the main part of the (temporary) fix. I was not able to find public methods to get the physical file (e.g. |
||
|
||
log.info( "Virtual file physical path = " + path ); | ||
return path; | ||
} catch (Exception e) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can confirm that
VirtualFile.getPhysicalFile
returns file path underdeployment
directory. (e.g.target/cargo/configurations/wildfly23x/tmp/vfs/deployment/deploymente0f78ed559baff33/kie-pmml-7.75.0-SNAPSHOT.jar-9458e4090f0fae31/contents/META-INF/kmodule.xml
)Actually, the
kmodule.xml
is created on the file path as a cache file. But what we want here is thekie-pmml-7.75.0-SNAPSHOT.jar
which is undertemp
directory.