|
|
@ -24,6 +24,7 @@ import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import org.reactivestreams.Publisher;
|
|
|
|
import org.reactivestreams.Publisher;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
|
|
import reactor.core.publisher.MonoSink;
|
|
|
|
import reactor.core.scheduler.Schedulers;
|
|
|
|
import reactor.core.scheduler.Schedulers;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
@ -212,9 +213,8 @@ public class WebEndpointReactiveHandlerMapping extends RequestMappingInfoHandler
|
|
|
|
return Mono.from(result).map(this::toResponseEntity)
|
|
|
|
return Mono.from(result).map(this::toResponseEntity)
|
|
|
|
.onErrorReturn(ParameterMappingException.class,
|
|
|
|
.onErrorReturn(ParameterMappingException.class,
|
|
|
|
new ResponseEntity<>(HttpStatus.BAD_REQUEST))
|
|
|
|
new ResponseEntity<>(HttpStatus.BAD_REQUEST))
|
|
|
|
.defaultIfEmpty(
|
|
|
|
.defaultIfEmpty(new ResponseEntity<>(httpMethod == HttpMethod.GET
|
|
|
|
new ResponseEntity<>(httpMethod == HttpMethod.GET
|
|
|
|
? HttpStatus.NOT_FOUND : HttpStatus.NO_CONTENT));
|
|
|
|
? HttpStatus.NOT_FOUND : HttpStatus.NO_CONTENT));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ResponseEntity<Object> toResponseEntity(Object response) {
|
|
|
|
private ResponseEntity<Object> toResponseEntity(Object response) {
|
|
|
@ -277,18 +277,20 @@ public class WebEndpointReactiveHandlerMapping extends RequestMappingInfoHandler
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Object invoke(Map<String, Object> arguments) {
|
|
|
|
public Object invoke(Map<String, Object> arguments) {
|
|
|
|
return Mono.create((sink) -> {
|
|
|
|
return Mono.create((sink) -> {
|
|
|
|
Schedulers.elastic().schedule(() -> {
|
|
|
|
Schedulers.elastic().schedule(() -> invoke(arguments, sink));
|
|
|
|
try {
|
|
|
|
|
|
|
|
Object result = this.delegate.invoke(arguments);
|
|
|
|
|
|
|
|
sink.success(result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
|
|
|
sink.error(ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void invoke(Map<String, Object> arguments, MonoSink<Object> sink) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Object result = this.delegate.invoke(arguments);
|
|
|
|
|
|
|
|
sink.success(result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
|
|
|
sink.error(ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|