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

Remove processing of older servlet versions #702

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -35,7 +35,6 @@

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
Expand Down Expand Up @@ -120,7 +119,6 @@ public abstract class AbstractHTTPDestination
protected boolean fixedParameterOrder;
protected boolean multiplexWithAddress;
protected CertConstraints certConstraints;
protected boolean isServlet3;
protected boolean decodeBasicAuthWithIso8859;
protected ContinuationProviderFactory cproviderFactory;
protected boolean enableWebSocket;
Expand All @@ -147,12 +145,6 @@ public AbstractHTTPDestination(Bus b,
this.bus = b;
this.registry = registry;
this.path = path;
try {
ServletRequest.class.getMethod("isAsyncSupported");
isServlet3 = true;
} catch (Throwable t) {
//servlet 2.5 or earlier, no async support
}
decodeBasicAuthWithIso8859 = PropertyUtils.isTrue(bus.getProperty(DECODE_BASIC_AUTH_WITH_ISO8859));

initConfig();
Expand Down Expand Up @@ -460,12 +452,6 @@ private String setEncoding(final Message inMessage,
return contentType;
}
protected Message retrieveFromContinuation(HttpServletRequest req) {
if (!isServlet3) {
if (cproviderFactory != null) {
return cproviderFactory.retrieveFromContinuation(req);
}
return null;
}
return retrieveFromServlet3Async(req);
}

Expand All @@ -482,7 +468,7 @@ protected void setupContinuation(Message inMessage,
final HttpServletRequest req,
final HttpServletResponse resp) {
try {
if (isServlet3 && req.isAsyncSupported()) {
if (req.isAsyncSupported()) {
inMessage.put(ContinuationProvider.class.getName(),
new Servlet3ContinuationProvider(req, resp, inMessage));
} else if (cproviderFactory != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.util.PropertyUtils;
import org.apache.cxf.continuations.Continuation;
import org.apache.cxf.continuations.ContinuationCallback;
Expand All @@ -41,22 +40,10 @@
*
*/
public class Servlet3ContinuationProvider implements ContinuationProvider {
static final boolean IS_31;
static {
boolean is31 = false;
try {
ClassLoaderUtils.loadClass("javax.servlet.WriteListener", HttpServletRequest.class);
is31 = true;
} catch (Throwable t) {
is31 = false;
}
IS_31 = is31;
}

HttpServletRequest req;
HttpServletResponse resp;
Message inMessage;
Servlet3Continuation continuation;
Servlet31Continuation continuation;

public Servlet3ContinuationProvider(HttpServletRequest req,
HttpServletResponse resp,
Expand All @@ -73,22 +60,21 @@ public void complete() {
}
}


/** {@inheritDoc}*/
public Continuation getContinuation() {
if (inMessage.getExchange().isOneWay()) {
return null;
}

if (continuation == null) {
continuation = IS_31 ? new Servlet31Continuation() : new Servlet3Continuation();
continuation = new Servlet31Continuation();
} else {
continuation.startAsyncAgain();
}
return continuation;
}

public class Servlet3Continuation implements Continuation, AsyncListener {
public class Servlet31Continuation implements Continuation, AsyncListener {
private static final String BLOCK_RESTART = "org.apache.cxf.continuation.block.restart";
AsyncContext context;
volatile boolean isNew = true;
Expand All @@ -99,8 +85,8 @@ public class Servlet3Continuation implements Continuation, AsyncListener {
volatile Object obj;
private ContinuationCallback callback;
private boolean blockRestart;
public Servlet3Continuation() {

public Servlet31Continuation() {
req.setAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE,
inMessage.getExchange().getInMessage());
callback = inMessage.getExchange().get(ContinuationCallback.class);
Expand Down Expand Up @@ -139,7 +125,15 @@ public boolean suspend(long timeout) {
return true;
}
protected void updateMessageForSuspend() {
inMessage.getExchange().getInMessage().getInterceptorChain().suspend();
Message currentMessage = PhaseInterceptorChain.getCurrentMessage();
if (currentMessage.get(WriteListener.class) != null) {
// CXF Continuation WriteListener will likely need to be introduced
// for NIO supported with non-Servlet specific mechanisms
getOutputStream().setWriteListener(currentMessage.get(WriteListener.class));
currentMessage.getInterceptorChain().suspend();
} else {
inMessage.getExchange().getInMessage().getInterceptorChain().suspend();
}
}
public void redispatch() {
if (!isComplete) {
Expand Down Expand Up @@ -240,7 +234,7 @@ private boolean isClientDisconnected(Throwable ex) {

@Override
public boolean isReadyForWrite() {
return true;
return getOutputStream().isReady();
}

protected ServletOutputStream getOutputStream() {
Expand All @@ -256,26 +250,4 @@ public boolean isTimeout() {
return isTimeout;
}
}
public class Servlet31Continuation extends Servlet3Continuation {
public Servlet31Continuation() {
}

@Override
protected void updateMessageForSuspend() {
Message currentMessage = PhaseInterceptorChain.getCurrentMessage();
if (currentMessage.get(WriteListener.class) != null) {
// CXF Continuation WriteListener will likely need to be introduced
// for NIO supported with non-Servlet specific mechanisms
getOutputStream().setWriteListener(currentMessage.get(WriteListener.class));
currentMessage.getInterceptorChain().suspend();
} else {
inMessage.getExchange().getInMessage().getInterceptorChain().suspend();
}
}

@Override
public boolean isReadyForWrite() {
return getOutputStream().isReady();
}
}
}
}