Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch empty body PUT request error #871

Merged
merged 1 commit into from Aug 18, 2015
Merged

Conversation

awoods
Copy link

@awoods awoods commented Aug 6, 2015

@acoburn
Copy link
Contributor

acoburn commented Aug 8, 2015

@awoods can you rebase this PR against fcrepo4/master?

@awoods
Copy link
Author

awoods commented Aug 10, 2015

@acoburn, rebased.

@ajs6f
Copy link
Contributor

ajs6f commented Aug 17, 2015

Travis appears to have failed. Also, are we confident that all places that Jena might throw a RuntimeIOException are places from which we want to map as done here?

@awoods
Copy link
Author

awoods commented Aug 17, 2015

Alternatives to mapping the Jena RuntimeIOException are to:

However, the Jena exception seems likely to be the result of a BAD_REQUEST scenario.
Regarding Travis, the branch builds locally. Probably a sporadic test error.

@ajs6f
Copy link
Contributor

ajs6f commented Aug 17, 2015

I'd rather take wrap the statement and check for the cause. RuntimeIOException is really generic. We could easily catch it and throw something more meaningful.

@awoods
Copy link
Author

awoods commented Aug 17, 2015

Sure. The downside, of course, is that there may be other places in the code that would benefit from a Jena RuntimeIOExceptionMapper.

@ajs6f
Copy link
Contributor

ajs6f commented Aug 17, 2015

Can we be sure what to produce (HTTP) for the generic case?

@awoods
Copy link
Author

awoods commented Aug 17, 2015

Can you clarify that question?

@ajs6f
Copy link
Contributor

ajs6f commented Aug 17, 2015

It's the same question with which I started. If you only have a RuntimeIOException and nothing else, can you be sure you know (in a mapper) what HTTP response to produce?

@awoods
Copy link
Author

awoods commented Aug 17, 2015

I would answer that question with, "yes", since this particular scenario is the first time the RuntimeIOException has surfaced.

However, if you would feel more comfortable with:

  • wrapping the specific location in ContentExposingResource, followed by
  • inspecting the RuntimeIOException cause, followed by
  • throwing a Fedora-specific exception (MalformedRdfException ??) that is caught by its own exception-mapper, I would be happy to add a new commit.

@ajs6f
Copy link
Contributor

ajs6f commented Aug 17, 2015

I honestly would. The semantics of RuntimeIOException are just what you'd think (just an unchecked IOException). I think rethrowing something (sure, MalformedRdfException, when that's appropriate) inside our code is cleaner. Especially if it turns out that there are several ways for the problem to happen (besides a purely empty body) and we want to distinguish them.

@awoods
Copy link
Author

awoods commented Aug 17, 2015

New commit responds to comments.
@ajs6f, let me know if this looks good to you. If so, I will squash the two commits.

@ajs6f
Copy link
Contributor

ajs6f commented Aug 18, 2015

Yeah, I like that much better. Thanks!

ajs6f added a commit that referenced this pull request Aug 18, 2015
Catch empty body PUT request error
@ajs6f ajs6f merged commit 68f99e1 into fcrepo:master Aug 18, 2015
@awoods awoods deleted the fcrepo-1667 branch August 18, 2015 19:16
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.

None yet

3 participants