Hi,

I just want to share our (somewhat painful) migration experiences here. I 
think it could be useful for the other people as there seems to be a lack 
of documentation about migration. It's mostly the other technologies 
dropwizard depends on and some of them are rather obvious and normal to not 
mention.

Jackson:
- In order to ignore certain fields, we were using *AnnotationIntrospector 
*feature 
by overriding "*hasIgnoreMarker*" method. That stopped working for some 
reason. Having not able to find the cause, and not wanting to spend too 
much time, we have decided to use *FilterProvider *feature instead.
- No need for extra java8 modules anymore. They are already included.
- Jackson has a new feature which treats @
*javax.beans.ConstructorProperties* as *@JsonCreator *(
https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.7). We use 
lombok, and have a lot of *@AllArgsConstructor*s for the json objects. 
Turns out, this annotation also adds @*javax.beans.ConstructorProperties *to 
the constructor. This makes Jackson to use that constructor instead of the 
empty one. This leads to setting nulls to non-existing fields even though 
we have *JsonInclude.Include.NON_ABSENT*. Thus, our default values were 
ignored.
I've decided to fix this by creating a lombok.config file and adding '
lombok.anyConstructor.suppressConstructorProperties = true' to it.
I've found another solution, but I didn't know what might be the side 
effect as it may be overriding the existing introspector: 
objectMapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector().
setConstructorPropertiesImpliesCreator(false));


Validation:
- No more *OptionalValidatedValueUnwrapper* needed.
- As *@Validated* used to be enough previously, we didn't follow the 
documentation and just kept *@Validated* on the parameters. This is not 
enough anymore, both *@Valid* and *@Validated* is required to have 
validation, if you need grouping.
https://github.com/dropwizard/dropwizard/pull/1251#issuecomment-142645734
- We have our own *ConstraintViolationException *mapper to be able to 
provide custom error objects which includes a "field" field which gives the 
field path. *c**onstraintViolation.getPropertyPath() *used to return the 
direct path of the field, like *childObject[1].field*. And 
*constraintViolation.getRootBeanClass() 
*used to return the json object. We do some reflection and annotation 
processing in order to get the *@JsonProperty("fieldName") *correctly on 
this json object. Now *propertyPath* is something like 
*post.args1.childObject[1].field* and *rootBeanClass* is the resource 
class. This needed considerable changes in order to continue to work as 
before.
- *@ValidationMethod *is now called even when when the regular validation 
fails.* B*efore, if, say, *@NotNull* fails, validation methods were not 
evaluated. So we didn't have '*if(null) return true' *in those methods before. 
With dropwizard 1.0.0 they started throwing null pointer exception and 
returning 500. Adding null checks fixed it of course.


Logging:
- We were using a 3rd party code that overrides "*AbstractAppenderFactory*". 
The signature has changed and broke the compatibility. We've done the 
necessary changes.

Configuration:
- In order to have a HTTPs server with a self-signed certificate, one 
needed to have *validateCerts: false* in the configuration yaml. Now this 
isn't enough. Now one also needs *validatePeers: false*.
- Jersey client gets 'Connection Reset' errors. Explained here: 
https://groups.google.com/forum/#!topic/dropwizard-user/gEwrTwRZez0. I've 
made it work with enabling *retries *on the configuration but would prefer 
to understand why it's failing in the first place. Which doesn't work out 
of box. You also need *chunkedEncodingEnabled: false *for it to work*.*
- https://github.com/tkrille/dropwizard-environment-config  
<https://github.com/tkrille/dropwizard-environment-config>is not compatible 
anymore. We have moved to 
https://github.com/tkrille/dropwizard-template-config. Which was already 
recommended apparently but we haven't been following the repository.

Feel free to add more of your experiences here so this can become some sort 
of documentation. Also corrections are obviously welcome.

Natan

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to