Skip to content

Commit c7de0d7

Browse files
committed
Migrate to jakarta namespace
1 parent 5317093 commit c7de0d7

File tree

8 files changed

+71
-49
lines changed

8 files changed

+71
-49
lines changed

.github/workflows/maven.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ jobs:
2525

2626
steps:
2727
- uses: actions/checkout@v2
28-
- name: Set up JDK 1.8
29-
uses: actions/setup-java@v1
30-
with:
31-
java-version: 1.8
32-
- name: Build with Maven
33-
env:
34-
HTTPCLIENT_VERSION: ${{ matrix.HTTPCLIENT_VERSION }}
35-
HTTPCLIENT_TEST_VERSION: ${{ matrix.HTTPCLIENT_TEST_VERSION }}
36-
JDOC: ${{ matrix.JDOC }}
37-
run: mvn -B -Dhttpclient.version=$HTTPCLIENT_VERSION -Dhttpclient.test.version=$HTTPCLIENT_TEST_VERSION verify $JDOC
3828
- name: Set up JDK 11
3929
uses: actions/setup-java@v1
4030
with:

pom.xml

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>org.mitre.dsmiley.httpproxy</groupId>
55
<artifactId>smiley-http-proxy-servlet</artifactId>
6-
<version>1.13-SNAPSHOT</version>
6+
<version>2.0-SNAPSHOT</version>
77
<packaging>jar</packaging>
88

99
<name>Smiley's HTTP Proxy Servlet</name>
@@ -54,11 +54,10 @@
5454

5555
<dependencies>
5656

57-
<!-- Probably works with 3.0 as well -->
5857
<dependency>
59-
<groupId>javax.servlet</groupId>
60-
<artifactId>javax.servlet-api</artifactId>
61-
<version>3.1.0</version>
58+
<groupId>jakarta.servlet</groupId>
59+
<artifactId>jakarta.servlet-api</artifactId>
60+
<version>5.0.0</version>
6261
<scope>provided</scope>
6362
</dependency>
6463

@@ -84,9 +83,9 @@
8483
</dependency>
8584

8685
<dependency>
87-
<groupId>httpunit</groupId>
86+
<groupId>com.github.hazendaz.httpunit</groupId>
8887
<artifactId>httpunit</artifactId>
89-
<version>1.7</version>
88+
<version>2.0.0</version>
9089
<scope>test</scope>
9190
</dependency>
9291

@@ -106,7 +105,7 @@
106105
<dependency>
107106
<groupId>org.eclipse.jetty</groupId>
108107
<artifactId>jetty-servlet</artifactId>
109-
<version>9.4.30.v20200611</version>
108+
<version>11.0.13</version>
110109
<scope>test</scope>
111110
</dependency>
112111
</dependencies>
@@ -147,8 +146,8 @@
147146
org.apache.http.util; version="0",
148147
org.apache.http.client.utils;version="0",
149148
org.apache.http.client.methods;version="0",
150-
javax.servlet;version="0",
151-
javax.servlet.http;version="0",
149+
jakarta.servlet;version="0",
150+
jakarta.servlet.http;version="0",
152151
javax.net.ssl;version="0", org.apache.http.client.config;version="0"</Import-Package>
153152
</manifestEntries>
154153
</archive>
@@ -191,6 +190,41 @@
191190
<version>3.9.1</version>
192191
</plugin>
193192

193+
<plugin>
194+
<groupId>org.apache.maven.plugins</groupId>
195+
<artifactId>maven-shade-plugin</artifactId>
196+
<version>3.2.2</version>
197+
<executions>
198+
<execution>
199+
<id>javax</id>
200+
<phase>package</phase>
201+
<goals>
202+
<goal>shade</goal>
203+
</goals>
204+
<configuration>
205+
<shadedClassifierName>javax</shadedClassifierName>
206+
<shadedArtifactAttached>true</shadedArtifactAttached>
207+
<createDependencyReducedPom>false</createDependencyReducedPom>
208+
<artifactSet>
209+
<includes>
210+
<include>${project.groupId}:${project.artifactId}</include>
211+
</includes>
212+
</artifactSet>
213+
<relocations>
214+
<relocation>
215+
<pattern>jakarta.servlet</pattern>
216+
<shadedPattern>javax.servlet</shadedPattern>
217+
</relocation>
218+
<relocation>
219+
<pattern>jakarta.annotation</pattern>
220+
<shadedPattern>javax.annotation</shadedPattern>
221+
</relocation>
222+
</relocations>
223+
</configuration>
224+
</execution>
225+
</executions>
226+
</plugin>
227+
194228
</plugins>
195229
</build>
196230

src/main/java/org/mitre/dsmiley/httpproxy/ProxyServlet.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
import org.apache.http.message.HeaderGroup;
3838
import org.apache.http.util.EntityUtils;
3939

40-
import javax.servlet.ServletException;
41-
import javax.servlet.http.Cookie;
42-
import javax.servlet.http.HttpServlet;
43-
import javax.servlet.http.HttpServletRequest;
44-
import javax.servlet.http.HttpServletResponse;
40+
import jakarta.servlet.ServletException;
41+
import jakarta.servlet.http.Cookie;
42+
import jakarta.servlet.http.HttpServlet;
43+
import jakarta.servlet.http.HttpServletRequest;
44+
import jakarta.servlet.http.HttpServletResponse;
4545
import java.io.Closeable;
4646
import java.io.IOException;
4747
import java.io.InputStream;
@@ -272,7 +272,7 @@ protected void initTarget() throws ServletException {
272272
}
273273

274274
/**
275-
* Called from {@link #init(javax.servlet.ServletConfig)}.
275+
* Called from {@link #init(jakarta.servlet.ServletConfig)}.
276276
* HttpClient offers many opportunities for customization.
277277
* In any case, it should be thread-safe.
278278
*/
@@ -374,11 +374,8 @@ protected void service(HttpServletRequest servletRequest, HttpServletResponse se
374374

375375
// Process the response:
376376

377-
// Pass the response code. This method with the "reason phrase" is deprecated but it's the
378-
// only way to pass the reason along too.
379377
int statusCode = proxyResponse.getStatusLine().getStatusCode();
380-
//noinspection deprecation
381-
servletResponse.setStatus(statusCode, proxyResponse.getStatusLine().getReasonPhrase());
378+
servletResponse.setStatus(statusCode);
382379

383380
// Copying response headers to make sure SESSIONID or other Cookie which comes from the remote
384381
// server will be saved in client when the proxied url was redirected to another one.
@@ -751,7 +748,7 @@ protected String rewriteQueryStringFromRequest(HttpServletRequest servletRequest
751748
}
752749

753750
/**
754-
* Allow overrides of {@link javax.servlet.http.HttpServletRequest#getPathInfo()}.
751+
* Allow overrides of {@link jakarta.servlet.http.HttpServletRequest#getPathInfo()}.
755752
* Useful when url-pattern of servlet-mapping (web.xml) requires manipulation.
756753
*/
757754
protected String rewritePathInfoFromRequest(HttpServletRequest servletRequest) {

src/main/java/org/mitre/dsmiley/httpproxy/URITemplateProxyServlet.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import org.apache.http.client.utils.URIUtils;
2121
import org.apache.http.client.utils.URLEncodedUtils;
2222

23-
import javax.servlet.ServletException;
24-
import javax.servlet.http.HttpServletRequest;
25-
import javax.servlet.http.HttpServletResponse;
23+
import jakarta.servlet.ServletException;
24+
import jakarta.servlet.http.HttpServletRequest;
25+
import jakarta.servlet.http.HttpServletResponse;
2626
import java.io.IOException;
2727
import java.net.URI;
2828
import java.net.URISyntaxException;

src/test/java/org/mitre/dsmiley/httpproxy/AcceptEncodingTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515
*/
1616
package org.mitre.dsmiley.httpproxy;
1717

18+
import static org.junit.Assert.assertEquals;
19+
20+
import jakarta.servlet.ServletException;
21+
import jakarta.servlet.http.HttpServlet;
22+
import jakarta.servlet.http.HttpServletRequest;
23+
import jakarta.servlet.http.HttpServletResponse;
1824
import java.io.IOException;
1925
import java.io.InputStream;
2026
import java.nio.charset.StandardCharsets;
2127
import java.util.Arrays;
2228
import java.util.HashSet;
23-
import javax.servlet.ServletException;
24-
import javax.servlet.http.HttpServlet;
25-
import javax.servlet.http.HttpServletRequest;
26-
import javax.servlet.http.HttpServletResponse;
2729
import org.apache.http.client.methods.CloseableHttpResponse;
2830
import org.apache.http.client.methods.HttpGet;
2931
import org.apache.http.impl.client.CloseableHttpClient;
@@ -34,7 +36,6 @@
3436
import org.eclipse.jetty.servlet.ServletHandler;
3537
import org.eclipse.jetty.servlet.ServletHolder;
3638
import org.junit.After;
37-
import static org.junit.Assert.assertEquals;
3839
import org.junit.Before;
3940
import org.junit.Test;
4041

src/test/java/org/mitre/dsmiley/httpproxy/ChunkedTransferTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
import java.util.List;
2424
import java.util.concurrent.CountDownLatch;
2525
import java.util.concurrent.TimeUnit;
26-
import javax.servlet.ServletException;
27-
import javax.servlet.http.HttpServlet;
28-
import javax.servlet.http.HttpServletRequest;
29-
import javax.servlet.http.HttpServletResponse;
26+
import jakarta.servlet.ServletException;
27+
import jakarta.servlet.http.HttpServlet;
28+
import jakarta.servlet.http.HttpServletRequest;
29+
import jakarta.servlet.http.HttpServletResponse;
3030
import org.apache.http.MalformedChunkCodingException;
3131
import org.apache.http.client.methods.CloseableHttpResponse;
3232
import org.apache.http.client.methods.HttpGet;

src/test/java/org/mitre/dsmiley/httpproxy/ModifyHeadersProxyServletTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import org.apache.http.protocol.HttpContext;
2626
import org.junit.Test;
2727

28-
import javax.servlet.http.HttpServletRequest;
29-
import javax.servlet.http.HttpServletResponse;
28+
import jakarta.servlet.http.HttpServletRequest;
29+
import jakarta.servlet.http.HttpServletResponse;
3030
import java.io.IOException;
3131

3232
import static org.junit.Assert.assertEquals;

src/test/java/org/mitre/dsmiley/httpproxy/ParallelConnectionsTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
import java.util.concurrent.Executors;
3232
import java.util.concurrent.Future;
3333
import java.util.concurrent.TimeUnit;
34-
import javax.servlet.ServletException;
35-
import javax.servlet.http.HttpServlet;
36-
import javax.servlet.http.HttpServletRequest;
37-
import javax.servlet.http.HttpServletResponse;
34+
import jakarta.servlet.ServletException;
35+
import jakarta.servlet.http.HttpServlet;
36+
import jakarta.servlet.http.HttpServletRequest;
37+
import jakarta.servlet.http.HttpServletResponse;
3838

3939
import org.eclipse.jetty.server.Server;
4040
import org.eclipse.jetty.server.ServerConnector;

0 commit comments

Comments
 (0)