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

Scala module (Jackson 3.x): some work needed wrt JSTEP-4 (unchecked exceptions) #494

Closed
cowtowncoder opened this issue Jan 19, 2021 · 6 comments
Assignees
Labels
3.x Something that likely has to be done in 3.x, not 2.x

Comments

@cowtowncoder
Copy link
Member

So, as per email I sent on jackson-dev, there is work for JSTEP-4 (https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-4), in particular:

FasterXML/jackson-databind#2177

and I intend to merge changes to master of most repos soon (January 19th, 2021), with force publish to get 3.0.0-SNAPSHOT. Right now changes are on exp/jstep-4-for-3.0 branches of affect repos, most notably for jackson-core and jackson-databind.

This issue is just created for coordination: I will update details once I merge changes. Not the ideal mechanism for sure, but hope it's better than mailing lists at least.

@cowtowncoder cowtowncoder added the 3.x Something that likely has to be done in 3.x, not 2.x label Jan 19, 2021
@cowtowncoder cowtowncoder changed the title Scala 3: some work needed wrt JSTEP-4 (unchecked exceptions) Scala module (Jackson 3.x): some work needed wrt JSTEP-4 (unchecked exceptions) Jan 19, 2021
@cowtowncoder
Copy link
Member Author

Changes mentioned have now been made and a new 3.0.0-SNAPSHOT of core components published.

In most cases changes needed should be simply either replacing "throws IOException" (and similar) with "throws JacksonException", or just removing (since exceptions are now unchecked): I have tried to indicate likeliest base exception for documentation purpose.

@pjfanning
Copy link
Member

scala does not force you to explicitly deal with exceptions -- it's almost like it treats every exception as a RuntimeException

so far, there are no issues with jackson-module-scala -- no new compile problems or additional test failures

@cowtowncoder
Copy link
Member Author

@pjfanning Excellent. Thank you for verification. I should be able to check this on my end too, just hadn't had time to see (still have some loose ends wrt JAX-RS).

@pjfanning
Copy link
Member

@cowtowncoder I updated a few compilation issues due to rename of getCurrentToken to currentToken.

These 5 issues still exist in main source (and others likely to exist in test source).

[info] compiling 60 Scala sources and 1 Java source to /Users/pj.fanning/code/jackson-module-scala/target/scala-2.13/classes ...
[error] /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/deser/EitherDeserializer.scala:53:22: value nextFieldName is not a member of com.fasterxml.jackson.core.JsonParser
[error]         val key = jp.nextFieldName()
[error]                      ^
[error] /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/ser/EitherSerializer.scala:106:10: value writeFieldName is not a member of com.fasterxml.jackson.core.JsonGenerator
[error]     jgen.writeFieldName(field)
[error]          ^
[error] /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/ser/EnumerationSerializerModule.scala:30:10: value writeStringField is not a member of com.fasterxml.jackson.core.JsonGenerator
[error]     jgen.writeStringField("enumClass", enumClass)
[error]          ^
[error] /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/ser/EnumerationSerializerModule.scala:31:10: value writeStringField is not a member of com.fasterxml.jackson.core.JsonGenerator
[error]     jgen.writeStringField("value", value.toString)
[error]          ^
[error] /Users/pj.fanning/code/jackson-module-scala/src/main/scala/com/fasterxml/jackson/module/scala/ser/TupleSerializerModule.scala:15:40: value writeObject is not a member of com.fasterxml.jackson.core.JsonGenerator
[error] did you mean writeObjectId?
[error]     value.productIterator.foreach(jgen.writeObject _)
[error]                                        ^
[error] 5 errors found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 77 s (01:17), completed 26-Jan-2021 12:12:37

@cowtowncoder
Copy link
Member Author

@pjfanning Thanks, apologies for lag in fixing these -- I hope to be done with streaming-level changes soon.

Fixes for these are:

  • writeFieldName() -> writeName() (big effort to remove refs to "field"; in most cases becomes "property" if not eliminated like here)
  • nextFieldName() -> nextName() similarly
  • writeXxxField() -> writeXxxProperty() (writeStringProperty()) here
  • writeObject() -> writePOJO() (since "Object" elsewhere refers to JSON Object type, but writeObject() is to serialize Java Objects (aka POJOs).

@pjfanning
Copy link
Member

closing in favour if #431 - builds are passing (although a few tests that work in jackson 2 have been disabled for a while)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Something that likely has to be done in 3.x, not 2.x
Projects
None yet
Development

No branches or pull requests

2 participants