aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-ws
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2023-01-09 10:21:46 +0100
committersonartech <sonartech@sonarsource.com>2023-01-10 20:03:01 +0000
commit295a87208f8c9898fbdc733a438587dc03a16877 (patch)
tree9771ee3245ab6e978b20b9d8b800450947fc7199 /server/sonar-webserver-ws
parent8868a5ff310c74f44f2c94e46ba31065017f50b4 (diff)
downloadsonarqube-295a87208f8c9898fbdc733a438587dc03a16877.tar.gz
sonarqube-295a87208f8c9898fbdc733a438587dc03a16877.zip
[NO-JIRA] Remove reported code smells about usage of instanceof
Diffstat (limited to 'server/sonar-webserver-ws')
-rw-r--r--server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WebServiceEngine.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WebServiceEngine.java b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WebServiceEngine.java
index 4c9d380cd2f..da04ef94fdd 100644
--- a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WebServiceEngine.java
+++ b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/WebServiceEngine.java
@@ -102,9 +102,9 @@ public class WebServiceEngine implements LocalConnector, Startable {
ActionExtractor actionExtractor = new ActionExtractor(request.getPath());
WebService.Action action = getAction(actionExtractor);
checkFound(action, "Unknown url : %s", request.getPath());
- if (request instanceof ValidatingRequest) {
- ((ValidatingRequest) request).setAction(action);
- ((ValidatingRequest) request).setLocalConnector(this);
+ if (request instanceof ValidatingRequest validatingRequest) {
+ validatingRequest.setAction(action);
+ validatingRequest.setLocalConnector(this);
}
checkActionExtension(actionExtractor.getExtension());
verifyRequest(action, request);
@@ -160,8 +160,8 @@ public class WebServiceEngine implements LocalConnector, Startable {
}
// response is not committed, status and content can be changed to return the error
- if (stream instanceof ServletResponse.ServletStream) {
- ((ServletResponse.ServletStream) stream).reset();
+ if (stream instanceof ServletResponse.ServletStream servletStream) {
+ servletStream.reset();
}
stream.setStatus(status);
stream.setMediaType(MediaTypes.JSON);
@@ -189,7 +189,7 @@ public class WebServiceEngine implements LocalConnector, Startable {
private static boolean isResponseCommitted(Response response) {
Response.Stream stream = response.stream();
// Request has been aborted by the client or the response was partially streamed, nothing can been done as Tomcat has committed the response
- return stream instanceof ServletResponse.ServletStream && ((ServletResponse.ServletStream) stream).response().isCommitted();
+ return stream instanceof ServletResponse.ServletStream servletStream && servletStream.response().isCommitted();
}
public static void writeErrors(JsonWriter json, List<String> errorMessages) {