15
15
*/
16
16
package com .netflix .zuul .http ;
17
17
18
+ import static org .junit .Assert .assertTrue ;
19
+ import static org .mockito .Mockito .spy ;
20
+ import static org .mockito .Mockito .times ;
21
+ import static org .mockito .Mockito .verify ;
22
+ import static org .mockito .Mockito .when ;
23
+
24
+ import java .io .IOException ;
25
+ import java .io .PrintWriter ;
26
+
27
+ import javax .servlet .ServletException ;
28
+ import javax .servlet .http .HttpServlet ;
29
+ import javax .servlet .http .HttpServletRequest ;
30
+ import javax .servlet .http .HttpServletResponse ;
18
31
19
- import com .netflix .zuul .FilterProcessor ;
20
- import com .netflix .zuul .ZuulRunner ;
21
- import com .netflix .zuul .context .RequestContext ;
22
- import com .netflix .zuul .exception .ZuulException ;
23
32
import org .junit .Before ;
24
33
import org .junit .Test ;
25
34
import org .junit .runner .RunWith ;
29
38
import org .slf4j .Logger ;
30
39
import org .slf4j .LoggerFactory ;
31
40
32
- import javax .servlet .http .HttpServlet ;
33
- import javax .servlet .http .HttpServletRequest ;
34
- import javax .servlet .http .HttpServletResponse ;
35
- import java .io .PrintWriter ;
36
-
37
- import static org .junit .Assert .assertEquals ;
38
- import static org .junit .Assert .assertTrue ;
39
- import static org .mockito .Mockito .*;
41
+ import com .netflix .zuul .FilterProcessor ;
42
+ import com .netflix .zuul .ZuulRunner ;
43
+ import com .netflix .zuul .context .RequestContext ;
44
+ import com .netflix .zuul .exception .ZuulException ;
40
45
41
46
/**
42
47
* Core Zuul servlet which intializes and orchestrates zuulFilter execution
46
51
* Time: 10:44 AM
47
52
*/
48
53
public class ZuulServlet extends HttpServlet {
54
+
55
+ private static final long serialVersionUID = -3374242278843351500L ;
49
56
private ZuulRunner zuulRunner = new ZuulRunner ();
50
57
private static Logger LOG = LoggerFactory .getLogger (ZuulServlet .class );
51
58
52
59
@ Override
53
- public void service (javax .servlet .ServletRequest servletRequest , javax .servlet .ServletResponse servletResponse ) throws javax . servlet . ServletException , java . io . IOException {
60
+ public void service (javax .servlet .ServletRequest servletRequest , javax .servlet .ServletResponse servletResponse ) throws ServletException , IOException {
54
61
try {
55
62
init ((HttpServletRequest ) servletRequest , (HttpServletResponse ) servletResponse );
56
63
57
- // marks this request as having passed through the "Zuul engine", as opposed to servlets
64
+ // Marks this request as having passed through the "Zuul engine", as opposed to servlets
58
65
// explicitly bound in web.xml, for which requests will not have the same data attached
59
- RequestContext .getCurrentContext ().setZuulEngineRan ();
66
+ RequestContext context = RequestContext .getCurrentContext ();
67
+ context .setZuulEngineRan ();
60
68
61
69
try {
62
70
preRoute ();
@@ -82,7 +90,6 @@ public void service(javax.servlet.ServletRequest servletRequest, javax.servlet.S
82
90
} catch (Throwable e ) {
83
91
error (new ZuulException (e , 500 , "UNHANDLED_EXCEPTION_" + e .getClass ().getName ()));
84
92
} finally {
85
- // RequestContext.getCurrentContext().unset();
86
93
}
87
94
}
88
95
0 commit comments