Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLUGINAPI-112 PLUGINAPI-45 remove javax.servlet #204

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# 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.
* Remove deprecation on `org.sonar.api.rules.RuleType`, `org.sonar.api.batch.rule.Severity`, `org.sonar.api.rule.Severity` and related usages.
* Remove deprecation on `org.sonar.api.server.rule.internal.ImpactMapper` and `org.sonar.api.server.rule.RuleTagsToTypeConverter`.
* Remove deprecation on metrics `org.sonar.api.measures.CoreMetrics.BLOCKER_VIOLATIONS`, `org.sonar.api.measures.CoreMetrics.CRITICAL_VIOLATIONS`, `org.sonar.api.measures.CoreMetrics.MAJOR_VIOLATIONS`, `org.sonar.api.measures.CoreMetrics.MINOR_VIOLATIONS`, `org.sonar.api.measures.CoreMetrics.INFO_VIOLATIONS`, `org.sonar.api.measures.CoreMetrics.NEW_BLOCKER_VIOLATIONS`, , `org.sonar.api.measures.CoreMetrics.NEW_CRITICAL_VIOLATIONS`, `org.sonar.api.measures.CoreMetrics.NEW_MAJOR_VIOLATIONS`, `org.sonar.api.measures.CoreMetrics.NEW_MINOR_VIOLATIONS`, `org.sonar.api.measures.CoreMetrics.NEW_INFO_VIOLATIONS`, `org.sonar.api.measures.CoreMetrics.CODE_SMELLS`, `org.sonar.api.measures.CoreMetrics.NEW_CODE_SMELLS`, `org.sonar.api.measures.CoreMetrics.BUGS`, `org.sonar.api.measures.CoreMetrics.NEW_BUGS`, `org.sonar.api.measures.CoreMetrics.VULNERABILITIES`, `org.sonar.api.measures.CoreMetrics.NEW_VULNERABILITIES`.
* Deprecate `org.sonar.api.server.rule.internal.ImpactMapper.convertToDeprecatedSeverity`. Use `org.sonar.api.server.rule.internal.ImpactMapper.convertToRuleSeverity` instead.
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
2 changes: 1 addition & 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 Expand Up @@ -109,6 +108,7 @@ publishing {
}

test {
dependsOn ':plugin-api:shadowJar'
// Enabling the JUnit Platform (see https://github.com/junit-team/junit5-samples/tree/master/junit5-migration-gradle)
useJUnitPlatform()
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
/**
* @see org.sonar.api.server.rule.RulesDefinition.NewRule#setType(RuleType)
* @since 5.5
* @deprecated since 10.1.
steve-marion-sonarsource marked this conversation as resolved.
Show resolved Hide resolved
*/
public class RuleTagsToTypeConverter {

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
Loading