An In-Memory CSS Compressor For django-pipeline

I recently discovered the convenience of the django-pipeline library when attempting to reduce the asset size of a Django project. Currently, this library only seems to support external CSS compressors, such as Yuglify and YUI. While I have no objection to these specific tools, I simply do not want to ...

Disable Artifact Archiving With Jenkins DSL

Out of the box, the Jenkins DSL project doesn't currently provide a way of disabling artifact archiving. For projects with large outputs built on slave nodes, this can cause dramatic slowdowns as gigabytes of data are sent back to the master. Luckily, the configure block can be used to ...

Freeing MappedByteBuffer

While investigating a production bug that indicated that the operating system of a server running only a JVM continually ran out of memory under a specific set of circumstances, I discovered a very interesting idiosyncrasy of the JVM. Specifically, memory allocated with mmap through the MappedByteBuffer (the super class of ...

Dropwizard IT Port Randomisation

Dropwizard's testing package includes a @ClassRule, DropwizardAppRule, that may be used to create end-to-end integration tests. However, you may rapidly discover that parallel test execution is severely impaired, as each test attempts to use the same application and admin ports as another. You can get around this by changing ...

Retain Your CDI Qualifiers

The CDI specifications is very clear in its definition of qualifiers:

A qualifier type is a Java annotation defined as @Target({METHOD, FIELD, PARAMETER, TYPE}) and @Retention(RUNTIME).

Of particular importance is the @Retention information: with the default retention, CLASS, a container's behaviour is undefined. I discovered this critical ...

Finally, Rollback Your Transaction

Lately, I've been working with code that exhibits a fairly poor practice: programmatic transactions (namely Spring) don't always get committed or rolled-back, even though the code appears correct. Consider the following contrived scenario:

void doWork(final PlatformTransactionManager txm)
{
    final TransactionStatus tx = txm.getTransaction(new DefaultTransactionDefinition());
    try {
        // do some ...

Enum Hash Codes Are Non-Deterministic

An annoying discovery: Java Enum objects have non-deterministic hash codes. Specifically, a hash code is the Enum's identity (or memory address).

public final int hashCode()
{
    return super.hashCode();
}

So, should you ever make the same mistake as me, keying a HashMap with an Enum, strongly consider using EnumMap, instead.

No ConcurrentHashSet? No Problem

The JDK provides several concurrent Set classes, each with their own application, but it does not provide a ConcurrentHashSet. Using the Collections utility class, however, such a structure may be created.

If you have ever looked at the source of java.util.HashSet, you will have noticed that it is ...

Using @cache_page With Django's Feeds

When returning a django.contrib.syndication.Feed from a view function, the @cache_page decorator does not seem to work as expected. Briefly inspecting the source of Feed explains why: Feed is not an HttpResponse. Truly, this isn't a bug: it's a documentation (if not comprehension) issue. Because the ...


1