Monday, May 16, 2011

My small contribution to RESTEasy project

I am working on some example to play with Infinispan and in this example, I wanted to store a YAML blob in the cache and play with Infinispan's different cache configuration options. To consume a YAML blob, I developed a REST interface using RESTEasy. RESTEasy's YAML provider worked pretty well but for the case when blob did not comply with YAML syntax. As expected, it would throw error but error message was far from helpful:


Caused by: java.lang.NullPointerException
at org.ho.yaml.JYamlParserEvent.getBean(Unknown Source)
at org.ho.yaml.YamlDecoder.readObject(Unknown Source)
at org.ho.yaml.YamlConfig.load(Unknown Source)
at org.ho.yaml.YamlConfig.load(Unknown Source)
at org.ho.yaml.Yaml.load(Unknown Source)

As of 2.0.1 RESTEasy version, YAML support was provided using JYAML which is not under development anymore. So I gave a shot at integrating SnakeYaml which is a very active project with good community around it. It was not a whole lot of work and it did not cause any regression in my local testing so I went ahead and committed to trunk after discussing with Bill. Thanks Bill. More details are at https://issues.jboss.org/browse/RESTEASY-543 . I updated the RESTEasy's doc as well..isn't that nice? ;-)

Tuesday, May 10, 2011

Tips when using curl to do an HTTP POST !

I have been playing with RestEasy stuff a bit lately and to test my RESTful webservices, I was using curl to do a HTTP GET and POST. To add to the fun, I wanted to use a YAML file as POST payload. I will talk about YAML and RestEasy in a separate blog post, but when you do a POST as


curl -X POST -d @/home/prabhat/house.yaml -H "Content-type: text/x-yaml" http://localhost:8080/eejot-rest/rest/houses


curl strips all newline which is what a browser does. YAML depends on new line and white spaces so that would result into all sort of deserialization issues on server side. The correct way to do instead is


curl -X POST --data-binary @/home/prabhat/payload.yaml -H "Content-type: text/x-yaml" http://localhost:8080/eejot-rest/rest/houses

Curl man page is very clear on this but sometimes we tend to have false assumption. RTFM Prabhat!

Tuesday, May 3, 2011

How to delete a svn repo and recover it

I woke up this morning and before I had my coffee, I did something like following:

svn delete .
svn commit -m "some clean up"

As I said I did this before I had my coffee. ;-) But why would I do such thing? SVN showed M for . because I was playing with some svnignore stuff. The above command completely wiped out the branch I was working on. When I realized what I did, I did not need coffee anymore.

After little googling, I did following

svn cp -m "restore.." https://eejot.org/branches/my-branch@110 https://eejot.org/branches/my-branch

where 110 is x-1 with x being the revision number which nuked the branch I was working on.