Archive for December, 2007

svn: Base checksum mismatch

Today I had difficulties commiting a source file as I got this error

svn: Checksum mismatch for /path/to/SourceFile.javaexpected: [checksum],actual: [checksum]

The problem occurred after moving a package into a different source-folder, with the mentioned file as new file in it. If you’re experiencing the same problem, just stop trying to fix it “the nice way”. Rather follow this easy workaround that suggests checking out the folder where the file lies into a temp-directory, then override your existing folder in your project with the newly checked out one.
It’s quick and dirty but it’s gonna save you a load of time :-)


Capacity planning

Today, I discovered a nice little gotcha in the Spring source, namely in org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor, while I was implementing a priority task queue. The mentioned class uses a template method to create the backing queue for pending tasks:

protected BlockingQueue createQueue(int queueCapacity) {...}

I’ve overridden this method like so:

protected BlockingQueue createQueue(int queueCapacity) {
return new PriorityBlockingQueue(queueCapacity, new Comparator() {...});
}

However, this didn’t work as I got:

java.lang.OutOfMemoryError: Requested array size exceeds VM limit

Why? By default, the ThreadPoolTaskExecutor uses

new LinkedBlockingQueue(queueCapacity);

With a default queueCapacity of Integer.MAX_VALUE … This is ok, as the capacity of a LinkedBlockingQueue is its maximum capacity while the capacity of the PriorityBlockingQueue is its initial capacity (and used to create a array of the given size). Unfortunately, it isnt’t even possible to limit the size of PriorityBlockingQueue at all. Therefore, the parameter should be ignored for PriorityBlockingQueues.