7.1.x - Simplify star imports check#15361
Merged
codeconsole merged 3 commits intoapache:7.1.xfrom Feb 1, 2026
Merged
Conversation
sbglasius
approved these changes
Jan 30, 2026
Contributor
sbglasius
left a comment
There was a problem hiding this comment.
When tests pass, then this PR is approved.
matrei
approved these changes
Jan 31, 2026
Comment on lines
273
to
296
| protected boolean isClassOnClasspath(FileCollection classpath, String className) { | ||
| String classPath = className.replace('.', '/') + '.class' | ||
| for (File file : classpath.files) { | ||
| try { | ||
| if (file.isFile() && file.name.endsWith('.jar')) { | ||
| def zip = new java.util.zip.ZipFile(file) | ||
| try { | ||
| if (zip.getEntry(classPath) != null) { | ||
| return true | ||
| } | ||
| } finally { | ||
| zip.close() | ||
| } | ||
| } else if (file.isDirectory()) { | ||
| if (new File(file, classPath).exists()) { | ||
| return true | ||
| } | ||
| } | ||
| } catch (Exception ignored) { | ||
| } | ||
| } catch (Exception e) { | ||
| project.logger.debug("Failed to check for dependency ${group}:${name} in ${configurationName}: ${e.message}") | ||
| return false | ||
| } | ||
| return false | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
Suggested change
| protected boolean isClassOnClasspath(FileCollection classpath, String className) { | |
| String classPath = className.replace('.', '/') + '.class' | |
| for (File file : classpath.files) { | |
| try { | |
| if (file.isFile() && file.name.endsWith('.jar')) { | |
| def zip = new java.util.zip.ZipFile(file) | |
| try { | |
| if (zip.getEntry(classPath) != null) { | |
| return true | |
| } | |
| } finally { | |
| zip.close() | |
| } | |
| } else if (file.isDirectory()) { | |
| if (new File(file, classPath).exists()) { | |
| return true | |
| } | |
| } | |
| } catch (Exception ignored) { | |
| } | |
| } catch (Exception e) { | |
| project.logger.debug("Failed to check for dependency ${group}:${name} in ${configurationName}: ${e.message}") | |
| return false | |
| } | |
| return false | |
| } | |
| private static boolean isClassOnClasspath(FileCollection classpath, String className) { | |
| def classEntry = className.replace('.', '/') + '.class' | |
| classpath.files.any { f -> | |
| try { | |
| if (f.file && f.name.endsWith('.jar')) { | |
| new ZipFile(f).withCloseable { zip -> | |
| zip.getEntry(classEntry) != null | |
| } | |
| } else if (f.directory) { | |
| new File(f, classEntry).exists() | |
| } else { | |
| false | |
| } | |
| } catch (Exception ignored) { | |
| false | |
| } | |
| } | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rather than searching the dependency hierarchy, just check to see if the class is in the classpath.
enabled by: