Bug 60852

Summary: Connector property compressableMimeType incorrectly spelled
Product: Tomcat 9 Reporter: Michael Osipov <michaelo>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 9.0.0.M17   
Target Milestone: -----   
Hardware: All   
OS: All   
Attachments: Trivial patch for Tomcat 9

Description Michael Osipov 2017-03-13 13:33:54 UTC
The word "compressable" does not exist according to Merriam Webster or the Oxford Dictionary. It seems simply to be a typo:

> $ grep -ri --exclude-dir=.svn compressable .
> ./java/org/apache/coyote/http11/AbstractHttp11Protocol.java:    private String compressableMimeType = "text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json,application/xml";
> ./java/org/apache/coyote/http11/AbstractHttp11Protocol.java:    private String[] compressableMimeTypes = null;
> ./java/org/apache/coyote/http11/AbstractHttp11Protocol.java:    public String getCompressableMimeType() { return compressableMimeType; }
> ./java/org/apache/coyote/http11/AbstractHttp11Protocol.java:    public void setCompressableMimeType(String valueS) {
> ./java/org/apache/coyote/http11/AbstractHttp11Protocol.java:        compressableMimeType = valueS;
> ./java/org/apache/coyote/http11/AbstractHttp11Protocol.java:        compressableMimeTypes = null;
> ./java/org/apache/coyote/http11/AbstractHttp11Protocol.java:    public String[] getCompressableMimeTypes() {
> ./java/org/apache/coyote/http11/AbstractHttp11Protocol.java:        String[] result = compressableMimeTypes;
> ./java/org/apache/coyote/http11/AbstractHttp11Protocol.java:        StringTokenizer tokens = new StringTokenizer(compressableMimeType, ",");
> ./java/org/apache/coyote/http11/AbstractHttp11Protocol.java:        compressableMimeTypes = result;
> ./java/org/apache/coyote/http11/AbstractHttp11Protocol.java:        processor.setCompressableMimeTypes(getCompressableMimeTypes());
> ./java/org/apache/coyote/http11/Http11Processor.java:    protected String[] compressableMimeTypes;
> ./java/org/apache/coyote/http11/Http11Processor.java:     * @param compressableMimeTypes MIME types for which compression should be
> ./java/org/apache/coyote/http11/Http11Processor.java:    public void setCompressableMimeTypes(String[] compressableMimeTypes) {
> ./java/org/apache/coyote/http11/Http11Processor.java:        this.compressableMimeTypes = compressableMimeTypes;
> ./java/org/apache/coyote/http11/Http11Processor.java:    private boolean isCompressable() {
> ./java/org/apache/coyote/http11/Http11Processor.java:            if (compressableMimeTypes != null) {
> ./java/org/apache/coyote/http11/Http11Processor.java:                return (startsWithStringArray(compressableMimeTypes,
> ./java/org/apache/coyote/http11/Http11Processor.java:        boolean isCompressable = false;
> ./java/org/apache/coyote/http11/Http11Processor.java:            isCompressable = isCompressable();
> ./java/org/apache/coyote/http11/Http11Processor.java:            if (isCompressable) {
> ./java/org/apache/coyote/http11/Http11Processor.java:        if (isCompressable) {
> ./webapps/docs/config/http.xml:    <attribute name="compressableMimeType" required="false">

A fix is fairly easy, but would require an incompatible change. This is possible in Tomcat 9 only. For Tomcat 8.5.x one could introduce new methods (getter, setter) calling old ones, mark as @Deprecated and change http.xml for the new one only. Old config should continue to run as expected.
Comment 1 Michael Osipov 2017-03-13 13:36:08 UTC
The correct term is "compressible", a => i
Comment 2 Christopher Schultz 2017-03-13 19:06:23 UTC
This can be done in a backward-compatible way. It's just an alias of an existing setting (or, rather, re-naming an existing setting and then creating an alias with the old name).

Would you care to submit a patch?
Comment 3 Michael Osipov 2017-03-13 19:49:44 UTC
(In reply to Christopher Schultz from comment #2)
> This can be done in a backward-compatible way. It's just an alias of an
> existing setting (or, rather, re-naming an existing setting and then
> creating an alias with the old name).
> 
> Would you care to submit a patch?

Yes, of course. I will start with Tomcat 9 first. Do you want me to simply break code in 9? I think this is OK since it is not GA yet.
When this is done, I will work in 8.5.

Can someone merge 60851 first? Both patches would cause a conflict.
Comment 4 Konstantin Kolinko 2017-03-15 08:50:50 UTC
1. Do both American English and British English consider this a typo?

Wictionary has this spelling listed,
https://en.wiktionary.org/wiki/compressable


2. I think it would be better to have a regular expression instead of a list.
To cover foo+xml, foo+json  mime types.

See bug 60851 and see <mime-type>s in the default conf/web.xml for examples?


3. Beware of BREACH.
https://en.wikipedia.org/wiki/BREACH_(security_exploit)
Comment 5 Michael Osipov 2017-03-15 10:41:00 UTC
(In reply to Konstantin Kolinko from comment #4)
> 1. Do both American English and British English consider this a typo?
> 
> Wictionary has this spelling listed,
> https://en.wiktionary.org/wiki/compressable

Strange, this isn't listed neither by Oxford, Merriam-Webster, nor Cambridge. I wouldn't take Wiktionary as a canonical reference for the English language.

What do native speakers say?
Comment 6 Mark Thomas 2017-03-15 12:58:06 UTC
This native speaker says "compressable" is a common misspelling of "compressible".
Comment 7 Christopher Schultz 2017-03-15 21:33:19 UTC
(In reply to Mark Thomas from comment #6)
> This native speaker says "compressable" is a common misspelling of
> "compressible".

+1

Tomcat is "able" to "compress" a file type, ergo "compressable". Of course, as I type that into my web browser, it kindly tells me it should be "compressible" (at least in US English).

Mistakes happen. Let's just make an alias and not mince around too much over a spelling issue.
Comment 8 Michael Osipov 2017-03-17 17:18:15 UTC
Created attachment 34841 [details]
Trivial patch for Tomcat 9

Here is a trivial patch for Tomcat 9. No backwards compat retained. I think this is OK for Tomcat 9, but not suited for 8.5.
Comment 9 Mark Thomas 2017-03-23 15:07:28 UTC
Thanks for the patch.

I applied a variation with deprecation to 9.0.x, back-ported all the way back to 7.0.x and removed the deprecated methods from 9.0.x.

Fixed in:
- trunk for 9.0.0.M19 onwards
- 8.5.x for 8.5.13 onwards
- 8.0.x for 8.0.43 onwards
- 7.0.x for 7.0.77 onwards