Does the Liskov Substitution Principle apply to blocking behaviour?

In page 72 of Release It! Michael Nygard says:

In Java, it is possible for a subclass to declare a method synchronized that is un-synchronized in its superclass or interface definition. Object-oriented purists will tell you that this violates the Liskov Substitution principle. They are correct.

What contract is being broken here? Just because a method call does not have synchronized on it does not mean it will not block. If that method call does any IO, database access, logging or even reading configuration it will need to synchronize. Since java makes no guarantee that any method call will execute in finite time, there is no contact to be broken. In fact the Java license explicitly forbids use of java in realtime systems. And only realtime programming languages put upper bounds on the time taken by a given operation.

Turning it around it would be nice at have a way of annotating a method in java to say that it is a pure function. Such a method would only do computation on its inputs and would not do any IO or access shared state. Of course it should be able to call other pure functions. That would be a nice development feature to have, and it would be a contract one would apply the Liskov Substitution principle to.

Having defined and proved a given method is a pure function, the JVM cannot guarantee that it
won’t block. The thread could be suspended indefinitely by the operating system scheduler, or a memory access can stall or even require a memory page to be read from a distant slow disk.

To my mind it makes sense include the general blocking behavior of a class in it’s contract, but that’s not the same as saying that introducing synchronized is breaking the contract.

Getting Hudson to work with SVN on Apache and mod_sspi

If you’ve got Subversion running in Apache httpd on Windows, you might well have installed mod_auth_sspi to get single signon. I’d definitely recommend it, but it does have it’s down sides. In this particular case, I just couldn’t get hudson to authenticate even though I was sure I was giving the right username and password.

It turns out that hudson uses svnkit, and svnkit has some trouble with Negotiate (sspi) authentication, so you need to force it to use Basic or NTLM authentication instead. This can be done with a system property: -Dsvnkit.http.methods=Basic,NTLM

Now if you are running hudson as a service and need to set this property, you need to put it in hudson.xml, like so:

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dsvnkit.http.methods=Basic,NTLM -jar "%BASE%\hudson.war" --httpPort=8180 --ajp13Port=8109</arguments>

I actually solved this problem twice about 6 months apart. The second time I knew I had seen the answer before, but couldn’t easily find it by searching the web, so I’m documenting so I can find it again next time I get this problem.  Unhelpfully, this hudson wiki page on sspi doesn’t cover this issue! There is some more info about setting the href=”,-authentication-cancelled-message-td26370248.html”>svnkit.http.methods property in this thread.

If this helped you, please give feedback.

Clearcase to Subversion migration script

Your corporate overlords want you to use Cleacase?  Your team want to use Subversion (SVN)?  Then you need my handy Clearcase to Subversion migration script.  This script is based on Clearcase UCM, but can easily be adapted to run on base clearcase.  We ran it from inside our builder server, and set the build script to run 5 mins after a checkin to SVN.

@echo off
REM DRYRUN=-preview
set CC_VIEW=Z:
set SVN_BASE=http://hostnname/repo/svn/trunk

echo Reading current head revision
svn info %SVN_BASE% | grep "Last Changed Rev" >curver.txt

echo Parsing latest SVN version
FOR /F "tokens=4" %%i in (curver.txt) do set REV=%%i

set EXPORT_DIR=export-%REV%
set DIFF_FILE=%CD%\diff-report.txt

echo Current dir is      : %CD%
echo Export dir is       : %EXPORT_DIR%
echo Export dir full is  : %EXPORT_DIR_FULL%

echo Exporting SVN revision %REV% to %EXPORT_DIR%
svn export --force -r %REV%  %SVN_BASE% %EXPORT_DIR%

rem check that the export worked ok, and abort is there were problems

echo Making clearcase activity
cd /d %CC_VIEW%\path\src\
cleartool mkact -in stream:STREAM@\PROJ migrate_svn_%REV%@%PVOB%
cleartool setact migrate_svn_%REV%

echo Executing clearfsimport
clearfsimport -recurse -rmname -nsetevent %DRYRUN% %EXPORT_DIR_FULL%\*

rem check that the export worked ok, and abort is there were problems

echo Checking for differences

echo Creating ClearCase baseline
call C:/apps/Python24/python.exe

echo Cleaning up
rmdir /s/q %EXPORT_DIR_FULL%

echo Migration Finished
goto END

echo Migration Failed, problem with svn export
goto END

echo Migration Failed, problem with clearfsimport
goto END


The echo at the end is important, as you can use it to detect errors. We used Luntbuild as a build server, but cruise control would work fine too, and ran the script from within the build server. We set Lunbuild up to look for ‘Migration Finished’, if it didn’t get output, then I’d get an email informing me of the problem. Failures we usually due to the ‘evil twin‘ trigger in ClearCase rejecting the commit. If this happened I had to fix it up manually before re-runnning the script. ⓓ

Keeping your options open

Recently, on a project, I’ve been learning about Lean, Real Options and Kanban.  On the project we used these principles to guide how we architected our release process so we could be ready to release at any time (mostly) without branching.  We did it mainly by being able to use config to turn features on and off, and aiming for backwards compatibliy.   That way if you deploy a new version, but don’t turn on the new features, it works exactly like the old version.  This means multiple features can be developed in parallel, and a release can be made when any one of them is ready.

Chris Matts my old project manager started a thread on the kanbandev mailing list asking if other people used similar techniques:

One of the most powerful techniques I have used over the last three years is latent code patterns. The project I just left made every feature configurable. This meant that we never had the situation where a fix / feature had to wait for another feature in testing. We focused on fast and effective regression testing. Despite frequent diva releases we only ever had a single branch and had no code merging issues as a result.
Is anyone else using latent code patterns? I would like to hear how others do it as the best lnnovation comes from practitioners with a problem.
The other issue that lcp raise is the wip limit around testing. Thoughts?

I’m not scared of SCM branches and merging, I can merge with the best of them.  Inspired by Chris’s demand to defer commitments, I made a conscious decision to avoid all branching unless absolutely necessary.  At the beginning it was an experiment, encouraged by the cost of branching.  The cost of merging, resolving conflicts, tracking which bugs are fixed where etc all add up.  That time and energy can be better spent finding a solution whereby we can make decisions as late as possible.  We wanted to able able to sense ambiguity in the requirements and code it up both ways, make it easy to change our minds.  Reduce the cost of change.

From the responses it seems some of the ideas we’ve been using are in use by others.  Some mentioned using dependency injection, but it’s not clear that others were affecting dependency injection at runtime like we are.  Others mentioned the command pattern, and it did indeed sound similar to our approach.

The thread was also summaried in the InfoQ post Enabling the Last Responsible Moment in Deployment which I think is a fairly good summary.

Next I will cover the techniques we use in more detail.

A new blog is born

This is my new technically-themed blog.  I intend to write a post posts occasionally about my technical interests in software, programming and related bits.

I’m hoping to put together some posts about setting up a development environment for a small team using SVN, Trac, Apache, ActiveDirectory, Maven and CruiseControl.  I might do some posts on XML, both thery and practice.  And then whatever subjects take my fancy.

So do check back soon.  In fact why not subscribe to the blog feed and let my blog posts come to you.