Skip to content

Commit 04704c7

Browse files
authored
Add more debug logging to smoke test async servlet (open-telemetry#8720)
1 parent 39f4891 commit 04704c7

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

smoke-tests/images/servlet/servlet-3.0/src/main/java/io/opentelemetry/smoketest/matrix/AsyncGreetingServlet.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
5757

5858
private static void handleRequest(AsyncContext ac) {
5959
System.err.println("dispatch async request");
60-
ac.dispatch("/greeting");
60+
try {
61+
ac.dispatch("/greeting");
62+
System.err.println("async request dispatched");
63+
} catch (Throwable throwable) {
64+
System.err.println("dispatching async request failed");
65+
throwable.printStackTrace();
66+
throw throwable;
67+
}
6168
}
6269
}

smoke-tests/images/servlet/servlet-3.0/src/main/java/io/opentelemetry/smoketest/matrix/GreetingServlet.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
import javax.servlet.http.HttpServletRequest;
1818
import javax.servlet.http.HttpServletResponse;
1919

20+
@SuppressWarnings("SystemOut")
2021
public class GreetingServlet extends HttpServlet {
2122
private static final long serialVersionUID = 1L;
2223

2324
@Override
2425
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
26+
System.err.println("called GreetingServlet doGet");
2527
String path = (req.getContextPath() + "/headers").replace("//", "/");
2628
URL url = new URL("http", "localhost", req.getLocalPort(), path);
2729
URLConnection urlConnection = url.openConnection();
@@ -34,6 +36,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO
3436
bytesRead + " bytes read by " + urlConnection.getClass().getName() + "\n" + responseBody);
3537
outputStream.flush();
3638
}
39+
System.err.println("GreetingServlet doGet completed");
3740
}
3841

3942
// We have to run on Java 8, so no Java 9 stream transfer goodies for us.

smoke-tests/images/servlet/servlet-5.0/src/main/java/io/opentelemetry/smoketest/matrix/AsyncGreetingServlet.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
5656

5757
private static void handleRequest(AsyncContext ac) {
5858
System.err.println("dispatch async request");
59-
ac.dispatch("/greeting");
59+
try {
60+
ac.dispatch("/greeting");
61+
System.err.println("async request dispatched");
62+
} catch (Throwable throwable) {
63+
System.err.println("dispatching async request failed");
64+
throwable.printStackTrace();
65+
throw throwable;
66+
}
6067
}
6168
}

smoke-tests/images/servlet/servlet-5.0/src/main/java/io/opentelemetry/smoketest/matrix/GreetingServlet.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
import java.net.URLConnection;
1818
import java.util.Objects;
1919

20+
@SuppressWarnings("SystemOut")
2021
public class GreetingServlet extends HttpServlet {
2122
private static final long serialVersionUID = 1L;
2223

2324
@Override
2425
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
26+
System.err.println("called GreetingServlet doGet");
2527
String path = (req.getContextPath() + "/headers").replace("//", "/");
2628
URL url = new URL("http", "localhost", req.getLocalPort(), path);
2729
URLConnection urlConnection = url.openConnection();
@@ -34,6 +36,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IO
3436
bytesRead + " bytes read by " + urlConnection.getClass().getName() + "\n" + responseBody);
3537
outputStream.flush();
3638
}
39+
System.err.println("GreetingServlet doGet completed");
3740
}
3841

3942
// We have to run on Java 8, so no Java 9 stream transfer goodies for us.

0 commit comments

Comments
 (0)