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

Spring Integration - Meeds-io/MIPs#57 #20

Merged
merged 2 commits into from
Jan 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se

//
HttpSession session = req.getSession(false);
if (session != null)
{
throw new ServletException("Was not expecting a session to exist");
if (session != null) {
throw new ServletException("Was not expecting a session to exist");
}

// Authenticate
Expand All @@ -77,24 +76,20 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
String id = session.getId();

//
String dispatchedId = (String)container.include(app.getServletContext(), req, resp, new RequestDispatchCallback()
{
@Override
public Object doCallback(ServletContext dispatchedCtx, HttpServletRequest dispatchedReq, HttpServletResponse dispatchedResp, Object handback) throws ServletException, IOException
{
if (dispatchedReq.getSession(false) != null)
{
throw new ServletException("Was not expecting a session to exist");
}
HttpSession dispatchedSession = dispatchedReq.getSession();
dispatchedSession.setAttribute("payload", "foo");
return dispatchedSession.getId();
}
String dispatchedId = (String)container.include(app.getServletContext(), req, resp, new RequestDispatchCallback() {
@Override
public Object doCallback(ServletContext dispatchedCtx,
HttpServletRequest dispatchedReq,
HttpServletResponse dispatchedResp,
Object handback) throws ServletException, IOException {
HttpSession dispatchedSession = dispatchedReq.getSession();
dispatchedSession.setAttribute("payload", "foo");
return dispatchedSession.getId();
}
}, null);

//
if (!id.equals(dispatchedId))
{
if (!id.equals(dispatchedId)) {
throw new ServletException("Was expecting session ids to be the same");
}

Expand Down
2 changes: 1 addition & 1 deletion test/servers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<name>GateIn - WCI test servers</name>

<modules>
<module>tomcat8</module>
<module>tomcat</module>
</modules>

<dependencies>
Expand Down
11 changes: 0 additions & 11 deletions test/servers/tomcat8/pom.xml → test/servers/tomcat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,6 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

</dependencies>

</project>
8 changes: 7 additions & 1 deletion wci/src/main/java/org/gatein/wci/command/CommandServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequestWrapper;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.MappingMatch;

/**
* This servlet is used to execute command coming from another context through a dispatching request. The invocation is
Expand Down Expand Up @@ -82,7 +84,11 @@ static Object include(
{
localCmd.set(callback);
RequestDispatcher switcher = targetContext.getRequestDispatcher(servletPath);
switcher.include(request, response);
switcher.include(new HttpServletRequestWrapper(request) {
public String getContextPath() {
return targetContext.getContextPath();
}
}, response);

//
Throwable throwable = localThrowable.get();
Expand Down