Author's posts

I write here now

The posts I write for the tech blog at work are all here:

Ubuntu clone with git ‘hung up unexpectedly’ problem solved

I was experiencing a very strange issue where I was unable to clone or pull from some repositories on github. It would only be for some (larger) respositories, and I could sometimes pull them fine using the https:// protocol, but not using the git:// or ssh:// protocols.

What I would see in the output, is that git would contact the remote server, and just hang for several minutes, before giving, rather cryptically, the 'remote end hung up unexpectedly' message. Doing a ‘git pull’ on an existing repo would give me 'error: RPC failed; result=56, HTTP code = 0'

I could clone the same repos fine on my OSX workstation, and on other Ubuntu linux boxes, so something weird was definitely up.

I suspected it was some sort of low-level networking issue, and after trying many things, came upon the solution:

My MTU size was set to ‘automatic’, and had defaulted to 1500. Apparently this can sometimes cause TCP connections to hang in some network environments!

I set my MTU size to 1492 on my network adapter (Under Edit Connections… in the UI) and everything started to work as expected! Huzzah.


Brew: the future of package management on OSX? Hope not.

Warning: This might come off a little ranty.

You know, it might just be that some people need to install older-than-the-bleeding edge versions of software. Some of us have stable production systems, that for whatever reason, don’t always run the latest, nightly-build-sure-it’ll-be-fine-no-really versions of everything.

Turns out to to this using “brew”, you have to go through some quite odd contortions

  1. Install brew (would assume you’ve already done this at least)
  2. brew update (this makes sure you have the /usr/local/.git directory)
  3. brew versions rabbitmq (I’m looking for 1.7.2 of RabbitMQ in this case)
  4. Copy down the git commit hash of the version I want.
  5. git checkout -b temp_branch $GITHASH
  6. brew install rabbitmq
  7. git checkout master
  8. git branch -d temp_branch

Clearly something like ‘brew install rabbitmq –version=1.7.2′ is far too difficult.

Also, what the hell is with brew littering the root of /usr/local with it’s junk? Is there something wrong with something clean like /usr/local/brew?


Modern Java

While it’s something I’ve been intending to do for quite a while now, I’ve finally managed to actually start using the Guava Libraries. This is a superset project which includes the Google Collections libraries, which are a huge improvement over the traditional J2SE Collections API.

It allows for very quick construction of collections objects: e.g.

final List empty = Lists.newArrayList();
final List populated = Lists.newArrayList("a", "b", "c");
final Map<Integer,MyThing> myMap = ImmutableMap.of(1, object1, 2, object2, 3, object3);

How about functions on lists?

final List spamList = Lists.transform(customers, new Function<Customer,EmailAddress>() {
    public EmailAddress apply(final Customer customer) {
         return customer.getEmail();

There is also a whole lot of other good stuff included, for I/O, Primitives utilities, String manipulation, Networking and concurrency.

Here is a link to some good resources.

Also, I just wanted to link to this article on JSR-310, which is the API that has arisen out of the very excellent Joda Date/Time library, which I endorse and use very heavily.


Recovering lost IntelliJ IDEA shelved changesets

Imagine the following scenario:

  • You are moving your beloved project out from a subdirectory of an svn repository, into it’s own brand spanking new repository.
  • You have about 3 days worth of large refactorings to the codebase waiting in the wings, with most of the tests passing, but not quite ready for commit to the trunk
  • You use IDEA’s shelve feature to put those changes into safe keeping, so you can make changes and commits to the repository in preparation for the move
  • You manage to successfully migrate the svn repository across, managing to keep all the history (yay)
  • You then open the new (and renamed) project in IDEA, and all of your shelved changes are gone


Luckily, IDEA never deletes any of the shelved changesets, and conveniently stores them in unified .diff format in $USERDIR$.IntelliJIdea80configshelf

Also, conveniently, there’s the ‘Version Control -> Apply Patch’ menu item, so you don’t have to worry about mucking about with the *nix patch command line tool.

Day saved. Hurrah!

** Perhaps this sort of thing is a good argument for using a Distributed VCS system, like git or mercurial or monotone et al. You would normally be doing lots of small commits to your local repository, without necessarily worrying about breaking trunk for everybody, and your changes stay safe

Selenium testing RichFaces comboBox controls

Ok, so I’ve spent the last day and a half chasing down a really weird bug I was seeing with our Selenium integration tests.

Basically, we had a RichFaces rich:comboBox component – which gives you a thing that looks like a drop down combo box, but also allows you to type free-form text into it. It does fancy things like auto-completion, etc.

What I had was an ajaxValidator that would trigger when the “onblur” event was fired at the component. This was working fine when I’d try it manually, i.e. I could type something into the field, hit tab (or click away from the field or whatever), and the validation would update, showing that the field now had a value (instead of complaining about not having one).

However, when I tested it using Selenium, using selenium.type() I could see the input appear in the text box, but the validation message would never go away.

Something with the event system in the combo box is way messed up, and you should test it using something like:

selenium.typeKeys( your_elementcomboboxField, "Some text" );
selenium.fireEvent( your_elementcomboboxField, "blur" );

This simulates a user actually typing each letter in, like a human would do, rather than just setting the field value. You then fire the onblur event, so simulate the user leaving the field.