aws / aws/aws-xray-sdk-java

Should Entity#close throw Exception?

Open
#31 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
100
Forks
100
PR merge metrics
No merged PRs in 30d

Description

`Entity` extends `Autoclosable` allowing `Entity#close` to throw any `Exception`. However both `Segment` and `Subsegment` interfaces override `close` to ditch the `Exception`. This discrepancy causes me troubles as it means that `(Subs|S)egment` can be easily wrapped in a try-with-resource statement but doing the same with `Entity` requires an explicit error path.

Why would `Entity#close` throw a checked `Exception`? As `AWSXrayRecorder#end(Subs|S)egment` only raise `(Subs|S)egementNotFoundException` and close seems an _alternative_ way to end an entity, I wouldn't expect it to throw any exception. What is the caller expected to do when a such exception is thrown?

My current understanding of the API is that `Entity#close` should not throw and this is an oversight but please correct me if I am wrong.

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.