-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use static exceptions for closing websocket flushers and in ContentPr…
…oducer (#8155) * Use StaticException class in jetty-util for websocket flushers. * Use StaticException class for ContentProducer recycle and consumeAll Signed-off-by: Lachlan Roberts <[email protected]> Signed-off-by: Ludovic Orban <[email protected]> Co-authored-by: Ludovic Orban <[email protected]>
- Loading branch information
1 parent
b1c19c0
commit 0699bc5
Showing
6 changed files
with
85 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
jetty-util/src/main/java/org/eclipse/jetty/util/StaticException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.util; | ||
|
||
/** | ||
* This exception can safely be stored in a static variable as suppressed exceptions are disabled, | ||
* meaning calling {@link #addSuppressed(Throwable)} has no effect. | ||
* This prevents potential memory leaks where a statically-stored exception would accumulate | ||
* suppressed exceptions added to them. | ||
*/ | ||
public class StaticException extends Exception | ||
{ | ||
/** | ||
* Create an instance with writable stack trace and suppression disabled. | ||
* | ||
* @param message – the detail message | ||
* | ||
* @see Throwable#Throwable(String, Throwable, boolean, boolean) | ||
*/ | ||
public StaticException(String message) | ||
{ | ||
this(message, false); | ||
} | ||
|
||
/** | ||
* Create an instance with suppression disabled. | ||
* | ||
* @param message – the detail message | ||
* @param writableStackTrace whether or not the stack trace should be writable | ||
* | ||
* @see Throwable#Throwable(String, Throwable, boolean, boolean) | ||
*/ | ||
public StaticException(String message, boolean writableStackTrace) | ||
{ | ||
// Make sure to call the super constructor that disables suppressed exception. | ||
super(message, null, false, writableStackTrace); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters