Amazon SDK broken dependencies

If you have received this error message:

java.lang.IllegalStateException: Unsupported cookie spec: default

It is because Amazon made their SDK dependency look like this:
+— com.amazonaws:aws-java-sdk
| +— org.apache.httpcomponents:httpclient:[4.1, 5.0) -> 4.4-beta1
| | +— org.apache.httpcomponents:httpcore:4.4-beta1

i.e. they made an open-ended statement that their SDK would work will all 4.x releases of httpclient.

As of 4.4-beta1, their statement became false. Somewhere down in the guts of httpclient, “default” is no longer a valid cookie specification, and now parts of the AWS SDK do not work.

See 2014/06/28/computer-science-hard-things/ ‎for a full essay on the problems with “dependency resolution”. In this case, Amazon just messed up – there is no way any particular aws-java-sdk release can claim compatibility with an entire 4.x line of the httpclient library.

The fix (at least in gradle; it should be similar in all build systems) is to exclude httpcomponents on the aws-java-sdk line, and then add a specific httpcomponents (e.g. 4.1 worked nicely for me, since presumably Amazon actually tested with that release before their release). Since Amazon was “fuzzy” about their actual dependency requirements, you may have to try 4.2, 4.3, etc. to make sure you get an actually-compatible-with-aws version of httpclient.

This entry was posted in Software Engineering. Bookmark the permalink.