Skip to content

Commit f221f24

Browse files
committed
Improve error message and formatting
1 parent feca2f7 commit f221f24

File tree

5 files changed

+33
-26
lines changed

5 files changed

+33
-26
lines changed

java/org/apache/catalina/startup/Catalina.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,10 @@ protected Digester createStartDigester() {
474474

475475
digester.addObjectCreate("Server/Service/Connector/OutputFilterFactory", null, "className");
476476
digester.addSetProperties("Server/Service/Connector/OutputFilterFactory");
477-
digester.addSetNext("Server/Service/Connector/OutputFilterFactory", "addOutputFilterFactory", "org.apache.coyote.http11.filters.OutputFilterFactory");
477+
digester.addSetNext(
478+
"Server/Service/Connector/OutputFilterFactory",
479+
"addOutputFilterFactory",
480+
"org.apache.coyote.http11.filters.OutputFilterFactory");
478481

479482
// Add RuleSets for nested elements
480483
digester.addRuleSet(new NamingRuleSet("Server/GlobalNamingResources/"));

java/org/apache/coyote/CompressionConfig.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ private OutputFilterFactory negotiateTE(List<OutputFilterFactory> factories, Lis
386386
/**
387387
* Negotiate the best encoding from Accept-Encoding entries against available factories.
388388
*/
389-
private OutputFilterFactory negotiateAcceptEncoding(List<OutputFilterFactory> factories, List<AcceptEncoding> acceptEncodings) {
389+
private OutputFilterFactory negotiateAcceptEncoding(
390+
List<OutputFilterFactory> factories,
391+
List<AcceptEncoding> acceptEncodings) {
390392
OutputFilterFactory bestFactory = null;
391393
double bestQuality = 0;
392394
int bestServerPriority = Integer.MAX_VALUE;

java/org/apache/coyote/http11/filters/GzipOutputFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ public void setLevel(int level) {
169169
*/
170170
public void setBufferSize(int bufferSize) {
171171
if (bufferSize <= 0) {
172-
throw new IllegalArgumentException(sm.getString("gzipOutputFilter.invalidBufferSize", Integer.valueOf(bufferSize)));
172+
throw new IllegalArgumentException(
173+
sm.getString("gzipOutputFilter.invalidBufferSize", Integer.valueOf(bufferSize)));
173174
}
174175
this.bufferSize = bufferSize;
175176
}

java/org/apache/coyote/http11/filters/LocalStrings.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ gzipOutputFilter.flushFail=Ignored exception while flushing gzip filter
3333
gzipOutputFilter.invalidLevel=The gzip compression level [{0}] is not valid. Valid values are -1 (default) or 1-9.
3434
gzipOutputFilter.invalidBufferSize=The gzip buffer size [{0}] is not valid. Must be a positive integer.
3535

36+
# Factory messages (mirror gzipOutputFilter messages for factory-level validation)
37+
gzipOutputFilterFactory.invalidLevel=The gzip compression level [{0}] is not valid. Valid values are -1 (default) or 1-9.
38+
gzipOutputFilterFactory.invalidBufferSize=The gzip buffer size [{0}] is not valid. Must be a positive integer.
39+
3640
inputFilter.maxSwallow=maxSwallowSize exceeded

webapps/docs/config/http.xml

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@
423423
compression may be used.
424424
The default value is
425425
<code>
426-
text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json,application/xml
426+
text/html,text/xml,text/plain,text/css,
427+
text/javascript,application/javascript,application/json,application/xml
427428
</code>.
428429
If you specify a type explicitly, the default is over-ridden.</p>
429430
</attribute>
@@ -459,33 +460,29 @@
459460
Units are in bytes.</p>
460461
</attribute>
461462

462-
<attribute name="gzipLevel" required="false">
463-
<p>If <strong>compression</strong> is set to "on" or "force" then this
464-
attribute may be used to configure the compression level for gzip
465-
compression. Valid values are <code>-1</code> (default compression)
466-
or <code>1</code> through <code>9</code> where <code>1</code> gives
467-
beset speed and <code>9</code> gives best compression ratio. If not
468-
specified, this attribute defaults to <code>-1</code> (JDK default compression).</p>
469-
</attribute>
470-
471-
<attribute name="gzipBufferSize" required="false">
472-
<p>If <strong>compression</strong> is set to "on" or "force" then this
473-
attribute may be used to configure the internal buffer size (in bytes)
474-
for the gzip compression stream. Larger buffers can improve compression
475-
ratios and throughput for bulk responses, while smaller buffers reduce
476-
latency for streaming scenarios. If not specified, this attribute
477-
defaults to <code>512</code> bytes. </p>
478-
</attribute>
479-
480-
<attribute name="noCompressionEncodings" requried="false">
463+
<p>Advanced gzip settings such as compression level and internal buffer
464+
size are configured via a nested
465+
<code>&lt;OutputFilterFactory&gt;</code> element inside the
466+
<code>&lt;Connector&gt;</code>
467+
when <strong>compression</strong> is enabled.</p>
468+
<pre>
469+
&lt;Connector ... compression="on"&gt;
470+
&lt;OutputFilterFactory
471+
className="org.apache.coyote.http11.filters.GzipOutputFilterFactory"
472+
level="-1"
473+
bufferSize="512"/&gt;
474+
&lt;/Connector&gt;
475+
</pre>
476+
477+
<attribute name="noCompressionEncodings" required="false">
481478
<p>A comma-separated list of content encodings that indicate
482479
already-compressed content. When the response already has a
483480
<code>Content-Encoding</code> header with one of these values, compression
484481
will not be applied to prevent double compression. This attribute is only
485482
used if <strong>compression</strong> is set to <code>on</code> or
486483
<code>force</code>.</p>
487484
<p>If not specified, the default values is
488-
<code>br,compress,dcb,dcz,deflate,gzip,pack2000-gzip,zstd</code>, which
485+
<code>br,compress,dcb,dcz,deflate,gzip,pack200-gzip,zstd</code>, which
489486
includes all commonly used compression algorithms. This can be customized
490487
to support custom compression algorithms when using a custom
491488
<code>outputFilterFactory</code>.</p>
@@ -683,15 +680,15 @@
683680
used.</p>
684681
</attribute>
685682

686-
<attribute name="noCompressionEncodings" requried="false">
683+
<attribute name="noCompressionEncodings" required="false">
687684
<p>A comma-separated list of content encodings that indicate
688685
already-compressed content. When the response already has a
689686
<code>Content-Encoding</code> header with one of these values, compression
690687
will not be applied to prevent double compression. This attribute is only
691688
used if <strong>compression</strong> is set to <code>on</code> or
692689
<code>force</code>.</p>
693690
<p>If not specified, the default values is
694-
<code>br,compress,dcb,dcz,deflate,gzip,pack2000-gzip,zstd</code>, which
691+
<code>br,compress,dcb,dcz,deflate,gzip,pack200-gzip,zstd</code>, which
695692
includes all commonly used compression algorithms.</p>
696693
</attribute>
697694

0 commit comments

Comments
 (0)