Skip to content

Commit

Permalink
Fix a couple of minor FindBugs warnings
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc8.0.x/trunk@1804310 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Aug 7, 2017
1 parent 470cd7e commit fb804be
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,18 @@ public class CompressionFilter implements Filter {
/**
* Minimal reasonable threshold.
*/
private final int minThreshold = 128;
private static final int MIN_THRESHOLD = 128;

/**
* The threshold number to compress.
* Minimal reasonable buffer.
*/
protected int compressionThreshold = 0;
// 8KB is what tomcat would use by default anyway
private static final int MIN_BUFFER = 8192;

/**
* Minimal reasonable buffer.
* The threshold number to compress.
*/
private final int minBuffer = 8192; // 8KB is what tomcat would use by default anyway
protected int compressionThreshold = 0;

/**
* The compression buffer size to avoid chunking.
Expand Down Expand Up @@ -95,24 +96,24 @@ public void init(FilterConfig filterConfig) {
String str = filterConfig.getInitParameter("compressionThreshold");
if (str!=null) {
compressionThreshold = Integer.parseInt(str);
if (compressionThreshold != 0 && compressionThreshold < minThreshold) {
if (compressionThreshold != 0 && compressionThreshold < MIN_THRESHOLD) {
if (debug > 0) {
System.out.println("compressionThreshold should be either 0 - no compression or >= " + minThreshold);
System.out.println("compressionThreshold set to " + minThreshold);
System.out.println("compressionThreshold should be either 0 - no compression or >= " + MIN_THRESHOLD);
System.out.println("compressionThreshold set to " + MIN_THRESHOLD);
}
compressionThreshold = minThreshold;
compressionThreshold = MIN_THRESHOLD;
}
}

str = filterConfig.getInitParameter("compressionBuffer");
if (str!=null) {
compressionBuffer = Integer.parseInt(str);
if (compressionBuffer < minBuffer) {
if (compressionBuffer < MIN_BUFFER) {
if (debug > 0) {
System.out.println("compressionBuffer should be >= " + minBuffer);
System.out.println("compressionBuffer set to " + minBuffer);
System.out.println("compressionBuffer should be >= " + MIN_BUFFER);
System.out.println("compressionBuffer set to " + MIN_BUFFER);
}
compressionBuffer = minBuffer;
compressionBuffer = MIN_BUFFER;
}
}

Expand Down

0 comments on commit fb804be

Please sign in to comment.