Skip to content

Conversation

@j-baker
Copy link
Contributor

@j-baker j-baker commented Jun 8, 2018

At the moment, AssertionErrors are not handled by remoting, even though
they're used fairly widely within services and libraries we have
internally. This means that the body ends up being empty if they
ever get hit, which leads to a fairly cryptic exception being
thrown on the client.

Bugs are still debuggable, it's just harder. This PR makes the claim
that AssertionErrors should be handled specially.

Could also argue that all errors should be handled the same as e.g.
a random RuntimeException (specifically thinking NoSuchMethodError).

At the moment, AssertionErrors are not handled by remoting, even though
they're used fairly widely within services and libraries we have
internally. This means that the body ends up being empty if they
ever get hit, which leads to a fairly cryptic exception being
thrown on the client.

Bugs are still debuggable, it's just harder. This PR makes the claim
that AssertionErrors should be handled specially.

Could also argue that all errors should be handled the same as e.g.
a random RuntimeException (specifically thinking NoSuchMethodError).
import javax.ws.rs.ext.Provider;

@Provider
final class AssertionErrorExceptionMapper extends JsonExceptionMapper<AssertionError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem pretty obscure that people are throwing AssertionErrors - I've generally only seen them in private constructors (throw new AssertionError("Not instantiable");). However, I think it does makes sense that in the strange case that this happens, we might as well give clients something helpful.

Can we expand it to all Errors? This would get us NoSuchFieldError, NoSuchMethodError and NoClassDefFoundError?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanding to Error or Throwable would also cover the occasional OutOfMemoryError

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that was my reticence at the start. I guess there's the thing where we hope that OOMs get handled by the JVM itself?

@j-baker j-baker requested a review from a team as a code owner September 3, 2018 16:24
@j-baker
Copy link
Contributor Author

j-baker commented Sep 3, 2018

I have rewritten to be in terms of the above - aka all Throwables - since sls-packaging handles throwing on out-of-memory.

@iamdanfox
Copy link
Contributor

@iamdanfox iamdanfox merged commit ed7357e into develop Sep 3, 2018
dansanduleac pushed a commit that referenced this pull request Sep 13, 2018
* Expose HostMetricsRegistry record methods (#780)

This is so that we can separately implement a HostMetricsSink for it (see #779) such that we can share host metrics when constructing both conjure and remoting3 clients

* publish BOM for jaxrs-client (#789)

* Excavator: Render CircleCI file using template specified in .circleci/template.sh (#791)

* Upgrade OkHttp to 3.11.0. (#794)

* AssertionErrors are converted into service exceptions with type internal (#727)

* No more ThreadLocals, delegate everything to 'palantir/tracing-java' (#799)

* Use BINTRAY_*_REMOTING envs (#802)

The project's default bintray creds are currently set up to publish to `conjure-java-runtime`.
Use these custom env vars to maintain ability to publish http-remoting.

* Better behaviour in the presence of 429s (#786)
@iamdanfox iamdanfox deleted the jbaker/assertion_error_handling branch November 5, 2018 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants