eclipse-ee4j / eclipse-ee4j/jersey

EventProcessor - hides unhandled exception at run()

Open
#3,537 7 comments 0 reactions 0 assignees View on GitHub
Priority: Major Type: Bug
Dominant language
Java
Stars
730
Forks
382
PR merge metrics
No merged PRs in 30d

Description

When I've created EventSource and opened connection it was working fine, but somewhere at some point during the run the process stopped without any error shown.

here is code piece that was run:

```
Client client = ClientBuilder.newBuilder().register(SseFeature.class).build();
WebTarget target = client.target("/relative/url");

EventSource eventSource = EventSource.target(target).build();
EventListener listener = new EventListener() {

@Override
public void onEvent(InboundEvent inboundEvent) {
log.debug(inboundEvent.getName() + "; " + inboundEvent.readData(String.class));
}
};
eventSource.register(listener);
eventSource.open();
```

this runs ok, but if you run

```
eventSource.isOpen();
```

it always returns false;

after debugging for some time and reading the source codes, I found
org.glassfish.jersey.media.sse.EventSource.EventProcessor with method run(). It has try-catch block with catch(Exception e). but ![](https://java.net/jira/images/icons/emoticons/warning.gif) the exception in never rethrown.

```
catch (Exception ex) {
if (LOGGER.isLoggable(CONNECTION_ERROR_LEVEL)) {
LOGGER.log(CONNECTION_ERROR_LEVEL, String.format("Unable to connect - closing the event source to %s.",
target.getUri().toASCIIString()), ex);
}
// if we're here, an unrecoverable error has occurred - just turn off the lights...
EventSource.this.shutdown();
// <---- here should rethrow, after successfully clossing app. worse yet, it will be hidden, if error occurs during shutdown.
}
```

Logger did not show anything so to find this I had to make a break-point on it.

The final error was javax.ws.rs.ProcessingException: URI is not absolute. This error could have been catched at creation time.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.