ASF Bugzilla – Attachment 32304 Details for
Bug 57367
If JAR scan experiences a stack overflow, give the URL from which each class in the loop was loaded in the complaint
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch that implements the feature enhancement
ContextConfig.diff (text/plain), 5.86 KB, created by
Edward Kuns
on 2014-12-18 18:39:27 UTC
(
hide
)
Description:
Proposed patch that implements the feature enhancement
Filename:
MIME Type:
Creator:
Edward Kuns
Created:
2014-12-18 18:39:27 UTC
Size:
5.86 KB
patch
obsolete
>--- /cygdrive/d/Local-Storage/Java-Packages/Apache/tomcat/apache-tomcat-7.0.57-src/java/org/apache/catalina/startup/ContextConfig.java 2014-12-05 18:19:41.771516300 -0600 >+++ ./ContextConfig.java 2014-12-18 12:21:42.016887400 -0600 >@@ -1945,7 +1945,7 @@ > try { > is = jar.getEntryInputStream(); > processAnnotationsStream( >- is, fragment, handlesTypesOnly); >+ is, fragment, handlesTypesOnly, url.toString()); > } catch (IOException e) { > log.error(sm.getString("contextConfig.inputStreamJar", > entryName, url),e); >@@ -2006,7 +2006,7 @@ > try { > is = dcUrlConn.getInputStream(); > processAnnotationsStream( >- is, fragment, handlesTypesOnly); >+ is, fragment, handlesTypesOnly,url.getPath()); > } catch (IOException e) { > log.error(sm.getString("contextConfig.inputStreamJndi", > url),e); >@@ -2043,7 +2043,7 @@ > FileInputStream fis = null; > try { > fis = new FileInputStream(file); >- processAnnotationsStream(fis, fragment, handlesTypesOnly); >+ processAnnotationsStream(fis, fragment, handlesTypesOnly, file.getAbsolutePath()); > } catch (IOException e) { > log.error(sm.getString("contextConfig.inputStreamFile", > file.getAbsolutePath()),e); >@@ -2064,12 +2064,12 @@ > > > protected void processAnnotationsStream(InputStream is, WebXml fragment, >- boolean handlesTypesOnly) >+ boolean handlesTypesOnly, String url) > throws ClassFormatException, IOException { > > ClassParser parser = new ClassParser(is); > JavaClass clazz = parser.parse(); >- checkHandlesTypes(clazz); >+ checkHandlesTypes(clazz, url); > > if (handlesTypesOnly) { > return; >@@ -2100,7 +2100,7 @@ > * for an annotation that matches {@link HandlesTypes}. > * @param javaClass > */ >- protected void checkHandlesTypes(JavaClass javaClass) { >+ protected void checkHandlesTypes(JavaClass javaClass, String url) { > > // Skip this if we can > if (typeInitializerMap.size() == 0) >@@ -2117,7 +2117,7 @@ > Class<?> clazz = null; > if (handlesTypesNonAnnotations) { > // This *might* be match for a HandlesType. >- populateJavaClassCache(className, javaClass); >+ populateJavaClassCache(className, javaClass, url); > JavaClassCacheEntry entry = javaClassCache.get(className); > if (entry.getSciSet() == null) { > try { >@@ -2183,7 +2183,7 @@ > JavaClassCacheEntry entry) { > JavaClassCacheEntry start = entry; > StringBuilder msg = new StringBuilder(className); >- msg.append("->"); >+ msg.append("(").append(entry.getUrl()).append(")->"); > > String parentName = entry.getSuperclassName(); > JavaClassCacheEntry parent = javaClassCache.get(parentName); >@@ -2191,7 +2191,7 @@ > > while (count < 100 && parent != null && parent != start) { > msg.append(parentName); >- msg.append("->"); >+ msg.append("(").append(parent.getUrl()).append(")->"); > > count ++; > parentName = parent.getSuperclassName(); >@@ -2199,17 +2199,27 @@ > } > > msg.append(parentName); >+ if (parent != null) { >+ if (parent == start) { >+ msg.append("(loop to first entry!)"); >+ } else { >+ msg.append("(").append(parent.getUrl()).append(")"); >+ } >+ } >+ if (count == 100 && parent != null && parent != start) { >+ msg.append("->..."); >+ } > > return msg.toString(); > } > >- private void populateJavaClassCache(String className, JavaClass javaClass) { >+ private void populateJavaClassCache(String className, JavaClass javaClass, String url) { > if (javaClassCache.containsKey(className)) { > return; > } > > // Add this class to the cache >- javaClassCache.put(className, new JavaClassCacheEntry(javaClass)); >+ javaClassCache.put(className, new JavaClassCacheEntry(javaClass, url)); > > populateJavaClassCache(javaClass.getSuperclassName()); > >@@ -2229,7 +2239,8 @@ > ClassParser parser = new ClassParser(is); > try { > JavaClass clazz = parser.parse(); >- populateJavaClassCache(clazz.getClassName(), clazz); >+ String url = context.getLoader().getClassLoader().getResource(name).toString(); >+ populateJavaClassCache(clazz.getClassName(), clazz, url); > } catch (ClassFormatException e) { > log.debug(sm.getString("contextConfig.invalidSciHandlesTypes", > className), e); >@@ -2732,17 +2743,23 @@ > } > > private static class JavaClassCacheEntry { >+ private final String url; > public final String superclassName; > > public final String[] interfaceNames; > > private Set<ServletContainerInitializer> sciSet = null; > >- public JavaClassCacheEntry(JavaClass javaClass) { >+ public JavaClassCacheEntry(JavaClass javaClass, String url) { >+ this.url = url; > superclassName = javaClass.getSuperclassName(); > interfaceNames = javaClass.getInterfaceNames(); > } > >+ public String getUrl() { >+ return url; >+ } >+ > public String getSuperclassName() { > return superclassName; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 57367
: 32304