wgx731's Technical Blog

Programmer @ National University Of Singapore.

Jackson & Export Problem

| Comments

I am working with Play! these days. So far I like the framework a lot, but I am not sure how is production performance for Play! yet. Anyway, this post is going to discuss about 2 issues I have encountered during my work.

The Jackson issue

As the title suggested, the first problem is related to Jackson, the default Json parsing library Play! is using. In my work, I am required to map some json to Java class, therefore I just create a standard Java class with the Jackson annotations. But it’s interesting when I am writing the unit test, because the behavior of the @JsonProperty annotation is not as what I think. There is a required Boolean configuration in annotation, and here is the documentation for it:

`public abstract boolean required`

Property that indicates whether a value (which may be explicit null) is expected for property during deserialization or not. If expected, BeanDeserialized should indicate this as a validity problem (usually by throwing an exception, but this may be sent via problem handlers that can try to rectify the problem, for example, by supplying a default value).

**Note that as of 2.0, this property is NOT used by BeanDeserializer: support is expected to be added for a later minor version.**

It seems the required field has no effect at all. At least, when I try a json without a required field, Jackson will just assign a default value for the field. And here are some github issues that supporting what I am seeing.

So if anyone have a solution for this, please kindly send me. :D

The export issue

This issue happens when I am playing around with Play! configuration files. It’s said that Play! configuration supports to get value from environment variables, so the usual way for me to setup a so called ‘environment variable’ is just put it in ~/.bashrc file. Here is how I set Play! variable in my ~/.bashrc:


But this approach doesn’t work for Play! configuration, and after a few try-and-error attempts, I have figured out that I am missing the export function. So I was wondering what is the export function doing here. And this post may give you more information about it. Basically, if you don’t export the environment variable, the process created from your current shell may not have access to it even you current shell can access it.

That’s all I have to share so far. Wish it helps for the ones who is facing same problem with me.

It’s been a long time since my last post. :P