Polishing
This commit is contained in:
@@ -58,9 +58,7 @@ public class ReactorServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
private static URI initUri(HttpServerRequest request) throws URISyntaxException {
|
||||
Assert.notNull(request, "'request' must not be null");
|
||||
URI baseUri = resolveBaseUrl(request);
|
||||
String requestUri = request.uri();
|
||||
return (baseUri != null ? new URI(baseUri.toString() + requestUri) : new URI(requestUri));
|
||||
return new URI(resolveBaseUrl(request).toString() + request.uri());
|
||||
}
|
||||
|
||||
private static URI resolveBaseUrl(HttpServerRequest request) throws URISyntaxException {
|
||||
@@ -69,14 +67,16 @@ public class ReactorServerHttpRequest extends AbstractServerHttpRequest {
|
||||
final int portIndex;
|
||||
if (header.startsWith("[")) {
|
||||
portIndex = header.indexOf(':', header.indexOf(']'));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
portIndex = header.indexOf(':');
|
||||
}
|
||||
if (portIndex != -1) {
|
||||
try {
|
||||
return new URI(null, null, header.substring(0, portIndex),
|
||||
Integer.parseInt(header.substring(portIndex + 1)), null, null, null);
|
||||
} catch (NumberFormatException ignore) {
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
throw new URISyntaxException(header, "Unable to parse port", portIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,10 +45,23 @@ import org.springframework.web.context.request.NativeWebRequest;
|
||||
*/
|
||||
public interface CallableProcessingInterceptor {
|
||||
|
||||
/**
|
||||
* Constant indicating that no result has been determined by this
|
||||
* interceptor, giving subsequent interceptors a chance.
|
||||
* @see #handleTimeout
|
||||
* @see #handleError
|
||||
*/
|
||||
Object RESULT_NONE = new Object();
|
||||
|
||||
/**
|
||||
* Constant indicating that the response has been handled by this interceptor
|
||||
* without a result and that no further interceptors are to be invoked.
|
||||
* @see #handleTimeout
|
||||
* @see #handleError
|
||||
*/
|
||||
Object RESPONSE_HANDLED = new Object();
|
||||
|
||||
|
||||
/**
|
||||
* Invoked <em>before</em> the start of concurrent handling in the original
|
||||
* thread in which the {@code Callable} is submitted for concurrent handling.
|
||||
@@ -58,6 +71,7 @@ public interface CallableProcessingInterceptor {
|
||||
* {@link #preProcess(NativeWebRequest, Callable)}. Capturing the state of
|
||||
* Spring Security's SecurityContextHolder and migrating it to the new Thread
|
||||
* is a concrete example of where this is useful.
|
||||
* <p>The default implementation is empty.
|
||||
* @param request the current request
|
||||
* @param task the task for the current async request
|
||||
* @throws Exception in case of errors
|
||||
@@ -69,6 +83,7 @@ public interface CallableProcessingInterceptor {
|
||||
* Invoked <em>after</em> the start of concurrent handling in the async
|
||||
* thread in which the {@code Callable} is executed and <em>before</em> the
|
||||
* actual invocation of the {@code Callable}.
|
||||
* <p>The default implementation is empty.
|
||||
* @param request the current request
|
||||
* @param task the task for the current async request
|
||||
* @throws Exception in case of errors
|
||||
@@ -81,6 +96,7 @@ public interface CallableProcessingInterceptor {
|
||||
* async thread in which the {@code Callable} is executed. This method may
|
||||
* be invoked later than {@code afterTimeout} or {@code afterCompletion}
|
||||
* depending on when the {@code Callable} finishes processing.
|
||||
* <p>The default implementation is empty.
|
||||
* @param request the current request
|
||||
* @param task the task for the current async request
|
||||
* @param concurrentResult the result of concurrent processing, which could
|
||||
@@ -96,6 +112,7 @@ public interface CallableProcessingInterceptor {
|
||||
* the {@code Callable} task completes. Implementations may return a value,
|
||||
* including an {@link Exception}, to use instead of the value the
|
||||
* {@link Callable} did not return in time.
|
||||
* <p>The default implementation always returns {@link #RESULT_NONE}.
|
||||
* @param request the current request
|
||||
* @param task the task for the current async request
|
||||
* @return a concurrent result value; if the value is anything other than
|
||||
@@ -112,6 +129,7 @@ public interface CallableProcessingInterceptor {
|
||||
* the async request before the {@code Callable} task completes.
|
||||
* Implementations may return a value, including an {@link Exception}, to
|
||||
* use instead of the value the {@link Callable} did not return in time.
|
||||
* <p>The default implementation always returns {@link #RESULT_NONE}.
|
||||
* @param request the current request
|
||||
* @param task the task for the current async request
|
||||
* @param t the error that occurred while request processing
|
||||
@@ -128,6 +146,7 @@ public interface CallableProcessingInterceptor {
|
||||
/**
|
||||
* Invoked from a container thread when async processing completes for any
|
||||
* reason including timeout or network error.
|
||||
* <p>The default implementation is empty.
|
||||
* @param request the current request
|
||||
* @param task the task for the current async request
|
||||
* @throws Exception in case of errors
|
||||
|
||||
@@ -32,48 +32,28 @@ import org.springframework.web.context.request.NativeWebRequest;
|
||||
@Deprecated
|
||||
public abstract class CallableProcessingInterceptorAdapter implements CallableProcessingInterceptor {
|
||||
|
||||
/**
|
||||
* This implementation is empty.
|
||||
*/
|
||||
@Override
|
||||
public <T> void beforeConcurrentHandling(NativeWebRequest request, Callable<T> task) throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation is empty.
|
||||
*/
|
||||
@Override
|
||||
public <T> void preProcess(NativeWebRequest request, Callable<T> task) throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation is empty.
|
||||
*/
|
||||
@Override
|
||||
public <T> void postProcess(NativeWebRequest request, Callable<T> task, Object concurrentResult) throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation always returns
|
||||
* {@link CallableProcessingInterceptor#RESULT_NONE RESULT_NONE}.
|
||||
*/
|
||||
@Override
|
||||
public <T> Object handleTimeout(NativeWebRequest request, Callable<T> task) throws Exception {
|
||||
return RESULT_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation always returns
|
||||
* {@link CallableProcessingInterceptor#RESULT_NONE RESULT_NONE}.
|
||||
*/
|
||||
@Override
|
||||
public <T> Object handleError(NativeWebRequest request, Callable<T> task, Throwable t) throws Exception {
|
||||
return RESULT_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation is empty.
|
||||
*/
|
||||
@Override
|
||||
public <T> void afterCompletion(NativeWebRequest request, Callable<T> task) throws Exception {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user