|
1 | 1 | /* |
2 | | - * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2010, 2025 Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials are made available under the |
5 | 5 | * terms of the Eclipse Public License v. 2.0, which is available at |
@@ -231,25 +231,29 @@ public void setSuspendTimeout(final long timeOut, final TimeUnit timeUnit) throw |
231 | 231 | public OutputStream writeResponseStatusAndHeaders(final long contentLength, |
232 | 232 | final ContainerResponse context) |
233 | 233 | throws ContainerException { |
234 | | - try { |
235 | | - final javax.ws.rs.core.Response.StatusType statusInfo = context.getStatusInfo(); |
236 | | - if (statusInfo.getReasonPhrase() == null) { |
237 | | - grizzlyResponse.setStatus(statusInfo.getStatusCode()); |
238 | | - } else { |
239 | | - grizzlyResponse.setStatus(statusInfo.getStatusCode(), statusInfo.getReasonPhrase()); |
240 | | - } |
| 234 | + if (!grizzlyResponse.isCommitted()) { |
| 235 | + try { |
| 236 | + final javax.ws.rs.core.Response.StatusType statusInfo = context.getStatusInfo(); |
| 237 | + if (statusInfo.getReasonPhrase() == null) { |
| 238 | + grizzlyResponse.setStatus(statusInfo.getStatusCode()); |
| 239 | + } else { |
| 240 | + grizzlyResponse.setStatus(statusInfo.getStatusCode(), statusInfo.getReasonPhrase()); |
| 241 | + } |
241 | 242 |
|
242 | | - grizzlyResponse.setContentLengthLong(contentLength); |
| 243 | + grizzlyResponse.setContentLengthLong(contentLength); |
243 | 244 |
|
244 | | - for (final Map.Entry<String, List<String>> e : context.getStringHeaders().entrySet()) { |
245 | | - for (final String value : e.getValue()) { |
246 | | - grizzlyResponse.addHeader(e.getKey(), value); |
| 245 | + for (final Map.Entry<String, List<String>> e : context.getStringHeaders().entrySet()) { |
| 246 | + for (final String value : e.getValue()) { |
| 247 | + grizzlyResponse.addHeader(e.getKey(), value); |
| 248 | + } |
247 | 249 | } |
248 | | - } |
249 | 250 |
|
250 | | - return grizzlyResponse.getOutputStream(); |
251 | | - } finally { |
252 | | - logger.debugLog("{0} - writeResponseStatusAndHeaders() called", name); |
| 251 | + return grizzlyResponse.getOutputStream(); |
| 252 | + } finally { |
| 253 | + logger.debugLog("{0} - writeResponseStatusAndHeaders() called", name); |
| 254 | + } |
| 255 | + } else { |
| 256 | + return null; |
253 | 257 | } |
254 | 258 | } |
255 | 259 |
|
|
0 commit comments