Skip to content

Remove ObjectMapper::copy() from QueryResource#1092

Merged
xvrl merged 1 commit intoapache:masterfrom
metamx:jacksonObjectMapperCopyFix
Feb 11, 2015
Merged

Remove ObjectMapper::copy() from QueryResource#1092
xvrl merged 1 commit intoapache:masterfrom
metamx:jacksonObjectMapperCopyFix

Conversation

@drcrallen
Copy link
Copy Markdown
Contributor

Ran into this one while working on Query-time Lookups.

Essentially anything annotated with @JacksonInject that's in the query codepath does not inject at all currently.

The configuration codepath still works as intended as far as I know.

This now uses the default configuration for ObjectMapper (@Json and @Smile) which may auto-close the input/outputs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems to be happening because we are storing a copy of the ObjectMapper, can we instead just not try to store a copy?

I think we are doing this so that we can set the config below this, but from looking at the code, I don't think we need to do that even. If closing the OutputStream we are being handed in the streaming response breaks something, then we can wrap that object such that the close() method doesn't actually do anything instead of setting this parameter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That could break if the current behavior relies on something other than ObjectMapper to do the closing. I'll look at it more when I have fresh eyes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From what I can tell, nothing is actually closing the OutputStream, which makes me think that it is the Jersey framework that is taking on that responsibility.

If that is the case, then I really think that it is the Jersey framework's job to make sure that calling close() on the OutputStream doesn't screw with things. But if they haven't done that, it should be easy enough for us to ensure that close() doesn't get called.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree with that. As a matter of fact, the only closable stream the objectMapper seems to be used on is the input stream where it parses the Query datatype. After trying a few quick examples it seems to function fine without the close. I'm going to try a few more tests then get rid of the copy completely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

After investigating the code and running a few tests, there doesn't seem to be any side effect of using the injected ObjectMappers. I'm uploading a new commit which removes the copy. I'll change the PR title when that is up.

@drcrallen
Copy link
Copy Markdown
Contributor Author

It is worth noting some of the changes were from a blanket reformat code... applied to the files that were touched.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This line is the actual change

@drcrallen drcrallen force-pushed the jacksonObjectMapperCopyFix branch 2 times, most recently from a6ad941 to 8134daf Compare February 5, 2015 17:03
@drcrallen
Copy link
Copy Markdown
Contributor Author

TravisCI failed on unrelated code.

@drcrallen drcrallen force-pushed the jacksonObjectMapperCopyFix branch from 8134daf to 1febc0a Compare February 5, 2015 18:00
@drcrallen drcrallen changed the title Workaround for https://github.com/FasterXML/jackson-databind/issues/696 Remove ObjectMapper::copy() from QueryResource Feb 5, 2015
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since we don't need to inject InjectableValues (which is in itself a very confusing thing), we can probably remove this method entirely or at least remove Guice annotations and make it private.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@drcrallen drcrallen force-pushed the jacksonObjectMapperCopyFix branch from 1febc0a to a6b3fa9 Compare February 11, 2015 00:48
@drcrallen drcrallen force-pushed the jacksonObjectMapperCopyFix branch from a6b3fa9 to d51b37c Compare February 11, 2015 00:50
@cheddar
Copy link
Copy Markdown
Contributor

cheddar commented Feb 11, 2015

LGTM, any reason not to merge?

@xvrl
Copy link
Copy Markdown
Member

xvrl commented Feb 11, 2015

I was just waiting for Charles to remove the unnecessary Guice stuff, looks like that's done now.

xvrl added a commit that referenced this pull request Feb 11, 2015
Remove ObjectMapper::copy() from QueryResource
@xvrl xvrl merged commit 8410023 into apache:master Feb 11, 2015
@xvrl xvrl deleted the jacksonObjectMapperCopyFix branch February 11, 2015 17:45
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.

3 participants