Skip to content

Commit 77b90fc

Browse files
authored
Update the default expected exception in server tests (#12555)
1 parent 050e299 commit 77b90fc

File tree

37 files changed

+29
-57
lines changed

37 files changed

+29
-57
lines changed

instrumentation/akka/akka-http-10.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/akkahttp/AkkaHttpTestAsyncWebServer.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ object AkkaHttpTestAsyncWebServer {
4747
case QUERY_PARAM => resp.withEntity(uri.queryString().orNull)
4848
case REDIRECT =>
4949
resp.withHeaders(headers.Location(endpoint.getBody))
50-
case ERROR => resp.withEntity(endpoint.getBody)
51-
case EXCEPTION => throw new Exception(endpoint.getBody)
50+
case ERROR => resp.withEntity(endpoint.getBody)
51+
case EXCEPTION =>
52+
throw new IllegalStateException(endpoint.getBody)
5253
case _ =>
5354
HttpResponse(status = NOT_FOUND.getStatus)
5455
.withEntity(NOT_FOUND.getBody)

instrumentation/akka/akka-http-10.0/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/akkahttp/AkkaHttpTestSyncWebServer.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ object AkkaHttpTestSyncWebServer {
4444
case QUERY_PARAM => resp.withEntity(uri.queryString().orNull)
4545
case REDIRECT =>
4646
resp.withHeaders(headers.Location(endpoint.getBody))
47-
case ERROR => resp.withEntity(endpoint.getBody)
48-
case EXCEPTION => throw new Exception(endpoint.getBody)
47+
case ERROR => resp.withEntity(endpoint.getBody)
48+
case EXCEPTION =>
49+
throw new IllegalStateException(endpoint.getBody)
4950
case _ =>
5051
HttpResponse(status = NOT_FOUND.getStatus)
5152
.withEntity(NOT_FOUND.getBody)

instrumentation/armeria/armeria-1.3/testing/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/AbstractArmeriaHttpServerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected Server setupServer() {
8282
.runWithSpan(
8383
"controller",
8484
() -> {
85-
throw new Exception(EXCEPTION.getBody());
85+
throw new IllegalStateException(EXCEPTION.getBody());
8686
}));
8787

8888
sb.service(

instrumentation/finatra-2.9/javaagent/src/latestDepTest/scala/io/opentelemetry/javaagent/instrumentation/finatra/FinatraController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class FinatraController extends Controller {
3333
any(EXCEPTION.getPath) { request: Request =>
3434
controller(
3535
EXCEPTION,
36-
supplier(() => throw new Exception(EXCEPTION.getBody))
36+
supplier(() => throw new IllegalStateException(EXCEPTION.getBody))
3737
)
3838
}
3939

instrumentation/finatra-2.9/javaagent/src/latestDepTest/scala/io/opentelemetry/javaagent/instrumentation/finatra/FinatraServerLatestTest.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ class FinatraServerLatestTest extends AbstractHttpServerTest[HttpServer] {
7878
if (endpoint == ServerEndpoint.EXCEPTION) {
7979
span
8080
.hasStatus(StatusData.error())
81-
.hasException(new Exception(ServerEndpoint.EXCEPTION.getBody))
81+
.hasException(
82+
new IllegalStateException(ServerEndpoint.EXCEPTION.getBody)
83+
)
8284
}
8385

8486
span

instrumentation/finatra-2.9/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/finatra/FinatraController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FinatraController extends Controller {
3636
any(EXCEPTION.getPath) { request: Request =>
3737
controller(
3838
EXCEPTION,
39-
supplier(() => throw new Exception(EXCEPTION.getBody))
39+
supplier(() => throw new IllegalStateException(EXCEPTION.getBody))
4040
)
4141
}
4242

instrumentation/finatra-2.9/javaagent/src/test/scala/io/opentelemetry/javaagent/instrumentation/finatra/FinatraServerTest.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ class FinatraServerTest extends AbstractHttpServerTest[HttpServer] {
7979
if (endpoint == ServerEndpoint.EXCEPTION) {
8080
span
8181
.hasStatus(StatusData.error())
82-
.hasException(new Exception(ServerEndpoint.EXCEPTION.getBody))
82+
.hasException(
83+
new IllegalStateException(ServerEndpoint.EXCEPTION.getBody)
84+
)
8385
}
8486

8587
span

instrumentation/grails-3.0/javaagent/src/test/groovy/test/TestController.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class TestController implements Controller {
5858
@Action
5959
def exception() {
6060
controller(EXCEPTION) {
61-
throw new Exception(EXCEPTION.body)
61+
throw new IllegalStateException(EXCEPTION.body)
6262
}
6363
}
6464

instrumentation/grails-3.0/javaagent/src/test/java/test/GrailsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public SpanDataAssert assertHandlerSpan(
156156
span.hasName(getHandlerSpanName(endpoint)).hasKind(SpanKind.INTERNAL);
157157
if (endpoint == EXCEPTION) {
158158
span.hasStatus(StatusData.error());
159-
span.hasException(new Exception(EXCEPTION.getBody()));
159+
span.hasException(new IllegalStateException(EXCEPTION.getBody()));
160160
}
161161
return span;
162162
}

instrumentation/jetty/jetty-11.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/jetty/v11_0/JettyHandlerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ protected void configure(HttpServerTestOptions options) {
8383
Sets.difference(
8484
DEFAULT_HTTP_ATTRIBUTES, Collections.singleton(HttpAttributes.HTTP_ROUTE)));
8585
options.setHasResponseSpan(endpoint -> endpoint == REDIRECT || endpoint == ERROR);
86-
options.setExpectedException(new IllegalStateException(EXCEPTION.getBody()));
8786
options.setHasResponseCustomizer(endpoint -> true);
8887
}
8988

0 commit comments

Comments
 (0)