Skip to content

Commit

Permalink
override com.sun.jersey.spi.container.servlet.WebComponent #1
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrenn committed Dec 26, 2024
1 parent c7aa58b commit 1a72d7a
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
import java.net.URI;
Expand Down Expand Up @@ -245,11 +247,21 @@ public void finish() throws IOException {
private void writeStatus() {
Response.StatusType statusType = cResponse.getStatusType();
final String reasonPhrase = statusType.getReasonPhrase();
//if (reasonPhrase != null) {
// response.setStatus(statusType.getStatusCode(), reasonPhrase);
//} else {
response.setStatus(statusType.getStatusCode());
//}
if (reasonPhrase != null) {
try {
response.setStatus(statusType.getStatusCode(), reasonPhrase);
} catch (NoSuchMethodError e) {
try {
Method setError = response.getClass().getMethod("setError", int.class, String.class);
setError.invoke(response, statusType.getStatusCode(), reasonPhrase);
} catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e1) {
//response.setStatus(statusType.getStatusCode());
response.setStatus(statusType.getStatusCode(), reasonPhrase);
}
}
} else {
response.setStatus(statusType.getStatusCode());
}
}

public void write(int b) throws IOException {
Expand Down

0 comments on commit 1a72d7a

Please sign in to comment.