|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2022 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -248,30 +248,31 @@ private void limitExceeded(String reason) {
|
248 | 248 |
|
249 | 249 | @Override
|
250 | 250 | public void close(CloseStatus status) throws IOException {
|
251 |
| - this.closeLock.lock(); |
252 |
| - try { |
253 |
| - if (this.closeInProgress) { |
254 |
| - return; |
255 |
| - } |
256 |
| - if (!CloseStatus.SESSION_NOT_RELIABLE.equals(status)) { |
257 |
| - try { |
258 |
| - checkSessionLimits(); |
259 |
| - } |
260 |
| - catch (SessionLimitExceededException ex) { |
261 |
| - // Ignore |
| 251 | + if (this.closeLock.tryLock()) { |
| 252 | + try { |
| 253 | + if (this.closeInProgress) { |
| 254 | + return; |
262 | 255 | }
|
263 |
| - if (this.limitExceeded) { |
264 |
| - if (logger.isDebugEnabled()) { |
265 |
| - logger.debug("Changing close status " + status + " to SESSION_NOT_RELIABLE."); |
| 256 | + if (!CloseStatus.SESSION_NOT_RELIABLE.equals(status)) { |
| 257 | + try { |
| 258 | + checkSessionLimits(); |
| 259 | + } |
| 260 | + catch (SessionLimitExceededException ex) { |
| 261 | + // Ignore |
| 262 | + } |
| 263 | + if (this.limitExceeded) { |
| 264 | + if (logger.isDebugEnabled()) { |
| 265 | + logger.debug("Changing close status " + status + " to SESSION_NOT_RELIABLE."); |
| 266 | + } |
| 267 | + status = CloseStatus.SESSION_NOT_RELIABLE; |
266 | 268 | }
|
267 |
| - status = CloseStatus.SESSION_NOT_RELIABLE; |
268 | 269 | }
|
| 270 | + this.closeInProgress = true; |
| 271 | + super.close(status); |
| 272 | + } |
| 273 | + finally { |
| 274 | + this.closeLock.unlock(); |
269 | 275 | }
|
270 |
| - this.closeInProgress = true; |
271 |
| - super.close(status); |
272 |
| - } |
273 |
| - finally { |
274 |
| - this.closeLock.unlock(); |
275 | 276 | }
|
276 | 277 | }
|
277 | 278 |
|
|
0 commit comments