Skip to content

Commit

Permalink
Add more debug logging to smoke test async servlet (open-telemetry#8720)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Jun 14, 2023
1 parent 39f4891 commit 04704c7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) {

private static void handleRequest(AsyncContext ac) {
System.err.println("dispatch async request");
ac.dispatch("/greeting");
try {
ac.dispatch("/greeting");
System.err.println("async request dispatched");
} catch (Throwable throwable) {
System.err.println("dispatching async request failed");
throwable.printStackTrace();
throw throwable;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

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

// We have to run on Java 8, so no Java 9 stream transfer goodies for us.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) {

private static void handleRequest(AsyncContext ac) {
System.err.println("dispatch async request");
ac.dispatch("/greeting");
try {
ac.dispatch("/greeting");
System.err.println("async request dispatched");
} catch (Throwable throwable) {
System.err.println("dispatching async request failed");
throwable.printStackTrace();
throw throwable;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
import java.net.URLConnection;
import java.util.Objects;

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

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

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

0 comments on commit 04704c7

Please sign in to comment.