Tomcat sucks... Is Apache flawed?

High on my list of Java blogs is Hani Suleiman’s The BileBlog, in which he gives unapologetically abrasive reviews of popular Java projects and the people behind them. In the past, he has had been less than complimentary of the Apache Project‘s various open source (“opensores”) Java offerings like Maven and Struts. Today, he took Tomcat to task.

Tomcat, of course, provides the reference implementations for the Servlet and JSP specifications, but by virtue of the fact that it is free, it’s also the server of choice for many small-to-medium businesses. I took a critical look at Tomcat myself awhile back, while looking for a beginner-friendly Java web application server (I’m still looking).

Suleiman’s critique of Tomcat is based, somewhat refreshingly (he often resorts to unpersuasive, if entertaining, personal attacks on the developers), on the quality of the project’s code–or rather its lack thereof. Choosing a pivotal but relatively uncomplicated class (DefaultServlet, which is responsible for serving static resources like HTML/CSS/JavaScript files and images), he points out many examples of terrible coding practice, of which these are only a sampling:

Initialization code that lazily catches Throwable
        // Set our properties from the initialization parameters         String value = null;         try {             value = getServletConfig().getInitParameter("debug");             debug = Integer.parseInt(value);         } catch (Throwable t) {             ;         }         try {             value = getServletConfig().getInitParameter("input");             input = Integer.parseInt(value);         } catch (Throwable t) {             ;         }
Throwable is the base interface for all Java exceptions an errors, many of which have no business being caught by this sort of code, let alone being ignored as this code will do. If the server happens to run out of memory while initializing a DefaultServlet, for example, this code will ignore the resulting error and attempt to continue running.
Attempts to identify particular exceptions by portions of their message strings
        try {             serveResource(request, response, true);         } catch( IOException ex ) {             // we probably have this check somewhere else too.             if( ex.getMessage() != null                 && ex.getMessage().indexOf("Broken pipe") >= 0 ) {                 // ignore it.             }             throw ex;         }

Fortunately, the if statement in question (which, from the comment, it seems the developer was rather uncertain about) doesn't actually cause the exceptions it identifies to be ignored (as the second comment says it should do), so this confusing twist of poor programming is actually useless anyway.

A method that returns an exception instead of throwing it
    protected IOException copyRange(InputStream istream,                                   ServletOutputStream ostream) {          // Copy the input stream to the output stream         IOException exception = null;         ...             try {                 ...             } catch (IOException e) {                 exception = e;                 ...             }         ...         return exception;      }

As a believer in open source development, I looked at every issue he pointed out to give it the benefit of the doubt. "Okay, it looks silly, but there must be a good reason that they did that." There wasn't, of course, unless you consider laziness or ignorance a good reason.

For a project produced under the public scrutiny of the open source development, these are disturbingly fundamental issues indeed. For me, the most important question becomes not whether or not Tomcat sucks, but whether this level of code quality is the exception or the norm in the Apache camp.

I know for a fact that there is plenty of good quality open source Java code in the wild. I've probed into the code of Jetty a number of times, for instance, and have been pleasantly surprised by what I found there. I also know that poor open source code isn't just a problem that faced by Java. But Apache is supposed to be a leader in the field.

If the repeated condemnations of The BileBlog are any indication, the majority of the web could be running software like this--code that looks like it was written in a desperate push to meet a deadline with something that works... most of the time... just barely.


Category: java Time: 2006-04-21 Views: 3

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.171 (s). 12 q(s)