Bug 55675 - Checking and handling invalid configuration option values
Summary: Checking and handling invalid configuration option values
Status: NEW
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.x-trunk
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-18 22:00 UTC by Sai Zhang
Modified: 2023-07-10 19:28 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sai Zhang 2013-10-18 22:00:53 UTC
Hi all,

I was using Tomcat for a while, but found Tomcat sometimes does not handle misconfiguration well, which causes unnecessary confusion. 

Specifically, when users provide a wrong configuration option and Tomcat produces a wrong result (or crashes), Tomcat should explicitly dump error message pointing to the mis-configured option, rather than just dumping stack traces, or simply restoring to the default behavior. At least, the invalid configuration values should be logged. 

Strictly speaking, this may not be a bug, but (I think) it is definitely worth improving to give better user experience. I have found many places in Tomcat. Here is a very simple case for illustration purpose (I have more complex examples, which I can post if they are of general interest):

In McastService.java

public long getDropTime() {
        String p = properties.getProperty("memberDropTime");
        return new Long(p).longValue();
}

If a careless user uses "1o" (not 0) as the value of configuration option: "memberDropTime", Tomcat will throw an exception when parsing this string. Similar cases occur to me a few times; often, the effect of a misconfigured option propagates through the program and causes some *delayed* problem, making it even harder to localize the original misconfigured option.

I would suggest to add timely check immediate after reading a configuration option value. For the above case, check whether p is a long value or not, and also checking its permitted ranges. (yes, many places in Tomcat do this, but still many places like the above case miss the checking). I would like Tomcat to explicitly warn the user (or at least log) which option is misconfigured rather than delaying the effect until the program crashes.

I found a couple of such places. and wondering whether Tomcat developers would like to know them, and how do you think about such "mis-handling"? 

Thanks 

-Sai
Comment 1 Mark Thomas 2013-10-19 09:32:13 UTC
Improving handling of invalid configuration is an enhancement rather than a bug.

The configuration style used in McastService is not one widely used in Tomcat although I suspect it may be used elsewhere in the org.apache.catalina.tribes package.

I'd be happy to see the properties field removed and replaced with standard getters and setters with appropriate defaults. If necessary (I'm not sure it is) , those defaults can be invalid and the implementation can check that they have been set to valid values at an appropriate point.

As always, patches welcome.

Note that changes like this that modify the API are less likely to be back-ported to earlier versions of Tomcat.