Checkout My GitHub! Adam Codez

Using Spring's CoreOAuthConsumerSupport on Google App Engine

Adam Duke | 07 April 2011

The Problem

After fixing CoreOAuthConsumerSupport and developing on the local Google App Engine environment I deployed my app to the production environment and promptly discovered a problem. It turns out that Spring's CoreOAuthConsumerSupport has dependencies on java.net.Proxy and java.net.ProxySelector, both which are restricted classes in the app engine environment. During my applications startup spring attempts to instantiate a singleton bean that I extended from CoreOAuthConsumerSupport, which causes an exception to be thrown regarding the restricted classes.

The Fix

In this case the fix is pretty easy because the CoreOAuthConsumerSupport class isn't highly dependent on the functionality of the restricted classes. In addition to using the getAuthorizationHeader method from my last post, I had to remove the proxySelector instance variable along with it's getter/setter, the selectProxy method, and modify the openConnection method not to call selectProxy. Instead of calling

it simply calls

instead.

The source for the fixed class is available on github at adamvduke/spring_ext