ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
assertEquals("OK", bc.toString());
+ // Give the async thread a chance to finish (but not too long)
+ int counter = 0;
+ while (!servlet.isDone() && counter < 10) {
+ Thread.sleep(1000);
+ counter++;
+ }
assertEquals("1false2true3true4true5false", servlet.getResult());
}
ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
assertEquals("OK", bc.toString());
+ // Give the async thread a chance to finish (but not too long)
+ int counter = 0;
+ while (!servlet.isDone() && counter < 10) {
+ Thread.sleep(1000);
+ counter++;
+ }
+
assertEquals("1false2true3true4true5false", servlet.getResult());
}
assertEquals("OK", bc.toString());
}
+ /*
+ * NOTE: This servlet is only intended to be used in single-threaded tests.
+ */
private static class Bug49528Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;
- private StringBuilder result = new StringBuilder();
+ private volatile boolean done = false;
+
+ private StringBuilder result;
public String getResult() {
return result.toString();
}
+ public boolean isDone() {
+ return done;
+ }
+
@Override
protected void doGet(final HttpServletRequest req,
final HttpServletResponse resp)
throws ServletException, IOException {
+ result = new StringBuilder();
result.append('1');
result.append(req.isAsyncStarted());
req.startAsync();
req.getAsyncContext().complete();
result.append('5');
result.append(req.isAsyncStarted());
+ done = true;
} catch (InterruptedException e) {
result.append(e);
} catch (IOException e) {
}
}
+ /*
+ * NOTE: This servlet is only intended to be used in single-threaded tests.
+ */
private static class Bug49567Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;
- private StringBuilder result = new StringBuilder();
+ private volatile boolean done = false;
+
+ private StringBuilder result;
public String getResult() {
return result.toString();
}
+ public boolean isDone() {
+ return done;
+ }
+
@Override
protected void doGet(final HttpServletRequest req,
final HttpServletResponse resp)
throws ServletException, IOException {
+ result = new StringBuilder();
result.append('1');
result.append(req.isAsyncStarted());
req.startAsync();
req.getAsyncContext().complete();
result.append('5');
result.append(req.isAsyncStarted());
+ done = true;
} catch (InterruptedException e) {
result.append(e);
} catch (IOException e) {