Skip to content

Commit

Permalink
Merge pull request #334 from zxy0728/master
Browse files Browse the repository at this point in the history
fix the problem of profiling webservice url error about some applications
  • Loading branch information
zxy0728 authored Jun 28, 2018
2 parents f0cd13c + d063fca commit b16cfea
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ public boolean parse(DescriptorCollector dc, Node node) {
String[] paths = StringHelper.tokenizeToStringArray(springConfigLocations.get(0),
CONFIG_LOCATION_DELIMITERS);
for (String path : paths) {
files.addAll(getFileLocation(webAppRoot, path));
files.addAll(getFileLocation(webAppRoot, path, null));
}
}

Expand Down Expand Up @@ -732,7 +732,7 @@ public boolean parse(DescriptorCollector dc, Node node) {

String importFileRelativePath = importFilePathPart1 + "/" + importFilePathPart2;

importfile.addAll(getFileLocation(webAppRoot, importFileRelativePath));
importfile.addAll(getFileLocation(webAppRoot, importFileRelativePath, importFilePathPart2));
}
}
catch (IOException e) {
Expand Down Expand Up @@ -945,7 +945,8 @@ private String getImplClassAsKey(String key, Node jaxws, ClassLoader cl, String
* @param filepath
* @return
*/
private List<String> getFileLocation(String webAppRoot, String path) {
@SuppressWarnings({ "unchecked", "rawtypes" })
private List<String> getFileLocation(String webAppRoot, String path, String importFilePathPart2) {

List<String> absPaths = new ArrayList<String>();
ClassLoader webappclsLoader = (ClassLoader) this.getContext().get(InterceptContext.class)
Expand Down Expand Up @@ -979,6 +980,20 @@ private List<String> getFileLocation(String webAppRoot, String path) {

File location = null;
if (resources != null) {
if (importFilePathPart2 != null) {
try {
// spring: if resource belongs to ClassPathResource or its subclass, try loading "org.springframework.core.io.ClassPathResource" and get resources again,
// in case that files cannot be found in relative path "path".
Class cpRes = webappclsLoader.loadClass("org.springframework.core.io.ClassPathResource");
if(cpRes != null && cpRes.isAssignableFrom(resources[0].getClass())) {
resources = (Object[]) ReflectionHelper.invoke(SPRING_ResourcePatternResolver_CLASSNAME, resourceloader,
"getResources", new Class[] { String.class }, new String[] { importFilePathPart2 }, webappclsLoader);
}
}
catch (ClassNotFoundException e1) {
// ignore
}
}
for (Object resource : resources) {
try {
location = (File) ReflectionHelper.invoke(SPRING_RESOURCE_CLASSNAME, resource, "getFile", null,
Expand Down

0 comments on commit b16cfea

Please sign in to comment.