Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <[email protected]>
  • Loading branch information
jbescos committed Nov 6, 2024
1 parent 9da8b32 commit 60545b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.lang.annotation.Annotation;
import java.net.URI;
import java.util.Arrays;
Expand Down Expand Up @@ -205,7 +204,7 @@ public void close() throws ProcessingException {
closed = true;
try {
context.close();
} catch (IOException | UncheckedIOException e) {
} catch (Exception e) {
// Just log the exception
Logger.getLogger(OutboundJaxrsResponse.class.getName()).log(Level.FINE, e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;
import java.io.OutputStream;
import java.io.UncheckedIOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.ArrayList;
Expand Down Expand Up @@ -555,22 +556,27 @@ public boolean isCommitted() {

/**
* Closes the context. Flushes and closes the entity stream.
* @throws IOException if errors
* @throws UncheckedIOException if IO errors
*/
public void close() throws IOException {
public void close() {
if (hasEntity()) {
try {
final OutputStream es = getEntityStream();
if (!FlushedCloseable.class.isInstance(es)) {
es.flush();
}
es.close();
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
// In case some of the output stream wrapper does not delegate close() call we
// close the root stream manually to make sure it commits the data.
if (!committingOutputStream.isClosed()) {
// It is possible that es.flush() or es.close() threw one exception already and we throw a new one here.
try {
committingOutputStream.close();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Response closeException(@Context ContainerRequest request) {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if ("failure".equals(method.getName())) {
exceptionMessage = ((Throwable) args[0]).getMessage();
exceptionMessage = ((Throwable) args[0]).getCause().getMessage();
}
return method.invoke(writer, args);
}
Expand Down

0 comments on commit 60545b7

Please sign in to comment.