Skip to content

Commit 532ab02

Browse files
ahornaceVladimir Kotal
authored andcommitted
Update Servlet API to 3.1 (#2131)
1 parent 64006f5 commit 532ab02

File tree

8 files changed

+277
-33
lines changed

8 files changed

+277
-33
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Official page of the project is on:
3131
## 2. Requirements
3232
* Latest Java (at least 1.8)
3333
<http://www.oracle.com/technetwork/java/>
34-
* A servlet container like Tomcat (8.x or later) supporting Servlet 2.5 and JSP 2.1
34+
* A servlet container like Tomcat (8.x or later) supporting Servlet 3.1 and JSP 2.1
3535
<http://tomcat.apache.org/>
3636
* Exuberant Ctags or Universal Ctags
3737
<http://ctags.sourceforge.net/>

opengrok-indexer/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
515515
</dependency>
516516
<dependency>
517517
<groupId>javax.servlet</groupId>
518-
<artifactId>servlet-api</artifactId>
518+
<artifactId>javax.servlet-api</artifactId>
519519
</dependency>
520520
<dependency>
521521
<groupId>com.googlecode.json-simple</groupId>

plugins/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
7272
</dependency>
7373
<dependency>
7474
<groupId>javax.servlet</groupId>
75-
<artifactId>servlet-api</artifactId>
75+
<artifactId>javax.servlet-api</artifactId>
7676
</dependency>
7777
<dependency>
7878
<groupId>junit</groupId>

plugins/test/opengrok/auth/plugin/util/DummyHttpServletRequestLdap.java

Lines changed: 89 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,44 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package opengrok.auth.plugin.util;
2424

2525
import java.io.BufferedReader;
2626
import java.io.IOException;
27-
import java.io.UnsupportedEncodingException;
2827
import java.security.Principal;
28+
import java.util.Collection;
2929
import java.util.Collections;
3030
import java.util.Enumeration;
3131
import java.util.HashMap;
3232
import java.util.Locale;
3333
import java.util.Map;
34+
import javax.servlet.AsyncContext;
35+
import javax.servlet.DispatcherType;
3436
import javax.servlet.RequestDispatcher;
3537
import javax.servlet.ServletContext;
3638
import javax.servlet.ServletInputStream;
39+
import javax.servlet.ServletRequest;
40+
import javax.servlet.ServletResponse;
3741
import javax.servlet.http.Cookie;
3842
import javax.servlet.http.HttpServletRequest;
43+
import javax.servlet.http.HttpServletResponse;
3944
import javax.servlet.http.HttpSession;
40-
import javax.servlet.http.HttpSessionContext;
45+
import javax.servlet.http.HttpUpgradeHandler;
46+
import javax.servlet.http.Part;
47+
4148
import opengrok.auth.plugin.UserPlugin;
4249
import opengrok.auth.plugin.entity.User;
4350
import org.opensolaris.opengrok.util.RandomString;
4451

4552
public class DummyHttpServletRequestLdap implements HttpServletRequest {
4653

47-
private final Map<String, String> headers = new HashMap<String, String>();
48-
private final Map<String, Object> attrs = new HashMap<String, Object>();
54+
private final Map<String, String> headers = new HashMap<>();
55+
private final Map<String, Object> attrs = new HashMap<>();
4956
private HttpSession sessions = new HttpSession() {
5057

51-
private final Map<String, Object> attrs = new HashMap<String, Object>();
58+
private final Map<String, Object> attrs = new HashMap<>();
5259

5360
@Override
5461
public long getCreationTime() {
@@ -83,8 +90,9 @@ public int getMaxInactiveInterval() {
8390
return 3600;
8491
}
8592

93+
@Override
8694
@SuppressWarnings("deprecation")
87-
public HttpSessionContext getSessionContext() {
95+
public javax.servlet.http.HttpSessionContext getSessionContext() {
8896
throw new UnsupportedOperationException("Not supported yet.");
8997
}
9098

@@ -155,10 +163,6 @@ public long getDateHeader(String string) {
155163
throw new UnsupportedOperationException("Not supported yet.");
156164
}
157165

158-
public void setHeader(String string, String value) {
159-
headers.put(string, value);
160-
}
161-
162166
@Override
163167
public String getHeader(String string) {
164168
return headers.get(string);
@@ -249,8 +253,9 @@ public HttpSession getSession() {
249253
return sessions;
250254
}
251255

252-
public void setSession(HttpSession session) {
253-
this.sessions = session;
256+
@Override
257+
public String changeSessionId() {
258+
return null;
254259
}
255260

256261
@Override
@@ -274,6 +279,36 @@ public boolean isRequestedSessionIdFromUrl() {
274279
throw new UnsupportedOperationException("Not supported yet.");
275280
}
276281

282+
@Override
283+
public boolean authenticate(HttpServletResponse httpServletResponse) {
284+
return false;
285+
}
286+
287+
@Override
288+
public void login(String s, String s1) {
289+
290+
}
291+
292+
@Override
293+
public void logout() {
294+
295+
}
296+
297+
@Override
298+
public Collection<Part> getParts() {
299+
return null;
300+
}
301+
302+
@Override
303+
public Part getPart(String s) {
304+
return null;
305+
}
306+
307+
@Override
308+
public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass) {
309+
return null;
310+
}
311+
277312
@Override
278313
public Object getAttribute(String string) {
279314
return attrs.get(string);
@@ -290,7 +325,7 @@ public String getCharacterEncoding() {
290325
}
291326

292327
@Override
293-
public void setCharacterEncoding(String string) throws UnsupportedEncodingException {
328+
public void setCharacterEncoding(String string) {
294329
throw new UnsupportedOperationException("Not supported yet.");
295330
}
296331

@@ -299,6 +334,11 @@ public int getContentLength() {
299334
throw new UnsupportedOperationException("Not supported yet.");
300335
}
301336

337+
@Override
338+
public long getContentLengthLong() {
339+
return 0;
340+
}
341+
302342
@Override
303343
public String getContentType() {
304344
throw new UnsupportedOperationException("Not supported yet.");
@@ -419,4 +459,39 @@ public String getLocalAddr() {
419459
public int getLocalPort() {
420460
throw new UnsupportedOperationException("Not supported yet.");
421461
}
462+
463+
@Override
464+
public ServletContext getServletContext() {
465+
return null;
466+
}
467+
468+
@Override
469+
public AsyncContext startAsync() throws IllegalStateException {
470+
return null;
471+
}
472+
473+
@Override
474+
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
475+
return null;
476+
}
477+
478+
@Override
479+
public boolean isAsyncStarted() {
480+
return false;
481+
}
482+
483+
@Override
484+
public boolean isAsyncSupported() {
485+
return false;
486+
}
487+
488+
@Override
489+
public AsyncContext getAsyncContext() {
490+
return null;
491+
}
492+
493+
@Override
494+
public DispatcherType getDispatcherType() {
495+
return null;
496+
}
422497
}

plugins/test/opengrok/auth/plugin/util/DummyHttpServletRequestUser.java

Lines changed: 87 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,38 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package opengrok.auth.plugin.util;
2424

2525
import java.io.BufferedReader;
2626
import java.io.IOException;
2727
import java.io.UnsupportedEncodingException;
2828
import java.security.Principal;
29+
import java.util.Collection;
2930
import java.util.Collections;
3031
import java.util.Enumeration;
3132
import java.util.HashMap;
3233
import java.util.Locale;
3334
import java.util.Map;
35+
import javax.servlet.AsyncContext;
36+
import javax.servlet.DispatcherType;
3437
import javax.servlet.RequestDispatcher;
3538
import javax.servlet.ServletContext;
3639
import javax.servlet.ServletInputStream;
40+
import javax.servlet.ServletRequest;
41+
import javax.servlet.ServletResponse;
3742
import javax.servlet.http.Cookie;
3843
import javax.servlet.http.HttpServletRequest;
44+
import javax.servlet.http.HttpServletResponse;
3945
import javax.servlet.http.HttpSession;
40-
import javax.servlet.http.HttpSessionContext;
46+
import javax.servlet.http.HttpUpgradeHandler;
47+
import javax.servlet.http.Part;
4148

4249
public class DummyHttpServletRequestUser implements HttpServletRequest {
4350

44-
private final Map<String, String> headers = new HashMap<String, String>();
45-
private final Map<String, Object> attrs = new HashMap<String, Object>();
51+
private final Map<String, String> headers = new HashMap<>();
52+
private final Map<String, Object> attrs = new HashMap<>();
4653
private HttpSession sessions = new HttpSession() {
4754

4855
private final Map<String, Object> attrs = new HashMap<>();
@@ -76,8 +83,9 @@ public int getMaxInactiveInterval() {
7683
return 3600;
7784
}
7885

86+
@Override
7987
@SuppressWarnings("deprecation")
80-
public HttpSessionContext getSessionContext() {
88+
public javax.servlet.http.HttpSessionContext getSessionContext() {
8189
throw new UnsupportedOperationException("Not supported yet.");
8290
}
8391

@@ -241,9 +249,10 @@ public HttpSession getSession(boolean bln) {
241249
public HttpSession getSession() {
242250
return sessions;
243251
}
244-
245-
public void setSession(HttpSession session) {
246-
this.sessions = session;
252+
253+
@Override
254+
public String changeSessionId() {
255+
return null;
247256
}
248257

249258
@Override
@@ -267,6 +276,36 @@ public boolean isRequestedSessionIdFromUrl() {
267276
throw new UnsupportedOperationException("Not supported yet.");
268277
}
269278

279+
@Override
280+
public boolean authenticate(HttpServletResponse httpServletResponse) {
281+
return false;
282+
}
283+
284+
@Override
285+
public void login(String s, String s1) {
286+
287+
}
288+
289+
@Override
290+
public void logout() {
291+
292+
}
293+
294+
@Override
295+
public Collection<Part> getParts() {
296+
return null;
297+
}
298+
299+
@Override
300+
public Part getPart(String s) {
301+
return null;
302+
}
303+
304+
@Override
305+
public <T extends HttpUpgradeHandler> T upgrade(Class<T> aClass) {
306+
return null;
307+
}
308+
270309
@Override
271310
public Object getAttribute(String string) {
272311
return attrs.get(string);
@@ -292,6 +331,11 @@ public int getContentLength() {
292331
throw new UnsupportedOperationException("Not supported yet.");
293332
}
294333

334+
@Override
335+
public long getContentLengthLong() {
336+
return 0;
337+
}
338+
295339
@Override
296340
public String getContentType() {
297341
throw new UnsupportedOperationException("Not supported yet.");
@@ -412,4 +456,39 @@ public String getLocalAddr() {
412456
public int getLocalPort() {
413457
throw new UnsupportedOperationException("Not supported yet.");
414458
}
459+
460+
@Override
461+
public ServletContext getServletContext() {
462+
return null;
463+
}
464+
465+
@Override
466+
public AsyncContext startAsync() throws IllegalStateException {
467+
return null;
468+
}
469+
470+
@Override
471+
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
472+
return null;
473+
}
474+
475+
@Override
476+
public boolean isAsyncStarted() {
477+
return false;
478+
}
479+
480+
@Override
481+
public boolean isAsyncSupported() {
482+
return false;
483+
}
484+
485+
@Override
486+
public AsyncContext getAsyncContext() {
487+
return null;
488+
}
489+
490+
@Override
491+
public DispatcherType getDispatcherType() {
492+
return null;
493+
}
415494
}

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ Portions Copyright (c) 2018, Chris Fraire <[email protected]>.
121121
</dependency>
122122
<dependency>
123123
<groupId>javax.servlet</groupId>
124-
<artifactId>servlet-api</artifactId>
125-
<version>2.5</version>
124+
<artifactId>javax.servlet-api</artifactId>
125+
<version>3.1.0</version>
126+
<scope>provided</scope>
126127
</dependency>
127128
<dependency>
128129
<groupId>com.googlecode.json-simple</groupId>

0 commit comments

Comments
 (0)