GeezerVison is showing github.com — Issue #868 - Use static Throwables without backtrace/stackTrace · grgrzybek/jetty.project@68f1793
File tree
Expand file treeCollapse file tree
Open diff view settings
jetty-continuation/src/main/java/org/eclipse/jetty/continuation jetty-util/src/main/java/org/eclipse/jetty/util
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: jetty-continuation/src/main/java/org/eclipse/jetty/continuation/ContinuationThrowable.java +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
43 | 43 | * </p> |
44 | 44 | */ |
45 | 45 | public class ContinuationThrowable extends Error |
46 | | -{} |
| 46 | +{ |
| 47 | + public ContinuationThrowable() |
| 48 | + { |
| 49 | + super(null, null, false, false); |
| 50 | + } |
| 51 | +} |
Collapse file
Copy file name to clipboard +43Lines changed: 43 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// |
| 2 | +// ======================================================================== |
| 3 | +// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd. |
| 4 | +// ------------------------------------------------------------------------ |
| 5 | +// All rights reserved. This program and the accompanying materials |
| 6 | +// are made available under the terms of the Eclipse Public License v1.0 |
| 7 | +// and Apache License v2.0 which accompanies this distribution. |
| 8 | +// |
| 9 | +// The Eclipse Public License is available at |
| 10 | +// http://www.eclipse.org/legal/epl-v10.html |
| 11 | +// |
| 12 | +// The Apache License v2.0 is available at |
| 13 | +// http://www.opensource.org/licenses/apache2.0.php |
| 14 | +// |
| 15 | +// You may elect to redistribute this code under either of these licenses. |
| 16 | +// ======================================================================== |
| 17 | +// |
| 18 | + |
| 19 | +package org.eclipse.jetty.util; |
| 20 | + |
| 21 | +/** |
| 22 | + * A {@link Throwable} that may be used in static contexts. It uses Java 7 |
| 23 | + * constructor that prevents setting stackTrace inside exception object. |
| 24 | + */ |
| 25 | +public class ConstantThrowable extends Throwable { |
| 26 | + |
| 27 | + private String name; |
| 28 | + |
| 29 | + public ConstantThrowable() { |
| 30 | + this(null); |
| 31 | + } |
| 32 | + |
| 33 | + public ConstantThrowable(String name) { |
| 34 | + super(null, null, false, false); |
| 35 | + this.name = name; |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public String toString() { |
| 40 | + return name; |
| 41 | + } |
| 42 | + |
| 43 | +} |
Collapse file
Copy file name to clipboardExpand all lines: jetty-util/src/main/java/org/eclipse/jetty/util/FutureCallback.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
29 | 29 |
|
30 | 30 | public class FutureCallback implements Future<Void>,Callback |
31 | 31 | { |
32 | | - private static Throwable COMPLETED=new Throwable(); |
| 32 | + private static Throwable COMPLETED=new ConstantThrowable(); |
33 | 33 | private final AtomicBoolean _done=new AtomicBoolean(false); |
34 | 34 | private final CountDownLatch _latch=new CountDownLatch(1); |
35 | 35 | private Throwable _cause; |
|
Collapse file
Copy file name to clipboardExpand all lines: jetty-util/src/main/java/org/eclipse/jetty/util/FuturePromise.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
29 | 29 |
|
30 | 30 | public class FuturePromise<C> implements Future<C>,Promise<C> |
31 | 31 | { |
32 | | - private static Throwable COMPLETED=new Throwable(); |
| 32 | + private static Throwable COMPLETED=new ConstantThrowable(); |
33 | 33 | private final AtomicBoolean _done=new AtomicBoolean(false); |
34 | 34 | private final CountDownLatch _latch=new CountDownLatch(1); |
35 | 35 | private Throwable _cause; |
|
Collapse file
Copy file name to clipboardExpand all lines: jetty-util/src/main/java/org/eclipse/jetty/util/SharedBlockingCallback.java +3-24Lines changed: 3 additions & 24 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
50 | 50 | public class SharedBlockingCallback |
51 | 51 | { |
52 | 52 | static final Logger LOG = Log.getLogger(SharedBlockingCallback.class); |
53 | | - private static Throwable IDLE = new Throwable() |
54 | | - { |
55 | | - @Override |
56 | | - public String toString() |
57 | | - { |
58 | | - return "IDLE"; |
59 | | - } |
60 | | - }; |
61 | | - private static Throwable SUCCEEDED = new Throwable() |
62 | | - { |
63 | | - @Override |
64 | | - public String toString() |
65 | | - { |
66 | | - return "SUCCEEDED"; |
67 | | - } |
68 | | - }; |
69 | | - private static Throwable FAILED = new Throwable() |
70 | | - { |
71 | | - @Override |
72 | | - public String toString() |
73 | | - { |
74 | | - return "FAILED"; |
75 | | - } |
76 | | - }; |
| 53 | + private static Throwable IDLE = new ConstantThrowable("IDLE"); |
| 54 | + private static Throwable SUCCEEDED = new ConstantThrowable("SUCCEEDED"); |
| 55 | + private static Throwable FAILED = new ConstantThrowable("FAILED"); |
77 | 56 |
|
78 | 57 | private final ReentrantLock _lock = new ReentrantLock(); |
79 | 58 | private final Condition _idle = _lock.newCondition(); |
|