Skip to content

Commit 322efcf

Browse files
adityamparikhclaude
andcommitted
fix(quality): resolve SonarQube violations
- S1488: return stream expression directly in validateCollectionExists instead of assigning to local variable - S7467: replace unused caught exceptions with _ (Java 25 unnamed variables) in CollectionService and SolrConfigUrlNormalizationTest Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: adityamparikh <aditya.m.parikh@gmail.com>
1 parent 96eb6c3 commit 322efcf

2 files changed

Lines changed: 10 additions & 12 deletions

File tree

src/main/java/org/apache/solr/mcp/server/metadata/CollectionService.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public List<String> listCollections() {
361361

362362
return new ArrayList<>(coreResponse.getCoreStatus().keySet());
363363
}
364-
} catch (SolrServerException | IOException e) {
364+
} catch (SolrServerException | IOException _) {
365365
return new ArrayList<>();
366366
}
367367
}
@@ -604,7 +604,7 @@ public CacheStats getCacheMetrics(String collection) {
604604
}
605605

606606
return stats;
607-
} catch (SolrServerException | IOException | RuntimeException e) {
607+
} catch (SolrServerException | IOException | RuntimeException _) {
608608
// RuntimeException covers SolrException subclasses (e.g. RemoteSolrException)
609609
// thrown when the /admin/mbeans endpoint is unavailable (removed in Solr 10).
610610
return null; // Return null instead of empty object
@@ -778,7 +778,7 @@ public HandlerStats getHandlerMetrics(String collection) {
778778
}
779779

780780
return stats;
781-
} catch (SolrServerException | IOException | RuntimeException e) {
781+
} catch (SolrServerException | IOException | RuntimeException _) {
782782
// RuntimeException covers SolrException subclasses (e.g. RemoteSolrException)
783783
// thrown when the /admin/mbeans endpoint is unavailable (removed in Solr 10).
784784
return null; // Return null instead of empty object
@@ -964,10 +964,8 @@ private boolean validateCollectionExists(String collection) {
964964
// Check if any of the returned collections start with the collection name (for
965965
// shard
966966
// names)
967-
boolean shardMatch = collections.stream().anyMatch(c -> c.startsWith(collection + SHARD_SUFFIX));
968-
969-
return shardMatch;
970-
} catch (Exception e) {
967+
return collections.stream().anyMatch(c -> c.startsWith(collection + SHARD_SUFFIX));
968+
} catch (Exception _) {
971969
return false;
972970
}
973971
}

src/test/java/org/apache/solr/mcp/server/config/SolrConfigUrlNormalizationTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void testUrlNormalization(String inputUrl, String expectedUrl) {
5151

5252
try {
5353
client.close();
54-
} catch (Exception e) {
54+
} catch (Exception _) {
5555
// Ignore close errors in test
5656
}
5757
}
@@ -68,7 +68,7 @@ void testUrlWithoutTrailingSlash() {
6868

6969
try {
7070
client.close();
71-
} catch (Exception e) {
71+
} catch (Exception _) {
7272
// Ignore close errors in test
7373
}
7474
}
@@ -85,7 +85,7 @@ void testUrlWithTrailingSlashButNoSolrPath() {
8585

8686
try {
8787
client.close();
88-
} catch (Exception e) {
88+
} catch (Exception _) {
8989
// Ignore close errors in test
9090
}
9191
}
@@ -102,7 +102,7 @@ void testUrlWithSolrPathButNoTrailingSlash() {
102102

103103
try {
104104
client.close();
105-
} catch (Exception e) {
105+
} catch (Exception _) {
106106
// Ignore close errors in test
107107
}
108108
}
@@ -119,7 +119,7 @@ void testUrlAlreadyProperlyFormatted() {
119119

120120
try {
121121
client.close();
122-
} catch (Exception e) {
122+
} catch (Exception _) {
123123
// Ignore close errors in test
124124
}
125125
}

0 commit comments

Comments
 (0)