Skip to content

Commit

Permalink
PLUGINAPI-45 Remove javax.servlet dependency.
Browse files Browse the repository at this point in the history
 Move to version 11.0.
  • Loading branch information
steve-marion-sonarsource committed Dec 10, 2024
1 parent decceab commit ab23710
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 444 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 11.0
* Remove usage of `javax-servlet-api`:
* Remove ~~`org.sonar.api.web.ServletFilter`~~
* Remove ~~`javax.servlet.http.HttpServletRequest`~~
* Remove ~~`javax.servlet.http.HttpServletResponse`~~

## 10.14

* Remove deprecation on `org.sonar.api.rules.RuleType`, `org.sonar.api.batch.rule.Severity`, `org.sonar.api.rule.Severity` and related usages.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
group=org.sonarsource.api.plugin
version=10.15-SNAPSHOT
version=11.0-SNAPSHOT
description=Plugin API for SonarQube, SonarCloud and SonarLint
org.gradle.jvmargs=-Xmx2048m
1 change: 0 additions & 1 deletion plugin-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dependencies {
implementation project(':check-api')

compileOnly libs.jsr305
compileOnly libs.javax.servlet.api

testImplementation libs.junit4
testImplementation libs.junit5
Expand Down
15 changes: 2 additions & 13 deletions plugin-api/src/main/java/org/sonar/api/security/Authenticator.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.sonar.api.security;

import javax.annotation.Nullable;
import javax.servlet.http.HttpServletRequest;
import org.sonar.api.ExtensionPoint;
import org.sonar.api.server.ServerSide;
import org.sonar.api.server.http.HttpRequest;
Expand All @@ -44,18 +43,16 @@ public abstract class Authenticator {
public static final class Context {
private String username;
private String password;
private HttpServletRequest request;
private HttpRequest httpRequest;

/**
* This class is not meant to be instantiated by plugins, except for tests.
*/
public Context(@Nullable String username, @Nullable String password, HttpRequest httpRequest, HttpServletRequest request) {
requireNonNull(request);
public Context(@Nullable String username, @Nullable String password, HttpRequest httpRequest) {
requireNonNull(httpRequest);
this.username = username;
this.password = password;
this.httpRequest = httpRequest;
this.request = request;
}

/**
Expand All @@ -72,14 +69,6 @@ public String getPassword() {
return password;
}

/**
* @deprecated since 9.16. Use {@link #getHttpRequest()} instead.
*/
@Deprecated(since = "9.16", forRemoval = true)
public HttpServletRequest getRequest() {
return request;
}

/**
* @since 9.16
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.util.Collection;
import javax.annotation.CheckForNull;
import javax.servlet.http.HttpServletRequest;
import org.sonar.api.server.http.HttpRequest;

/**
Expand All @@ -46,30 +45,20 @@ public Collection<String> doGetGroups(Context context) {

public static final class Context {
private String username;
private HttpServletRequest request;
private HttpRequest httpRequest;

/**
* This class is not meant to be instantiated by plugins, except for tests.
*/
public Context(String username, HttpRequest httpRequest, HttpServletRequest request) {
public Context(String username, HttpRequest httpRequest) {
this.username = username;
this.httpRequest = httpRequest;
this.request = request;
}

public String getUsername() {
return username;
}

/**
* @deprecated since 9.16. Use {@link #getHttpRequest()} instead.
*/
@Deprecated(since = "9.16", forRemoval = true)
public HttpServletRequest getRequest() {
return request;
}

/**
* @since 9.16
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.sonar.api.security;

import javax.annotation.Nullable;
import javax.servlet.http.HttpServletRequest;
import org.sonar.api.server.http.HttpRequest;

/**
Expand All @@ -43,30 +42,20 @@ public UserDetails doGetUserDetails(Context context) {

public static final class Context {
private String username;
private HttpServletRequest request;
private HttpRequest httpRequest;

/**
* This class is not meant to be instantiated by plugins, except for tests.
*/
public Context(@Nullable String username, HttpRequest httpRequest, HttpServletRequest request) {
public Context(@Nullable String username, HttpRequest httpRequest) {
this.username = username;
this.httpRequest = httpRequest;
this.request = request;
}

public String getUsername() {
return username;
}

/**
* @deprecated since 9.16. Use {@link #getHttpRequest()} instead.
*/
@Deprecated(since = "9.16", forRemoval = true)
public HttpServletRequest getRequest() {
return request;
}

/**
* @since 9.16
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package org.sonar.api.server.authentication;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.sonar.api.server.http.HttpRequest;
import org.sonar.api.server.http.HttpResponse;

Expand Down Expand Up @@ -51,24 +49,6 @@ interface Context {
*/
HttpResponse getHttpResponse();

/**
* Get the received HTTP request.
* Note - {@code getRequest().getSession()} must not be used in order to support
* future clustering of web servers without stateful server sessions.
*
* @deprecated since 9.16. Use {@link #getHttpRequest()} instead.
*/
@Deprecated(since = "9.16", forRemoval = true)
HttpServletRequest getRequest();

/**
* Get the HTTP response to send
*
* @deprecated since 9.16. Use {@link #getHttpResponse()} instead.
*/
@Deprecated(since = "9.16", forRemoval = true)
HttpServletResponse getResponse();

/**
* Return the server base URL
* @see org.sonar.api.platform.Server#getPublicRootUrl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package org.sonar.api.server.authentication;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.sonar.api.server.http.HttpRequest;
import org.sonar.api.server.http.HttpResponse;

Expand Down Expand Up @@ -60,24 +58,6 @@ interface OAuth2Context {
* @since 9.16
*/
HttpResponse getHttpResponse();

/**
* Get the received HTTP request.
* Note - {@code getRequest().getSession()} must not be used in order to support
* future clustering of web servers without stateful server sessions.
*
* @deprecated since 9.16. Use {@link #getHttpRequest()} instead.
*/
@Deprecated(since = "9.16", forRemoval = true)
HttpServletRequest getRequest();

/**
* Get the HTTP response to send
*
* @deprecated since 9.16. Use {@link #getHttpResponse()} instead.
*/
@Deprecated(since = "9.16", forRemoval = true)
HttpServletResponse getResponse();
}

interface InitContext extends OAuth2Context {
Expand Down
83 changes: 0 additions & 83 deletions plugin-api/src/main/java/org/sonar/api/web/ServletFilter.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;
import javax.servlet.http.HttpServletRequest;
import org.junit.Test;
import org.sonar.api.server.http.HttpRequest;

Expand All @@ -39,8 +38,7 @@ public void doGetGroupsNoOverride() {
};

String userName = "foo";
assertThat(groupsProvider.doGetGroups(new ExternalGroupsProvider.Context(userName, mock(HttpRequest.class),
mock(HttpServletRequest.class)))).isNull();
assertThat(groupsProvider.doGetGroups(new ExternalGroupsProvider.Context(userName, mock(HttpRequest.class)))).isNull();
}

@Test
Expand All @@ -63,7 +61,7 @@ public Collection<String> doGetGroups(Context context) {
private static void runDoGetGroupsTests(ExternalGroupsProvider groupsProvider, Map<String, Collection<String>> userGroupsMap) {
for (Map.Entry<String, Collection<String>> userGroupMapEntry : userGroupsMap.entrySet()) {
Collection<String> groups = groupsProvider.doGetGroups(new ExternalGroupsProvider.Context(
userGroupMapEntry.getKey(), mock(HttpRequest.class), mock(HttpServletRequest.class)));
userGroupMapEntry.getKey(), mock(HttpRequest.class)));
assertThat(groups).isEqualTo(userGroupMapEntry.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.sonar.api.security;

import com.google.common.base.Preconditions;
import javax.servlet.http.HttpServletRequest;
import org.junit.Test;
import org.sonar.api.server.http.HttpRequest;

Expand All @@ -42,7 +41,7 @@ public UserDetails doGetUserDetails(Context context) {
return user;
}
};
UserDetails user = provider.doGetUserDetails(new ExternalUsersProvider.Context("foo", mock(HttpRequest.class), mock(HttpServletRequest.class)));
UserDetails user = provider.doGetUserDetails(new ExternalUsersProvider.Context("foo", mock(HttpRequest.class)));

assertThat(user.getName()).isEqualTo("foo");
assertThat(user.getEmail()).isEqualTo("[email protected]");
Expand Down
Loading

0 comments on commit ab23710

Please sign in to comment.