ResponseBodyEmitter.java (spring-framework-5.3.23) | : | ResponseBodyEmitter.java (spring-framework-5.3.24) | ||
---|---|---|---|---|
/* | /* | |||
* Copyright 2002-2020 the original author or authors. | * Copyright 2002-2022 the original author or authors. | |||
* | * | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | * You may obtain a copy of the License at | |||
* | * | |||
* https://www.apache.org/licenses/LICENSE-2.0 | * https://www.apache.org/licenses/LICENSE-2.0 | |||
* | * | |||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
skipping to change at line 193 | skipping to change at line 193 | |||
/** | /** | |||
* Overloaded variant of {@link #send(Object)} that also accepts a MediaT ype | * Overloaded variant of {@link #send(Object)} that also accepts a MediaT ype | |||
* hint for how to serialize the given Object. | * hint for how to serialize the given Object. | |||
* @param object the object to write | * @param object the object to write | |||
* @param mediaType a MediaType hint for selecting an HttpMessageConverte r | * @param mediaType a MediaType hint for selecting an HttpMessageConverte r | |||
* @throws IOException raised when an I/O error occurs | * @throws IOException raised when an I/O error occurs | |||
* @throws java.lang.IllegalStateException wraps any other errors | * @throws java.lang.IllegalStateException wraps any other errors | |||
*/ | */ | |||
public synchronized void send(Object object, @Nullable MediaType mediaTyp e) throws IOException { | public synchronized void send(Object object, @Nullable MediaType mediaTyp e) throws IOException { | |||
Assert.state(!this.complete, | Assert.state(!this.complete, () -> "ResponseBodyEmitter has alrea | |||
"ResponseBodyEmitter has already completed" + | dy completed" + | |||
(this.failure != null ? " with er ror: " + this.failure : "")); | (this.failure != null ? " with er ror: " + this.failure : "")); | |||
sendInternal(object, mediaType); | sendInternal(object, mediaType); | |||
} | } | |||
private void sendInternal(Object object, @Nullable MediaType mediaType) t hrows IOException { | private void sendInternal(Object object, @Nullable MediaType mediaType) t hrows IOException { | |||
if (this.handler != null) { | if (this.handler != null) { | |||
try { | try { | |||
this.handler.send(object, mediaType); | this.handler.send(object, mediaType); | |||
} | } | |||
catch (IOException ex) { | catch (IOException ex) { | |||
End of changes. 2 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |