Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 1801bf7

Browse files
Marek PotočiarGerrit Code Review
authored andcommitted
Merge "JERSEY-2494 AsyncResponse timeouts creates unnecessary GC pressure"
2 parents b0f03e2 + ea43b3d commit 1801bf7

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

containers/jdk-http/src/main/java/org/glassfish/jersey/jdkhttp/JdkHttpHandlerContainer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,12 @@ private long getResponseLength(long contentLength) {
291291

292292
@Override
293293
public boolean suspend(long timeOut, TimeUnit timeUnit, TimeoutHandler timeoutHandler) {
294-
throw new UnsupportedOperationException("Method suspend is not support by the container.");
294+
throw new UnsupportedOperationException("Method suspend is not supported by the container.");
295295
}
296296

297297
@Override
298298
public void setSuspendTimeout(long timeOut, TimeUnit timeUnit) throws IllegalStateException {
299-
throw new UnsupportedOperationException("Method suspend is not support by the container.");
299+
throw new UnsupportedOperationException("Method setSuspendTimeout is not supported by the container.");
300300
}
301301

302302
@Override

containers/jersey-servlet-core/src/main/java/org/glassfish/jersey/servlet/internal/ResponseWriter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ public void commit() {
206206
}
207207
}
208208
} finally {
209+
requestTimeoutHandler.close();
209210
asyncExt.complete();
210211
}
211212
}
@@ -233,6 +234,7 @@ public void failure(Throwable error) {
233234
}
234235
}
235236
} finally {
237+
requestTimeoutHandler.close();
236238
rethrow(error);
237239
}
238240
}

core-server/src/main/java/org/glassfish/jersey/server/ApplicationHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,13 +984,14 @@ public void commit() {
984984
// need to also strip the object entity as it was stripped when writing to output
985985
current.setEntity(null);
986986
}
987-
987+
requestTimeoutHandler.close();
988988
super.set(current);
989989
}
990990
}
991991

992992
@Override
993993
public void failure(final Throwable error) {
994+
requestTimeoutHandler.close();
994995
super.setException(error);
995996
}
996997

core-server/src/main/java/org/glassfish/jersey/server/internal/JerseyRequestTimeoutHandler.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ public void run() {
135135
throw new IllegalStateException(LocalizationMessages.SUSPEND_NOT_SUSPENDED());
136136
}
137137

138-
if (timeoutTask != null) {
139-
timeoutTask.cancel(true);
140-
timeoutTask = null;
141-
}
138+
close();
142139

143140
if (timeOut <= AsyncResponse.NO_TIMEOUT) {
144141
return;
@@ -151,4 +148,14 @@ public void run() {
151148
}
152149
}
153150
}
151+
152+
/**
153+
* Cancel the suspended task.
154+
*/
155+
public synchronized void close() {
156+
if (timeoutTask != null) {
157+
timeoutTask.cancel(true);
158+
timeoutTask = null;
159+
}
160+
}
154161
}

0 commit comments

Comments
 (0)