Skip to content

Commit 556dddd

Browse files
committed
Don't use Netty's ThrowableUtil which is internal
1 parent af0c897 commit 556dddd

File tree

8 files changed

+40
-9
lines changed

8 files changed

+40
-9
lines changed

client/src/main/java/org/asynchttpclient/exception/ChannelClosedException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
*/
1313
package org.asynchttpclient.exception;
1414

15-
import java.io.IOException;
15+
import static org.asynchttpclient.util.ThrowableUtil.unknownStackTrace;
1616

17-
import static io.netty.util.internal.ThrowableUtil.*;
17+
import java.io.IOException;
1818

1919
@SuppressWarnings("serial")
2020
public final class ChannelClosedException extends IOException {

client/src/main/java/org/asynchttpclient/exception/PoolAlreadyClosedException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
package org.asynchttpclient.exception;
1414

15-
import static io.netty.util.internal.ThrowableUtil.unknownStackTrace;
15+
import static org.asynchttpclient.util.ThrowableUtil.unknownStackTrace;
1616

1717
import java.io.IOException;
1818

client/src/main/java/org/asynchttpclient/exception/RemotelyClosedException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
package org.asynchttpclient.exception;
1414

15-
import static io.netty.util.internal.ThrowableUtil.unknownStackTrace;
15+
import static org.asynchttpclient.util.ThrowableUtil.unknownStackTrace;
1616

1717
import java.io.IOException;
1818

client/src/main/java/org/asynchttpclient/netty/channel/ConnectionSemaphore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
*/
1414
package org.asynchttpclient.netty.channel;
1515

16+
import static org.asynchttpclient.util.ThrowableUtil.unknownStackTrace;
17+
1618
import java.io.IOException;
1719
import java.util.concurrent.ConcurrentHashMap;
1820

1921
import org.asynchttpclient.AsyncHttpClientConfig;
2022
import org.asynchttpclient.exception.TooManyConnectionsException;
2123
import org.asynchttpclient.exception.TooManyConnectionsPerHostException;
2224

23-
import static io.netty.util.internal.ThrowableUtil.unknownStackTrace;
24-
2525
/**
2626
* Max connections and max-per-host connections limiter.
2727
*

client/src/main/java/org/asynchttpclient/netty/handler/intercept/Redirect30xInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
package org.asynchttpclient.netty.handler.intercept;
1515

1616
import static io.netty.handler.codec.http.HttpHeaderNames.*;
17-
import static io.netty.util.internal.ThrowableUtil.unknownStackTrace;
1817
import static org.asynchttpclient.util.HttpConstants.Methods.GET;
1918
import static org.asynchttpclient.util.HttpConstants.ResponseStatusCodes.*;
2019
import static org.asynchttpclient.util.HttpUtils.*;
2120
import static org.asynchttpclient.util.MiscUtils.isNonEmpty;
21+
import static org.asynchttpclient.util.ThrowableUtil.unknownStackTrace;
2222
import io.netty.channel.Channel;
2323
import io.netty.handler.codec.http.HttpHeaders;
2424
import io.netty.handler.codec.http.HttpResponse;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2017 AsyncHttpClient Project. All rights reserved.
3+
*
4+
* This program is licensed to you under the Apache License Version 2.0,
5+
* and you may not use this file except in compliance with the Apache License Version 2.0.
6+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7+
*
8+
* Unless required by applicable law or agreed to in writing,
9+
* software distributed under the Apache License Version 2.0 is distributed on an
10+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12+
*/
13+
package org.asynchttpclient.util;
14+
15+
public final class ThrowableUtil {
16+
17+
private ThrowableUtil() {
18+
}
19+
20+
/**
21+
* @param <T> the Throwable type
22+
* @param t the throwable whose stacktrace we want to remove
23+
* @param clazz the caller class
24+
* @param method the caller method
25+
* @return the input throwable with removed stacktrace
26+
*/
27+
public static <T extends Throwable> T unknownStackTrace(T t, Class<?> clazz, String method) {
28+
t.setStackTrace(new StackTraceElement[] { new StackTraceElement(clazz.getName(), method, null, -1) });
29+
return t;
30+
}
31+
}

client/src/test/java/org/asynchttpclient/AsyncStreamHandlerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
package org.asynchttpclient;
1717

1818
import static io.netty.handler.codec.http.HttpHeaderNames.*;
19-
import static io.netty.util.internal.ThrowableUtil.unknownStackTrace;
2019
import static java.nio.charset.StandardCharsets.US_ASCII;
2120
import static org.asynchttpclient.Dsl.config;
2221
import static org.asynchttpclient.test.TestUtils.*;
22+
import static org.asynchttpclient.util.ThrowableUtil.unknownStackTrace;
2323
import static org.testng.Assert.*;
2424
import io.netty.handler.codec.http.HttpHeaderValues;
2525
import io.netty.handler.codec.http.HttpHeaders;

client/src/test/java/org/asynchttpclient/BasicHttpTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
package org.asynchttpclient;
1515

1616
import static io.netty.handler.codec.http.HttpHeaderNames.*;
17-
import static io.netty.util.internal.ThrowableUtil.unknownStackTrace;
1817
import static java.nio.charset.StandardCharsets.ISO_8859_1;
1918
import static java.util.concurrent.TimeUnit.SECONDS;
2019
import static org.asynchttpclient.Dsl.*;
2120
import static org.asynchttpclient.test.TestUtils.*;
2221
import static org.asynchttpclient.util.DateUtils.unpreciseMillisTime;
22+
import static org.asynchttpclient.util.ThrowableUtil.unknownStackTrace;
2323
import static org.testng.Assert.*;
2424
import io.netty.handler.codec.http.DefaultHttpHeaders;
2525
import io.netty.handler.codec.http.HttpHeaderValues;

0 commit comments

Comments
 (0)