Skip to content

Commit 393bb60

Browse files
committed
asyncGetWithTimeout test uncommented
Signed-off-by: Gaurav Gupta <[email protected]>
1 parent 5319e79 commit 393bb60

File tree

1 file changed

+22
-23
lines changed
  • connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector

1 file changed

+22
-23
lines changed

connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AsyncTest.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -113,29 +113,28 @@ public void handleTimeout(AsyncResponse asyncResponse) {
113113
asyncResponse.resume(Response.status(Response.Status.SERVICE_UNAVAILABLE)
114114
.entity("Operation time out.").build());
115115

116-
// new Thread(new Runnable() {
117-
//
118-
// @Override
119-
// public void run() {
120-
// String result = veryExpensiveOperation();
121-
// asyncResponse.resume(result);
122-
// }
123-
//
124-
// private String veryExpensiveOperation() {
125-
// // very expensive operation that typically finishes within 1 second but can take up to 5 seconds,
126-
// // simulated using sleep()
127-
// try {
128-
// Thread.sleep(5 * OPERATION_DURATION);
129-
// return "DONE";
130-
// } catch (InterruptedException e) {
131-
// Thread.currentThread().interrupt();
132-
// return "INTERRUPTED";
133-
// } finally {
134-
// LOGGER.info("Async long-running get with timeout finished on thread " +
135-
// Thread.currentThread().getName());
136-
// }
137-
// }
138-
// }).start();
116+
new Thread(new Runnable() {
117+
118+
@Override
119+
public void run() {
120+
String result = veryExpensiveOperation();
121+
asyncResponse.resume(result);
122+
}
123+
124+
private String veryExpensiveOperation() {
125+
// very expensive operation that typically finishes within 1 second but can take up to 5 seconds,
126+
// simulated using sleep()
127+
try {
128+
Thread.sleep(5 * OPERATION_DURATION);
129+
return "DONE";
130+
} catch (InterruptedException e) {
131+
Thread.currentThread().interrupt();
132+
return "INTERRUPTED";
133+
} finally {
134+
LOGGER.info("Async long-running get with timeout finished on thread " + Thread.currentThread().getName());
135+
}
136+
}
137+
}).start();
139138
}
140139

141140
}

0 commit comments

Comments
 (0)