Handle nested JAR files in getClassNamesFromPackage and reduce cognit…#2620
Handle nested JAR files in getClassNamesFromPackage and reduce cognit…#2620k8s-ci-robot merged 7 commits intokubernetes-client:masterfrom
Conversation
…ive complexity method
|
|
|
Welcome @lobocode! |
…for faster lookups
|
there's a bunch of style/whitespace changes in this PR, can you run |
Ah, thanks for the tip (I can be a lil' scatterbrained sometimes). I already fixed it dude! About the duplicate PR, I closed the later one and am keeping just this one. As for SonarLint, I fixed only those that are considered critical and major (usually related to some complex functions that need to be broken down to improve code maintenance or something related to performance and security). Personally, not all the smells pointed out by SonarLint make sense. Once again, thank you so much for the tips dude! |
|
/lgtm It would be great to have a fatjar test at somepoint but that can be a later PR. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brendandburns, lobocode The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This commit updates the getClassNamesFromPackage method to properly handle nested JAR files within fat JARs. It checks for a second exclamation mark in the URL to identify nested JARs and uses a JarInputStream to read the entries and load the appropriate classes. This change ensures correct class loading when the application is packaged as a fat JAR with nested dependencies and breaks down the original getClassNamesFromPackage method into smaller, more manageable functions, following SonarLint rule java:S3776. The changes improve code readability and maintainability by reducing cognitive complexity.
This is a bug fix reported in #1659
This pull request includes a series of changes to address the issues and suggestions pointed out by the SonarLint analysis (only critical and major smells). Each change has been committed with an appropriate commit. These changes include improvements such as code simplification, use of Optional instead of null, more informative Javadoc tags, among others.
The refactoring of the findApiResourceByGroupVersionKind method involved creating a new HashMap to store API resources by their kind and group. This new map allows for faster lookup of resources during the method's execution, improving the overall performance. The previous implementation required iterating through all resources until a match was found, resulting in a slower search. The new implementation leverages the HashMap data structure, which provides faster access to resources by key. This refactoring improves the code's maintainability, readability, and efficiency.