Skip to content

Serialization format of nio Path changed between 2.7.4 and 2.8.0.rc1 #1264

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

Closed
michaelhixson opened this issue Jun 8, 2016 · 3 comments
Closed
Milestone

Comments

@michaelhixson
Copy link
Contributor

The JSON serialization of java.nio.file.Path changed between 2.7.4 and 2.8.0.rc1, causing a couple of my tests to fail:

public void testRelativePath() throws Exception {
  ObjectMapper mapper = new ObjectMapper();
  Path expected = Paths.get("one/two/three");
  String json = mapper.writeValueAsString(expected);
  Path actual = mapper.readValue(json, Path.class);
  assertEquals(expected, actual);
}

public void testAbsolutePath() throws Exception {
  ObjectMapper mapper = new ObjectMapper();
  Path expected = Paths.get("/one/two/three");
  String json = mapper.writeValueAsString(expected);
  Path actual = mapper.readValue(json, Path.class);
  assertEquals(expected, actual);
}

In 2.8.0.rc1 the relative path becomes a "file:///" URI in the JSON string, which is an absolute URI including my current working directory, and then after deserializing it remains an absolute path. In the second test, the absolute path gets prepended with "C:" (I'm using Windows).

It turns out I'm not actually serializing Path objects anywhere except my tests. They're leftovers from previous functionality. So I personally have no problem with simply deleting my tests.

Maybe this change should be called out in the release notes though? I didn't see anything about it here: https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.8

@cowtowncoder
Copy link
Member

@michaelhixson good point. It's most likely due #1235 and I will add a note (both in individual updates, and under compatibility issues section).

@benson-basis just an fyi, regarding relative path, if there's anything that could or should be done for backwards compatibility.

@cowtowncoder cowtowncoder added this to the 2.8.0.rc2 milestone Jun 8, 2016
@cowtowncoder
Copy link
Member

Updated release notes pages.

@benson-basis
Copy link
Contributor

I'm on vacation, I'll think upon it.

On Tue, Jun 7, 2016 at 10:02 PM, Tatu Saloranta [email protected]
wrote:

Closed #1264 #1264.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1264 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ADM9zyx20k1CAbuToDcI-iOJkY7QSnpNks5qJiKcgaJpZM4IwfWh
.

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

No branches or pull requests

3 participants