我正在尝试播放以下示例代码:
@GetMapping("/unsupport")
public Mono<Void> unsupport(ServerWebExchange exchange) {
return exchange.getResponse().writeWith(Mono.just(exchange.getResponse().bufferFactory().wrap("unsupport".getBytes(StandardCharsets.UTF_8))));
}
然后我在下面的堆栈中得到了UnsupportedOperationException:
,位于java.util.Collections $ UnmodifiableMap.put(未知源),位于 org.springframework.http.HttpHeaders.set(HttpHeaders.java:1451)在 org.springframework.http.HttpHeaders.setContentType(HttpHeaders.java:854) 在 org.springframework.http.codec.EncoderHttpMessageWriter.updateContentType(EncoderHttpMessageWriter.java:132) 在 org.springframework.http.codec.EncoderHttpMessageWriter.write(EncoderHttpMessageWriter.java:100) 在 org.springframework.http.codec.EncoderHttpMessageWriter.write(EncoderHttpMessageWriter.java:167) 在 org.springframework.web.reactive.result.method.annotation.AbstractMessageWriterResultHandler.writeBody(AbstractMessageWriterResultHandler.java:146) 在 org.springframework.web.reactive.result.method.annotation.ResponseEntityResultHandler.lambda $ handleResult $ 2(ResponseEntityResultHandler.java:174) 在 Reactor.core.publisher.FluxFlatMap.trySubscribeScalarMap(FluxFlatMap.java:141) 在react..core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:53) 在 Reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44) 在 Reactor.core.publisher.MonoFlatMap $ FlatMapMain.onNext(MonoFlatMap.java:150) 在 Reactor.core.publisher.Operators $ MonoSubscriber.complete(Operators.java:1080) 在 Reactor.core.publisher.MonoFlatMap $ FlatMapInner.onNext(MonoFlatMap.java:241) 在 Reactor.core.publisher.FluxOnErrorResume $ ResumeSubscriber.onNext(FluxOnErrorResume.java:73) 在 Reactor.core.publisher.Operators $ MonoSubscriber.complete(Operators.java:1080) 在 Reactor.core.publisher.MonoFlatMap $ FlatMapMain.onNext(MonoFlatMap.java:144) 在 Reactor.core.publisher.Operators $ MonoSubscriber.complete(Operators.java:1080) 在 Reactor.core.publisher.MonoZip $ ZipCoordinator.signal(MonoZip.java:241) 在react..core.publisher.MonoZip $ ZipInner.onNext(MonoZip.java:323) 在 Reactor.core.publisher.Operators $ ScalarSubscription.request(Operators.java:1637) 在 Reactor.core.publisher.MonoZip $ ZipInner.onSubscribe(MonoZip.java:312) 在react.core.publisher.MonoJust.subscribe(MonoJust.java:54)处 react..core.publisher.Mono.subscribe(Mono.java:3080)位于 react..core.publisher.MonoZip.subscribe(MonoZip.java:128)位于 react..core.publisher.MonoFlatMap.subscribe(MonoFlatMap.java:60)在 react..core.publisher.Mono.subscribe(Mono.java:3080)位于 Reactor.core.publisher.FluxOnErrorResume $ ResumeSubscriber.onError(FluxOnErrorResume.java:97) 在 Reactor.core.publisher.FluxPeekFuseable $ PeekFuseableSubscriber.onError(FluxPeekFuseable.java:222) 在 Reactor.core.publisher.FluxPeekFuseable $ PeekFuseableSubscriber.onError(FluxPeekFuseable.java:222) 在 Reactor.core.publisher.Operators $ MonoSubscriber.onError(Operators.java:1123) 在 Reactor.core.publisher.MonoIgnoreThen $ ThenAcceptInner.onError(MonoIgnoreThen.java:300) 在 Reactor.core.publisher.MonoFlatMap $ FlatMapMain.secondError(MonoFlatMap.java:185) 在 Reactor.core.publisher.MonoFlatMap $ FlatMapInner.onError(MonoFlatMap.java:251) 在 Reactor.core.publisher.MonoIgnoreThen $ ThenIgnoreMain.drain(MonoIgnoreThen.java:133) 在 Reactor.core.publisher.MonoIgnoreThen $ ThenIgnoreMain.ignoreDone(MonoIgnoreThen.java:185) 在 Reactor.core.publisher.MonoIgnoreThen $ ThenIgnoreInner.onComplete(MonoIgnoreThen.java:234) 在 org.springframework.http.server.reactive.ChannelSendOperator $ WriteCompletionBarrier.onComplete(ChannelSendOperator.java:373) 在 Reactor.core.publisher.MonoIgnoreElements $ IgnoreElementsSubscriber.onComplete(MonoIgnoreElements.java:80) 在 Reactor.core.publisher.FluxConcatIterable $ ConcatIterableSubscriber.onComplete(FluxConcatIterable.java:115) 在 Reactor.core.publisher.MonoNext $ NextSubscriber.onComplete(MonoNext.java:96) 在 org.springframework.http.server.reactive.WriteResultPublisher $ State.publishComplete(WriteResultPublisher.java:229) 在 org.springframework.http.server.reactive.WriteResultPublisher.publishComplete(WriteResultPublisher.java:69) 在 org.springframework.http.server.reactive.AbstractListenerWriteFlushProcessor $ State $ 3.writeComplete(AbstractListenerWriteFlushProcessor.java:250) 在 org.springframework.http.server.reactive.AbstractListenerWriteFlushProcessor $ State $ WriteResultSubscriber.onComplete(AbstractListenerWriteFlushProcessor.java:374) 在 org.springframework.http.server.reactive.WriteResultPublisher $ State.publishComplete(WriteResultPublisher.java:229) 在 org.springframework.http.server.reactive.WriteResultPublisher.publishComplete(WriteResultPublisher.java:69) 在 org.springframework.http.server.reactive.AbstractListenerWriteProcessor.changeStateToComplete(AbstractListenerWriteProcessor.java:209) 在 org.springframework.http.server.reactive.AbstractListenerWriteProcessor.access $ 400(AbstractListenerWriteProcessor.java:44) 在 org.springframework.http.server.reactive.AbstractListenerWriteProcessor $ State $ 3.onWritePossible(AbstractListenerWriteProcessor.java:289) 在 org.springframework.http.server.reactive.AbstractListenerWriteProcessor.onWritePossible(AbstractListenerWriteProcessor.java:103) 在 org.springframework.http.server.reactive.ServletServerHttpResponse $ ResponseBodyWriteListener.onWritePossible(ServletServerHttpResponse.java:238) 在org.apache.coyote.Response.onWritePossible(Response.java:700)在 org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:188) 在 org.apache.coyote.AbstractProcessor.dispatch(AbstractProcessor.java:232) 在 org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:49) 在 org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:790) 在 org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1468) 在 org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 在java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源) 在 org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run(未知来源)
HttpHeaders似乎是以不变的方式创建的。
我做错了还是这是一个错误?
谢谢
利昂