Skip to content

fix: replace URL with URI in Set to avoid DNS lookups#13

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260331-032524-d94ebe72
Open

fix: replace URL with URI in Set to avoid DNS lookups#13
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260331-032524-d94ebe72

Conversation

@sonarqube-agent
Copy link
Copy Markdown

Changed Set to Set to prevent unintended DNS lookups during equals and hashCode operations. Using URI instead of URL in collections eliminates blocking network calls that can impact performance and reliability.

View Project in SonarCloud


Fixed Issues

java:S2112 - Use the URI class instead. • MAJORView issue

Location: core/src/main/java/com/webcohesion/enunciate/Enunciate.java:588

Why is this an issue?

The equals and hashCode methods of java.net.URL may trigger a name service lookup (typically DNS) to resolve the hostname or IP address. Depending on the configuration, and network status, this lookup can be time-consuming.

What changed

This is the direct fix for the issue of using java.net.URL in a Set, which can trigger DNS lookups during equals/hashCode operations. It changes the local variable declaration from Set to Set, eliminating the problematic URL-based Set at the exact line flagged by the static analysis warning.

--- a/core/src/main/java/com/webcohesion/enunciate/Enunciate.java
+++ b/core/src/main/java/com/webcohesion/enunciate/Enunciate.java
@@ -588,1 +588,1 @@ public class Enunciate implements Runnable {
-      Set<URL> sourceFiles = getSourceFileURLs();
+      Set<URI> sourceFiles = getSourceFileURLs();

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZZmtiWq2HDYqP_XyoAv for java:S2112 rule

Generated by SonarQube Agent (task: e50b25ec-9b82-4ec6-a218-cbbdece5e6b7)
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant