This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new d13cb91 Code clean-up. Add braces for clarity. d13cb91 is described below commit d13cb914f1882e9816d1980802313499fa2b202d Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed May 26 17:03:32 2021 +0100 Code clean-up. Add braces for clarity. Still testing changes to CI --- .../catalina/users/MemoryUserDatabaseFactory.java | 3 +- java/org/apache/catalina/util/Extension.java | 45 ++++--- .../org/apache/catalina/util/ManifestResource.java | 16 ++- java/org/apache/catalina/util/ResourceSet.java | 9 +- java/org/apache/catalina/util/ServerInfo.java | 9 +- .../catalina/util/StandardSessionIdGenerator.java | 10 +- java/org/apache/coyote/AbstractProtocol.java | 4 +- java/org/apache/coyote/RequestGroupInfo.java | 3 +- java/org/apache/coyote/Response.java | 10 +- java/org/apache/coyote/ajp/AjpMessage.java | 6 +- java/org/apache/coyote/ajp/AjpProcessor.java | 3 +- java/org/apache/coyote/ajp/Constants.java | 5 +- .../apache/coyote/http11/Http11InputBuffer.java | 21 ++- .../apache/coyote/http11/Http11OutputBuffer.java | 3 +- .../coyote/http11/filters/ChunkedInputFilter.java | 3 +- .../http11/filters/SavedRequestInputFilter.java | 3 +- java/org/apache/coyote/http2/HPackHuffman.java | 16 ++- java/org/apache/el/lang/ELArithmetic.java | 34 +++-- java/org/apache/el/lang/ExpressionBuilder.java | 7 +- java/org/apache/el/lang/FunctionMapperImpl.java | 4 +- java/org/apache/el/util/ReflectionUtil.java | 6 +- java/org/apache/jasper/EmbeddedServletOptions.java | 9 +- java/org/apache/jasper/JspC.java | 17 ++- java/org/apache/jasper/compiler/AntCompiler.java | 6 +- java/org/apache/jasper/compiler/Collector.java | 3 +- java/org/apache/jasper/compiler/Compiler.java | 9 +- java/org/apache/jasper/compiler/ELParser.java | 3 +- java/org/apache/jasper/compiler/Generator.java | 83 +++++++----- java/org/apache/jasper/compiler/JDTCompiler.java | 3 +- .../apache/jasper/compiler/JspDocumentParser.java | 11 +- java/org/apache/jasper/compiler/JspReader.java | 39 ++++-- java/org/apache/jasper/compiler/Node.java | 3 +- java/org/apache/jasper/compiler/PageDataImpl.java | 4 +- java/org/apache/jasper/compiler/PageInfo.java | 78 ++++++----- java/org/apache/jasper/compiler/Parser.java | 15 ++- .../apache/jasper/compiler/ParserController.java | 4 +- .../apache/jasper/compiler/ScriptingVariabler.java | 5 +- java/org/apache/jasper/compiler/ServletWriter.java | 6 +- java/org/apache/jasper/compiler/SmapStratum.java | 36 +++-- java/org/apache/jasper/compiler/SmapUtil.java | 45 ++++--- .../apache/jasper/compiler/TagFileProcessor.java | 9 +- .../apache/jasper/compiler/TagLibraryInfoImpl.java | 3 +- .../apache/jasper/compiler/TagPluginManager.java | 9 +- java/org/apache/jasper/compiler/Validator.java | 42 ++++-- java/org/apache/jasper/el/ELContextWrapper.java | 4 +- java/org/apache/jasper/el/JspMethodExpression.java | 24 +++- .../org/apache/jasper/runtime/BodyContentImpl.java | 10 +- java/org/apache/jasper/runtime/JspFactoryImpl.java | 3 +- .../apache/jasper/runtime/JspRuntimeLibrary.java | 148 +++++++++++++-------- java/org/apache/jasper/runtime/JspWriterImpl.java | 63 ++++++--- .../org/apache/jasper/runtime/PageContextImpl.java | 27 ++-- java/org/apache/jasper/runtime/TagHandlerPool.java | 15 ++- java/org/apache/jasper/servlet/JasperLoader.java | 6 +- .../apache/jasper/servlet/JspCServletContext.java | 6 +- java/org/apache/jasper/servlet/JspServlet.java | 4 +- java/org/apache/jasper/tagplugins/jstl/Util.java | 47 ++++--- res/checkstyle/checkstyle.xml | 2 +- 57 files changed, 665 insertions(+), 356 deletions(-) diff --git a/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java b/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java index 6d01ac1..8c23fed 100644 --- a/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java +++ b/java/org/apache/catalina/users/MemoryUserDatabaseFactory.java @@ -106,8 +106,9 @@ public class MemoryUserDatabaseFactory implements ObjectFactory { // Return the configured database instance database.open(); // Don't try something we know won't work - if (!database.getReadonly()) + if (!database.getReadonly()) { database.save(); + } return database; } diff --git a/java/org/apache/catalina/util/Extension.java b/java/org/apache/catalina/util/Extension.java index 172f313..b326561 100644 --- a/java/org/apache/catalina/util/Extension.java +++ b/java/org/apache/catalina/util/Extension.java @@ -181,32 +181,38 @@ public final class Extension { public boolean isCompatibleWith(Extension required) { // Extension Name must match - if (extensionName == null) + if (extensionName == null) { return false; - if (!extensionName.equals(required.getExtensionName())) + } + if (!extensionName.equals(required.getExtensionName())) { return false; + } // If specified, available specification version must be >= required if (required.getSpecificationVersion() != null) { if (!isNewer(specificationVersion, - required.getSpecificationVersion())) + required.getSpecificationVersion())) { return false; + } } // If specified, Implementation Vendor ID must match if (required.getImplementationVendorId() != null) { - if (implementationVendorId == null) + if (implementationVendorId == null) { return false; + } if (!implementationVendorId.equals(required - .getImplementationVendorId())) + .getImplementationVendorId())) { return false; + } } // If specified, Implementation version must be >= required if (required.getImplementationVersion() != null) { if (!isNewer(implementationVersion, - required.getImplementationVersion())) + required.getImplementationVersion())) { return false; + } } // This available optional package satisfies the requirements @@ -263,32 +269,39 @@ public final class Extension { private boolean isNewer(String first, String second) throws NumberFormatException { - if ((first == null) || (second == null)) + if ((first == null) || (second == null)) { return false; - if (first.equals(second)) + } + if (first.equals(second)) { return true; + } StringTokenizer fTok = new StringTokenizer(first, ".", true); StringTokenizer sTok = new StringTokenizer(second, ".", true); int fVersion = 0; int sVersion = 0; while (fTok.hasMoreTokens() || sTok.hasMoreTokens()) { - if (fTok.hasMoreTokens()) + if (fTok.hasMoreTokens()) { fVersion = Integer.parseInt(fTok.nextToken()); - else + } else { fVersion = 0; - if (sTok.hasMoreTokens()) + } + if (sTok.hasMoreTokens()) { sVersion = Integer.parseInt(sTok.nextToken()); - else + } else { sVersion = 0; - if (fVersion < sVersion) + } + if (fVersion < sVersion) { return false; - else if (fVersion > sVersion) + } else if (fVersion > sVersion) { return true; - if (fTok.hasMoreTokens()) // Swallow the periods + } + if (fTok.hasMoreTokens()) { fTok.nextToken(); - if (sTok.hasMoreTokens()) + } + if (sTok.hasMoreTokens()) { sTok.nextToken(); + } } return true; // Exact match diff --git a/java/org/apache/catalina/util/ManifestResource.java b/java/org/apache/catalina/util/ManifestResource.java index 2402b51..d4c80de 100644 --- a/java/org/apache/catalina/util/ManifestResource.java +++ b/java/org/apache/catalina/util/ManifestResource.java @@ -107,7 +107,9 @@ public class ManifestResource { return true; } for (Extension ext : requiredExtensions) { - if (!ext.isFulfilled()) return false; + if (!ext.isFulfilled()) { + return false; + } } return true; } @@ -154,8 +156,9 @@ public class ManifestResource { Attributes attributes = manifest.getMainAttributes(); String names = attributes.getValue("Extension-List"); - if (names == null) + if (names == null) { return null; + } ArrayList<Extension> extensionList = new ArrayList<>(); names += " "; @@ -163,15 +166,17 @@ public class ManifestResource { while (true) { int space = names.indexOf(' '); - if (space < 0) + if (space < 0) { break; + } String name = names.substring(0, space).trim(); names = names.substring(space + 1); String value = attributes.getValue(name + "-Extension-Name"); - if (value == null) + if (value == null) { continue; + } Extension extension = new Extension(); extension.setExtensionName(value); extension.setImplementationURL @@ -201,8 +206,9 @@ public class ManifestResource { Attributes attributes = manifest.getMainAttributes(); String name = attributes.getValue("Extension-Name"); - if (name == null) + if (name == null) { return null; + } ArrayList<Extension> extensionList = new ArrayList<>(); diff --git a/java/org/apache/catalina/util/ResourceSet.java b/java/org/apache/catalina/util/ResourceSet.java index 4e6dc68..a551d5a 100644 --- a/java/org/apache/catalina/util/ResourceSet.java +++ b/java/org/apache/catalina/util/ResourceSet.java @@ -138,9 +138,10 @@ public final class ResourceSet<T> extends HashSet<T> { */ @Override public boolean add(T o) { - if (locked) + if (locked) { throw new IllegalStateException (sm.getString("resourceSet.locked")); + } return super.add(o); } @@ -153,9 +154,10 @@ public final class ResourceSet<T> extends HashSet<T> { @Override public void clear() { - if (locked) + if (locked) { throw new IllegalStateException (sm.getString("resourceSet.locked")); + } super.clear(); } @@ -171,9 +173,10 @@ public final class ResourceSet<T> extends HashSet<T> { */ @Override public boolean remove(Object o) { - if (locked) + if (locked) { throw new IllegalStateException (sm.getString("resourceSet.locked")); + } return super.remove(o); } diff --git a/java/org/apache/catalina/util/ServerInfo.java b/java/org/apache/catalina/util/ServerInfo.java index a70b5bf..d8719bd 100644 --- a/java/org/apache/catalina/util/ServerInfo.java +++ b/java/org/apache/catalina/util/ServerInfo.java @@ -68,12 +68,15 @@ public class ServerInfo { } catch (Throwable t) { ExceptionUtils.handleThrowable(t); } - if (info == null || info.equals("Apache Tomcat/@VERSION@")) + if (info == null || info.equals("Apache Tomcat/@VERSION@")) { info = "Apache Tomcat/9.0.x-dev"; - if (built == null || built.equals("@VERSION_BUILT@")) + } + if (built == null || built.equals("@VERSION_BUILT@")) { built = "unknown"; - if (number == null || number.equals("@VERSION_NUMBER@")) + } + if (number == null || number.equals("@VERSION_NUMBER@")) { number = "9.0.x"; + } serverInfo = info; serverBuilt = built; diff --git a/java/org/apache/catalina/util/StandardSessionIdGenerator.java b/java/org/apache/catalina/util/StandardSessionIdGenerator.java index 437a28a..ea6ea65 100644 --- a/java/org/apache/catalina/util/StandardSessionIdGenerator.java +++ b/java/org/apache/catalina/util/StandardSessionIdGenerator.java @@ -37,14 +37,16 @@ public class StandardSessionIdGenerator extends SessionIdGeneratorBase { j++) { byte b1 = (byte) ((random[j] & 0xf0) >> 4); byte b2 = (byte) (random[j] & 0x0f); - if (b1 < 10) + if (b1 < 10) { buffer.append((char) ('0' + b1)); - else + } else { buffer.append((char) ('A' + (b1 - 10))); - if (b2 < 10) + } + if (b2 < 10) { buffer.append((char) ('0' + b2)); - else + } else { buffer.append((char) ('A' + (b2 - 10))); + } resultLenBytes++; } } diff --git a/java/org/apache/coyote/AbstractProtocol.java b/java/org/apache/coyote/AbstractProtocol.java index a2fca87..c8b4a94 100644 --- a/java/org/apache/coyote/AbstractProtocol.java +++ b/java/org/apache/coyote/AbstractProtocol.java @@ -1225,7 +1225,9 @@ public abstract class AbstractProtocol<S> implements ProtocolHandler, size.incrementAndGet(); } } - if (!result) handler.unregister(processor); + if (!result) { + handler.unregister(processor); + } return result; } diff --git a/java/org/apache/coyote/RequestGroupInfo.java b/java/org/apache/coyote/RequestGroupInfo.java index 057430a..e2ca05b 100644 --- a/java/org/apache/coyote/RequestGroupInfo.java +++ b/java/org/apache/coyote/RequestGroupInfo.java @@ -40,8 +40,9 @@ public class RequestGroupInfo extends BaseModelMBean { public synchronized void removeRequestProcessor( RequestInfo rp ) { if( rp != null ) { - if( deadMaxTime < rp.getMaxTime() ) + if( deadMaxTime < rp.getMaxTime() ) { deadMaxTime = rp.getMaxTime(); + } deadProcessingTime += rp.getProcessingTime(); deadRequestCount += rp.getRequestCount(); deadErrorCount += rp.getErrorCount(); diff --git a/java/org/apache/coyote/Response.java b/java/org/apache/coyote/Response.java index d4af8e7..26870ef 100644 --- a/java/org/apache/coyote/Response.java +++ b/java/org/apache/coyote/Response.java @@ -361,8 +361,9 @@ public final class Response { public void setHeader(String name, String value) { char cc=name.charAt(0); if( cc=='C' || cc=='c' ) { - if( checkSpecialHeader(name, value) ) - return; + if( checkSpecialHeader(name, value) ) { + return; + } } headers.setValue(name).setString( value); } @@ -376,8 +377,9 @@ public final class Response { public void addHeader(String name, String value, Charset charset) { char cc=name.charAt(0); if( cc=='C' || cc=='c' ) { - if( checkSpecialHeader(name, value) ) - return; + if( checkSpecialHeader(name, value) ) { + return; + } } MessageBytes mb = headers.addValue(name); if (charset != null) { diff --git a/java/org/apache/coyote/ajp/AjpMessage.java b/java/org/apache/coyote/ajp/AjpMessage.java index 9c93a59..3560305 100644 --- a/java/org/apache/coyote/ajp/AjpMessage.java +++ b/java/org/apache/coyote/ajp/AjpMessage.java @@ -371,10 +371,12 @@ public class AjpMessage { log.debug(prefix + ": " + HexUtils.toHexString(buf) + " " + pos +"/" + (len + 4)); } int max = pos; - if (len + 4 > pos) + if (len + 4 > pos) { max = len+4; - if (max > 1000) + } + if (max > 1000) { max = 1000; + } if (log.isDebugEnabled()) { for (int j = 0; j < max; j += 16) { log.debug(hexLine(buf, j, len)); diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java b/java/org/apache/coyote/ajp/AjpProcessor.java index c99ad9e..289089f 100644 --- a/java/org/apache/coyote/ajp/AjpProcessor.java +++ b/java/org/apache/coyote/ajp/AjpProcessor.java @@ -1041,8 +1041,9 @@ public class AjpProcessor extends AbstractProcessor { */ @Override protected final void finishResponse() throws IOException { - if (responseFinished) + if (responseFinished) { return; + } responseFinished = true; diff --git a/java/org/apache/coyote/ajp/Constants.java b/java/org/apache/coyote/ajp/Constants.java index 245404b..355c765 100644 --- a/java/org/apache/coyote/ajp/Constants.java +++ b/java/org/apache/coyote/ajp/Constants.java @@ -232,9 +232,10 @@ public final class Constants { public static final int getResponseAjpIndex(String header) { Integer i = responseTransHash.get(header); - if (i == null) + if (i == null) { return 0; - else + } else { return i.intValue(); + } } } diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java b/java/org/apache/coyote/http11/Http11InputBuffer.java index 99a5e60..b632e53 100644 --- a/java/org/apache/coyote/http11/Http11InputBuffer.java +++ b/java/org/apache/coyote/http11/Http11InputBuffer.java @@ -218,8 +218,9 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler filter.setBuffer(inputStreamInputBuffer); } else { for (int i = 0; i <= lastActiveFilter; i++) { - if (activeFilters[i] == filter) + if (activeFilters[i] == filter) { return; + } } filter.setBuffer(activeFilters[lastActiveFilter]); } @@ -399,8 +400,9 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler while (!space) { // Read new bytes if needed if (byteBuffer.position() >= byteBuffer.limit()) { - if (!fill(false)) // request line parsing + if (!fill(false)) { return false; + } } // Spec says method name is a token followed by a single SP but // also be tolerant of multiple SP and/or HT. @@ -425,8 +427,9 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler while (space) { // Read new bytes if needed if (byteBuffer.position() >= byteBuffer.limit()) { - if (!fill(false)) // request line parsing + if (!fill(false)) { return false; + } } chr = byteBuffer.get(); if (!(chr == Constants.SP || chr == Constants.HT)) { @@ -448,8 +451,9 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler while (!space) { // Read new bytes if needed if (byteBuffer.position() >= byteBuffer.limit()) { - if (!fill(false)) // request line parsing + if (!fill(false)) { return false; + } } int pos = byteBuffer.position(); prevChr = chr; @@ -519,8 +523,9 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler while (space) { // Read new bytes if needed if (byteBuffer.position() >= byteBuffer.limit()) { - if (!fill(false)) // request line parsing + if (!fill(false)) { return false; + } } byte chr = byteBuffer.get(); if (!(chr == Constants.SP || chr == Constants.HT)) { @@ -542,8 +547,9 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler while (!parsingRequestLineEol) { // Read new bytes if needed if (byteBuffer.position() >= byteBuffer.limit()) { - if (!fill(false)) // request line parsing + if (!fill(false)) { return false; + } } int pos = byteBuffer.position(); @@ -1163,8 +1169,9 @@ public class Http11InputBuffer implements InputBuffer, ApplicationBufferHandler if (byteBuffer.position() >= byteBuffer.limit()) { // The application is reading the HTTP request body which is // always a blocking operation. - if (!fill(true)) + if (!fill(true)) { return -1; + } } int length = byteBuffer.remaining(); diff --git a/java/org/apache/coyote/http11/Http11OutputBuffer.java b/java/org/apache/coyote/http11/Http11OutputBuffer.java index 906e8c9..cf666b6 100644 --- a/java/org/apache/coyote/http11/Http11OutputBuffer.java +++ b/java/org/apache/coyote/http11/Http11OutputBuffer.java @@ -163,8 +163,9 @@ public class Http11OutputBuffer implements HttpOutputBuffer { filter.setBuffer(outputStreamOutputBuffer); } else { for (int i = 0; i <= lastActiveFilter; i++) { - if (activeFilters[i] == filter) + if (activeFilters[i] == filter) { return; + } } filter.setBuffer(activeFilters[lastActiveFilter]); } diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java index b59eb6e..586d070 100644 --- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java +++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java @@ -335,8 +335,9 @@ public class ChunkedInputFilter implements InputFilter, ApplicationBufferHandler while (!eol) { if (readChunk == null || readChunk.position() >= readChunk.limit()) { - if (readBytes() <= 0) + if (readBytes() <= 0) { return false; + } } byte chr = readChunk.get(readChunk.position()); diff --git a/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java b/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java index 5229bcb..c84fe69 100644 --- a/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java +++ b/java/org/apache/coyote/http11/filters/SavedRequestInputFilter.java @@ -47,8 +47,9 @@ public class SavedRequestInputFilter implements InputFilter { @Override public int doRead(ApplicationBufferHandler handler) throws IOException { - if(input.getOffset()>= input.getEnd()) + if(input.getOffset()>= input.getEnd()) { return -1; + } ByteBuffer byteBuffer = handler.getByteBuffer(); byteBuffer.position(byteBuffer.limit()).limit(byteBuffer.capacity()); diff --git a/java/org/apache/coyote/http2/HPackHuffman.java b/java/org/apache/coyote/http2/HPackHuffman.java index cda063c..1bdc9a0 100644 --- a/java/org/apache/coyote/http2/HPackHuffman.java +++ b/java/org/apache/coyote/http2/HPackHuffman.java @@ -555,13 +555,21 @@ public class HPackHuffman { public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } HuffmanCode that = (HuffmanCode) o; - if (length != that.length) return false; - if (value != that.value) return false; + if (length != that.length) { + return false; + } + if (value != that.value) { + return false; + } return true; } diff --git a/java/org/apache/el/lang/ELArithmetic.java b/java/org/apache/el/lang/ELArithmetic.java index cff8d69..228e6a5 100644 --- a/java/org/apache/el/lang/ELArithmetic.java +++ b/java/org/apache/el/lang/ELArithmetic.java @@ -39,10 +39,12 @@ public abstract class ELArithmetic { @Override protected Number coerce(Number num) { - if (num instanceof BigDecimal) + if (num instanceof BigDecimal) { return num; - if (num instanceof BigInteger) + } + if (num instanceof BigInteger) { return new BigDecimal((BigInteger) num); + } return new BigDecimal(num.doubleValue()); } @@ -87,8 +89,9 @@ public abstract class ELArithmetic { @Override protected Number coerce(Number num) { - if (num instanceof BigInteger) + if (num instanceof BigInteger) { return num; + } return new BigInteger(num.toString()); } @@ -138,10 +141,12 @@ public abstract class ELArithmetic { @Override protected Number coerce(Number num) { - if (num instanceof Double) + if (num instanceof Double) { return num; - if (num instanceof BigInteger) + } + if (num instanceof BigInteger) { return new BigDecimal((BigInteger) num); + } return Double.valueOf(num.doubleValue()); } @@ -203,8 +208,9 @@ public abstract class ELArithmetic { @Override protected Number coerce(Number num) { - if (num instanceof Long) + if (num instanceof Long) { return num; + } return Long.valueOf(num.longValue()); } @@ -267,14 +273,15 @@ public abstract class ELArithmetic { } final ELArithmetic delegate; - if (BIGDECIMAL.matches(obj0, obj1)) + if (BIGDECIMAL.matches(obj0, obj1)) { delegate = DOUBLE; - else if (DOUBLE.matches(obj0, obj1)) + } else if (DOUBLE.matches(obj0, obj1)) { delegate = DOUBLE; - else if (BIGINTEGER.matches(obj0, obj1)) + } else if (BIGINTEGER.matches(obj0, obj1)) { delegate = BIGINTEGER; - else + } else { delegate = LONG; + } Number num0 = delegate.coerce(obj0); Number num1 = delegate.coerce(obj1); @@ -300,12 +307,13 @@ public abstract class ELArithmetic { } final ELArithmetic delegate; - if (BIGDECIMAL.matches(obj0, obj1)) + if (BIGDECIMAL.matches(obj0, obj1)) { delegate = BIGDECIMAL; - else if (BIGINTEGER.matches(obj0, obj1)) + } else if (BIGINTEGER.matches(obj0, obj1)) { delegate = BIGDECIMAL; - else + } else { delegate = DOUBLE; + } Number num0 = delegate.coerce(obj0); Number num1 = delegate.coerce(obj1); diff --git a/java/org/apache/el/lang/ExpressionBuilder.java b/java/org/apache/el/lang/ExpressionBuilder.java index 252ba51..20dec6b 100644 --- a/java/org/apache/el/lang/ExpressionBuilder.java +++ b/java/org/apache/el/lang/ExpressionBuilder.java @@ -120,11 +120,12 @@ public final class ExpressionBuilder implements NodeVisitor { Node child = null; for (int i = 0; i < numChildren; i++) { child = n.jjtGetChild(i); - if (child instanceof AstLiteralExpression) + if (child instanceof AstLiteralExpression) { continue; - if (type == null) + } + if (type == null) { type = child.getClass(); - else { + } else { if (!type.equals(child.getClass())) { throw new ELException(MessageFactory.get( "error.mixed", expr)); diff --git a/java/org/apache/el/lang/FunctionMapperImpl.java b/java/org/apache/el/lang/FunctionMapperImpl.java index 7ca71b4..dc7ff0a 100644 --- a/java/org/apache/el/lang/FunctionMapperImpl.java +++ b/java/org/apache/el/lang/FunctionMapperImpl.java @@ -146,7 +146,9 @@ public class FunctionMapperImpl extends FunctionMapper implements ClassNotFoundException { this.prefix = in.readUTF(); - if (this.prefix.isEmpty()) this.prefix = null; + if (this.prefix.isEmpty()) { + this.prefix = null; + } this.localName = in.readUTF(); this.owner = in.readUTF(); this.name = in.readUTF(); diff --git a/java/org/apache/el/util/ReflectionUtil.java b/java/org/apache/el/util/ReflectionUtil.java index e4327ba..03ae766 100644 --- a/java/org/apache/el/util/ReflectionUtil.java +++ b/java/org/apache/el/util/ReflectionUtil.java @@ -87,8 +87,9 @@ public class ReflectionUtil { * @throws ClassNotFoundException If a class of a given name cannot be found */ public static Class<?>[] toTypeArray(String[] s) throws ClassNotFoundException { - if (s == null) + if (s == null) { return null; + } Class<?>[] c = new Class[s.length]; for (int i = 0; i < s.length; i++) { c[i] = forName(s[i]); @@ -103,8 +104,9 @@ public class ReflectionUtil { * result is the name of the class instance at index i in the input */ public static String[] toTypeNameArray(Class<?>[] c) { - if (c == null) + if (c == null) { return null; + } String[] s = new String[c.length]; for (int i = 0; i < c.length; i++) { s[i] = c[i].getName(); diff --git a/java/org/apache/jasper/EmbeddedServletOptions.java b/java/org/apache/jasper/EmbeddedServletOptions.java index 3636f62..1d49646 100644 --- a/java/org/apache/jasper/EmbeddedServletOptions.java +++ b/java/org/apache/jasper/EmbeddedServletOptions.java @@ -644,12 +644,14 @@ public final class EmbeddedServletOptions implements Options { } String ieClassId = config.getInitParameter("ieClassId"); - if (ieClassId != null) + if (ieClassId != null) { this.ieClassId = ieClassId; + } String classpath = config.getInitParameter("classpath"); - if (classpath != null) + if (classpath != null) { this.classpath = classpath; + } /* * scratchdir @@ -670,9 +672,10 @@ public final class EmbeddedServletOptions implements Options { } if (!(scratchDir.exists() && scratchDir.canRead() && - scratchDir.canWrite() && scratchDir.isDirectory())) + scratchDir.canWrite() && scratchDir.isDirectory())) { log.fatal(Localizer.getMessage("jsp.error.bad.scratch.dir", scratchDir.getAbsolutePath())); + } this.compiler = config.getInitParameter("compiler"); diff --git a/java/org/apache/jasper/JspC.java b/java/org/apache/jasper/JspC.java index 15f983d..c37680d 100644 --- a/java/org/apache/jasper/JspC.java +++ b/java/org/apache/jasper/JspC.java @@ -836,8 +836,9 @@ public class JspC extends Task implements Options { */ @Override public String getClassPath() { - if( classPath != null ) + if( classPath != null ) { return classPath; + } return System.getProperty("java.class.path"); } @@ -1280,12 +1281,14 @@ public class JspC extends Task implements Options { } } - if(!webXml2.delete() && log.isDebugEnabled()) + if(!webXml2.delete() && log.isDebugEnabled()) { log.debug(Localizer.getMessage("jspc.delete.fail", webXml2.toString())); + } - if (!(new File(webxmlFile)).delete() && log.isDebugEnabled()) + if (!(new File(webxmlFile)).delete() && log.isDebugEnabled()) { log.debug(Localizer.getMessage("jspc.delete.fail", webxmlFile)); + } } @@ -1610,7 +1613,9 @@ public class JspC extends Task implements Options { } protected String nextFile() { - if (fullstop) argPos++; + if (fullstop) { + argPos++; + } if (argPos >= args.length) { return null; } else { @@ -1764,7 +1769,9 @@ public class JspC extends Task implements Options { String[] libs = webinfLib.list(); if (libs != null) { for (String lib : libs) { - if (lib.length() < 5) continue; + if (lib.length() < 5) { + continue; + } String ext = lib.substring(lib.length() - 4); if (!".jar".equalsIgnoreCase(ext)) { if (".tld".equalsIgnoreCase(ext)) { diff --git a/java/org/apache/jasper/compiler/AntCompiler.java b/java/org/apache/jasper/compiler/AntCompiler.java index 2246b99..3e14bc7 100644 --- a/java/org/apache/jasper/compiler/AntCompiler.java +++ b/java/org/apache/jasper/compiler/AntCompiler.java @@ -65,8 +65,9 @@ public class AntCompiler extends Compiler { // Lazy eval - if we don't need to compile we probably don't need the project protected Project getProject() { - if (project != null) + if (project != null) { return project; + } // Initializing project project = new Project(); @@ -80,8 +81,9 @@ public class AntCompiler extends Compiler { } if( options.getCompiler() != null ) { - if( log.isDebugEnabled() ) + if( log.isDebugEnabled() ) { log.debug("Compiler " + options.getCompiler() ); + } project.setProperty("build.compiler", options.getCompiler() ); } project.init(); diff --git a/java/org/apache/jasper/compiler/Collector.java b/java/org/apache/jasper/compiler/Collector.java index cd0f38d..29d93c9 100644 --- a/java/org/apache/jasper/compiler/Collector.java +++ b/java/org/apache/jasper/compiler/Collector.java @@ -161,8 +161,9 @@ class Collector { @Override public void visit(Node.JspElement n) throws JasperException { - if (n.getNameAttribute().isExpression()) + if (n.getNameAttribute().isExpression()) { scriptingElementSeen = true; + } Node.JspAttribute[] attrs = n.getJspAttributes(); for (Node.JspAttribute attr : attrs) { diff --git a/java/org/apache/jasper/compiler/Compiler.java b/java/org/apache/jasper/compiler/Compiler.java index ac6f321..e834e00 100644 --- a/java/org/apache/jasper/compiler/Compiler.java +++ b/java/org/apache/jasper/compiler/Compiler.java @@ -543,9 +543,10 @@ public abstract class Compiler { return true; } } catch (Exception e) { - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("Problem accessing resource. Treat as outdated.", e); + } return true; } } @@ -580,8 +581,9 @@ public abstract class Compiler { try { File javaFile = new File(ctxt.getServletJavaFileName()); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("Deleting " + javaFile); + } if (javaFile.exists()) { if (!javaFile.delete()) { log.warn(Localizer.getMessage( @@ -599,8 +601,9 @@ public abstract class Compiler { public void removeGeneratedClassFiles() { try { File classFile = new File(ctxt.getClassFileName()); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("Deleting " + classFile); + } if (classFile.exists()) { if (!classFile.delete()) { log.warn(Localizer.getMessage( diff --git a/java/org/apache/jasper/compiler/ELParser.java b/java/org/apache/jasper/compiler/ELParser.java index 3bcef5b..afae730 100644 --- a/java/org/apache/jasper/compiler/ELParser.java +++ b/java/org/apache/jasper/compiler/ELParser.java @@ -407,8 +407,9 @@ public class ELParser { int start = index; while (hasNextChar()) { char c = expression.charAt(index); - if (c > ' ') + if (c > ' ') { break; + } index++; } whiteSpace = expression.substring(start, index); diff --git a/java/org/apache/jasper/compiler/Generator.java b/java/org/apache/jasper/compiler/Generator.java index 1fec7df..649f927 100644 --- a/java/org/apache/jasper/compiler/Generator.java +++ b/java/org/apache/jasper/compiler/Generator.java @@ -163,16 +163,17 @@ class Generator { StringBuilder b = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); - if (c == '"') + if (c == '"') { b.append('\\').append('"'); - else if (c == '\\') + } else if (c == '\\') { b.append('\\').append('\\'); - else if (c == '\n') + } else if (c == '\n') { b.append('\\').append('n'); - else if (c == '\r') + } else if (c == '\r') { b.append('\\').append('r'); - else + } else { b.append(c); + } } return b.toString(); } @@ -184,16 +185,17 @@ class Generator { StringBuilder b = new StringBuilder(); b.append('\''); - if (c == '\'') + if (c == '\'') { b.append('\\').append('\''); - else if (c == '\\') + } else if (c == '\\') { b.append('\\').append('\\'); - else if (c == '\n') + } else if (c == '\n') { b.append('\\').append('n'); - else if (c == '\r') + } else if (c == '\r') { b.append('\\').append('r'); - else + } else { b.append(c); + } b.append('\''); return b.toString(); } @@ -237,8 +239,9 @@ class Generator { } String info = n.getAttributeValue("info"); - if (info == null) + if (info == null) { return; + } getServletInfoGenerated = true; out.printil("public java.lang.String getServletInfo() {"); @@ -800,8 +803,9 @@ class Generator { // Local variable declarations out.printil("final javax.servlet.jsp.PageContext pageContext;"); - if (pageInfo.isSession()) + if (pageInfo.isSession()) { out.printil("javax.servlet.http.HttpSession session = null;"); + } if (pageInfo.isErrorPage()) { out.printil("java.lang.Throwable exception = org.apache.jasper.runtime.JspRuntimeLibrary.getThrowable(request);"); @@ -847,8 +851,9 @@ class Generator { out.printil("application = pageContext.getServletContext();"); out.printil("config = pageContext.getServletConfig();"); - if (pageInfo.isSession()) + if (pageInfo.isSession()) { out.printil("session = pageContext.getSession();"); + } out.printil("out = pageContext.getOut();"); out.printil("_jspx_out = out;"); out.println(); @@ -1262,7 +1267,9 @@ class Generator { + name + "\"), request);"); } else if (value == null) { if (param == null) + { param = property; // default to same as property + } out.printil("org.apache.jasper.runtime.JspRuntimeLibrary.introspecthelper(" + "_jspx_page_context.findAttribute(\"" + name @@ -1532,8 +1539,9 @@ class Generator { * @return a string for the form 'attr = "value"' */ private String makeAttr(String attr, String value) { - if (value == null) + if (value == null) { return ""; + } return " " + attr + "=\"" + value + '\"'; } @@ -1556,10 +1564,11 @@ class Generator { public void visit(Node.ParamAction n) throws JasperException { String name = n.getTextAttribute("name"); - if (name.equalsIgnoreCase("object")) + if (name.equalsIgnoreCase("object")) { name = "java_object"; - else if (name.equalsIgnoreCase("type")) + } else if (name.equalsIgnoreCase("type")) { name = "java_type"; + } n.setBeginJavaLine(out.getJavaLine()); // XXX - Fixed a bug here - value used to be output @@ -1627,10 +1636,12 @@ class Generator { } } - if (iepluginurl == null) + if (iepluginurl == null) { iepluginurl = Constants.IE_PLUGIN_URL; - if (nspluginurl == null) + } + if (nspluginurl == null) { nspluginurl = Constants.NS_PLUGIN_URL; + } n.setBeginJavaLine(out.getJavaLine()); @@ -1713,8 +1724,9 @@ class Generator { /* * generate a <param> for each <jsp:param> in the plugin body */ - if (n.getBody() != null) + if (n.getBody() != null) { n.getBody().visit(new ParamVisitor(true)); + } /* * Netscape style plugin part @@ -1741,8 +1753,9 @@ class Generator { /* * Generate a 'attr = "value"' for each <jsp:param> in plugin body */ - if (n.getBody() != null) + if (n.getBody() != null) { n.getBody().visit(new ParamVisitor(false)); + } out.printil("out.write(" + quote("/>") + ");"); out.printil("out.write(\"\\n\");"); @@ -2787,12 +2800,14 @@ class Generator { if (varInfos.length > 0) { for (VariableInfo varInfo : varInfos) { - if (varInfo.getScope() != scope) + if (varInfo.getScope() != scope) { continue; + } // If the scripting variable has been declared, skip codes // for saving and restoring it. - if (declaredVariables.contains(varInfo)) + if (declaredVariables.contains(varInfo)) { continue; + } String varName = varInfo.getVarName(); String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel(); @@ -2803,12 +2818,14 @@ class Generator { } } else { for (TagVariableInfo tagVarInfo : tagVarInfos) { - if (tagVarInfo.getScope() != scope) + if (tagVarInfo.getScope() != scope) { continue; + } // If the scripting variable has been declared, skip codes // for saving and restoring it. - if (declaredVariables.contains(tagVarInfo)) + if (declaredVariables.contains(tagVarInfo)) { continue; + } String varName = tagVarInfo.getNameGiven(); if (varName == null) { varName = n.getTagData().getAttributeString( @@ -2859,12 +2876,14 @@ class Generator { if (varInfos.length > 0) { for (VariableInfo varInfo : varInfos) { - if (varInfo.getScope() != scope) + if (varInfo.getScope() != scope) { continue; + } // If the scripting variable has been declared, skip codes // for saving and restoring it. - if (declaredVariables.contains(varInfo)) + if (declaredVariables.contains(varInfo)) { continue; + } String varName = varInfo.getVarName(); String tmpVarName = "_jspx_" + varName + "_" + n.getCustomNestingLevel(); @@ -2875,12 +2894,14 @@ class Generator { } } else { for (TagVariableInfo tagVarInfo : tagVarInfos) { - if (tagVarInfo.getScope() != scope) + if (tagVarInfo.getScope() != scope) { continue; + } // If the scripting variable has been declared, skip codes // for saving and restoring it. - if (declaredVariables.contains(tagVarInfo)) + if (declaredVariables.contains(tagVarInfo)) { continue; + } String varName = tagVarInfo.getNameGiven(); if (varName == null) { varName = n.getTagData().getAttributeString( @@ -3662,8 +3683,9 @@ class Generator { // Tag-handler specific declarations generateTagHandlerAttributes(tagInfo); - if (tagInfo.hasDynamicAttributes()) + if (tagInfo.hasDynamicAttributes()) { generateSetDynamicAttribute(); + } // Methods here genPreambleMethods(); @@ -4055,9 +4077,10 @@ class Generator { if (propertyDescriptor.getWriteMethod() != null) { methodMaps.put(propertyDescriptor.getName(), propertyDescriptor.getWriteMethod()); } - if (propertyDescriptor.getPropertyEditorClass() != null) + if (propertyDescriptor.getPropertyEditorClass() != null) { propertyEditorMaps.put(propertyDescriptor.getName(), propertyDescriptor .getPropertyEditorClass()); + } } } catch (IntrospectionException ie) { // Likely unreachable code diff --git a/java/org/apache/jasper/compiler/JDTCompiler.java b/java/org/apache/jasper/compiler/JDTCompiler.java index 5b15a80..7e3e4de 100644 --- a/java/org/apache/jasper/compiler/JDTCompiler.java +++ b/java/org/apache/jasper/compiler/JDTCompiler.java @@ -415,8 +415,9 @@ public class JDTCompiler extends org.apache.jasper.compiler.Compiler { StringBuilder classFileName = new StringBuilder(outputDir).append('/'); for (int j = 0; j < compoundName.length; j++) { - if (j > 0) + if (j > 0) { classFileName.append('/'); + } classFileName.append(compoundName[j]); } byte[] bytes = classFile.getBytes(); diff --git a/java/org/apache/jasper/compiler/JspDocumentParser.java b/java/org/apache/jasper/compiler/JspDocumentParser.java index b40ba76..f0893fe 100644 --- a/java/org/apache/jasper/compiler/JspDocumentParser.java +++ b/java/org/apache/jasper/compiler/JspDocumentParser.java @@ -593,10 +593,11 @@ class JspDocumentParser startMark = new Mark(ctxt, path, line, column); break; } - if (ch == '"') + if (ch == '"') { doubleQ = !doubleQ; - else if (ch == '\'') + } else if (ch == '\'') { singleQ = !singleQ; + } ttext.write(ch); lastCh = ch; @@ -1351,10 +1352,12 @@ class JspDocumentParser Node n = body.getNode(i); if (!(n instanceof Node.TemplateText)) { String elemType = SCRIPTLET_ACTION; - if (scriptingElem instanceof Node.Declaration) + if (scriptingElem instanceof Node.Declaration) { elemType = DECLARATION_ACTION; - if (scriptingElem instanceof Node.Expression) + } + if (scriptingElem instanceof Node.Expression) { elemType = EXPRESSION_ACTION; + } String msg = Localizer.getMessage( "jsp.error.parse.xml.scripting.invalid.body", diff --git a/java/org/apache/jasper/compiler/JspReader.java b/java/org/apache/jasper/compiler/JspReader.java index d191df0..c2c86ce 100644 --- a/java/org/apache/jasper/compiler/JspReader.java +++ b/java/org/apache/jasper/compiler/JspReader.java @@ -112,8 +112,9 @@ class JspReader { try { CharArrayWriter caw = new CharArrayWriter(); char buf[] = new char[1024]; - for (int i = 0 ; (i = reader.read(buf)) != -1 ;) + for (int i = 0 ; (i = reader.read(buf)) != -1 ;) { caw.write(buf, 0, i); + } caw.close(); current = new Mark(this, caw.toCharArray(), fname); } catch (Throwable ex) { @@ -152,8 +153,9 @@ class JspReader { } int nextChar() { - if (!hasMoreInput()) + if (!hasMoreInput()) { return -1; + } int ch = current.stream[current.cursor]; @@ -198,8 +200,9 @@ class JspReader { * and the cursor point to next character. */ private Boolean indexOf(char c, Mark mark) { - if (!hasMoreInput()) + if (!hasMoreInput()) { return null; + } int end = current.stream.length; int ch; @@ -345,11 +348,13 @@ class JspReader { boolean matchesETag(String tagName) { Mark mark = mark(); - if (!matches("</" + tagName)) + if (!matches("</" + tagName)) { return false; + } skipSpaces(); - if (nextChar() == '>') + if (nextChar() == '>') { return true; + } setCurrent(mark); return false; @@ -358,11 +363,13 @@ class JspReader { boolean matchesETagWithoutLessThan(String tagName) { Mark mark = mark(); - if (!matches("/" + tagName)) - return false; + if (!matches("/" + tagName)) { + return false; + } skipSpaces(); - if (nextChar() == '>') - return true; + if (nextChar() == '>') { + return true; + } setCurrent(mark); return false; @@ -464,10 +471,11 @@ class JspReader { skipELExpression(); } else if (ch == firstChar) { for (int i = 1 ; i < limlen ; i++) { - if (peekChar() == limit.charAt(i)) + if (peekChar() == limit.charAt(i)) { nextChar(); - else + } else { continue skip; + } } return ret; } @@ -487,8 +495,9 @@ class JspReader { Mark ret = skipUntil("</" + tag); if (ret != null) { skipSpaces(); - if (nextChar() != '>') + if (nextChar() != '>') { ret = null; + } } return ret; } @@ -576,8 +585,9 @@ class JspReader { ch = nextChar(); for (ch = nextChar(); ch != -1 && ch != endQuote; ch = nextChar()) { - if (ch == '\\') + if (ch == '\\') { ch = nextChar(); + } StringBuilder.append((char) ch); } // Check end of quote, skip closing quote: @@ -595,8 +605,9 @@ class JspReader { // Take care of the quoting here. if (ch == '\\') { if (peekChar() == '"' || peekChar() == '\'' || - peekChar() == '>' || peekChar() == '%') + peekChar() == '>' || peekChar() == '%') { ch = nextChar(); + } } StringBuilder.append((char) ch); } while (!isDelimiter()); diff --git a/java/org/apache/jasper/compiler/Node.java b/java/org/apache/jasper/compiler/Node.java index 92b4a96..094e912 100644 --- a/java/org/apache/jasper/compiler/Node.java +++ b/java/org/apache/jasper/compiler/Node.java @@ -460,8 +460,9 @@ abstract class Node implements TagConstants { // Figure out and set the parent root Node r = parent; - while ((r != null) && !(r instanceof Node.Root)) + while ((r != null) && !(r instanceof Node.Root)) { r = r.getParent(); + } parentRoot = (Node.Root) r; } diff --git a/java/org/apache/jasper/compiler/PageDataImpl.java b/java/org/apache/jasper/compiler/PageDataImpl.java index 97f44dc..13b6770 100644 --- a/java/org/apache/jasper/compiler/PageDataImpl.java +++ b/java/org/apache/jasper/compiler/PageDataImpl.java @@ -665,7 +665,9 @@ class PageDataImpl extends PageData implements TagConstants { * within the given text, so it can be included in a CDATA section. */ private String escapeCDATA(String text) { - if( text==null ) return ""; + if( text==null ) { + return ""; + } int len = text.length(); CharArrayWriter result = new CharArrayWriter(len); for (int i=0; i<len; i++) { diff --git a/java/org/apache/jasper/compiler/PageInfo.java b/java/org/apache/jasper/compiler/PageInfo.java index ecc35fe..48779d6 100644 --- a/java/org/apache/jasper/compiler/PageInfo.java +++ b/java/org/apache/jasper/compiler/PageInfo.java @@ -133,8 +133,9 @@ class PageInfo { * @return true if Id has been declared. */ public boolean isPluginDeclared(String id) { - if (pluginDcls.contains(id)) + if (pluginDcls.contains(id)) { return true; + } pluginDcls.add(id); return false; } @@ -156,8 +157,9 @@ class PageInfo { } public void addDependant(String d, Long lastModified) { - if (!dependants.containsKey(d) && !jspFile.equals(d)) - dependants.put(d, lastModified); + if (!dependants.containsKey(d) && !jspFile.equals(d)) { + dependants.put(d, lastModified); + } } public Map<String,Long> getDependants() { @@ -380,10 +382,11 @@ class PageInfo { throws JasperException { if (!"java".equalsIgnoreCase(value)) { - if (pagedir) + if (pagedir) { err.jspError(n, "jsp.error.page.language.nonjava"); - else + } else { err.jspError(n, "jsp.error.tag.language.nonjava"); + } } language = value; @@ -445,9 +448,9 @@ class PageInfo { public void setBufferValue(String value, Node n, ErrorDispatcher err) throws JasperException { - if ("none".equalsIgnoreCase(value)) + if ("none".equalsIgnoreCase(value)) { buffer = 0; - else { + } else { if (value == null || !value.endsWith("kb")) { if (n == null) { err.jspError("jsp.error.page.invalid.buffer"); @@ -486,12 +489,13 @@ class PageInfo { public void setSession(String value, Node n, ErrorDispatcher err) throws JasperException { - if ("true".equalsIgnoreCase(value)) + if ("true".equalsIgnoreCase(value)) { isSession = true; - else if ("false".equalsIgnoreCase(value)) + } else if ("false".equalsIgnoreCase(value)) { isSession = false; - else + } else { err.jspError(n, "jsp.error.page.invalid.session"); + } session = value; } @@ -511,12 +515,13 @@ class PageInfo { public void setAutoFlush(String value, Node n, ErrorDispatcher err) throws JasperException { - if ("true".equalsIgnoreCase(value)) + if ("true".equalsIgnoreCase(value)) { isAutoFlush = true; - else if ("false".equalsIgnoreCase(value)) + } else if ("false".equalsIgnoreCase(value)) { isAutoFlush = false; - else + } else { err.jspError(n, "jsp.error.autoFlush.invalid"); + } autoFlush = value; } @@ -536,12 +541,13 @@ class PageInfo { public void setIsThreadSafe(String value, Node n, ErrorDispatcher err) throws JasperException { - if ("true".equalsIgnoreCase(value)) + if ("true".equalsIgnoreCase(value)) { isThreadSafe = true; - else if ("false".equalsIgnoreCase(value)) + } else if ("false".equalsIgnoreCase(value)) { isThreadSafe = false; - else + } else { err.jspError(n, "jsp.error.page.invalid.isthreadsafe"); + } isThreadSafeValue = value; } @@ -585,12 +591,13 @@ class PageInfo { public void setIsErrorPage(String value, Node n, ErrorDispatcher err) throws JasperException { - if ("true".equalsIgnoreCase(value)) + if ("true".equalsIgnoreCase(value)) { isErrorPage = true; - else if ("false".equalsIgnoreCase(value)) + } else if ("false".equalsIgnoreCase(value)) { isErrorPage = false; - else + } else { err.jspError(n, "jsp.error.page.invalid.iserrorpage"); + } isErrorPageValue = value; } @@ -611,15 +618,16 @@ class PageInfo { boolean pagedir) throws JasperException { - if ("true".equalsIgnoreCase(value)) + if ("true".equalsIgnoreCase(value)) { isELIgnored = true; - else if ("false".equalsIgnoreCase(value)) + } else if ("false".equalsIgnoreCase(value)) { isELIgnored = false; - else { - if (pagedir) + } else { + if (pagedir) { err.jspError(n, "jsp.error.page.invalid.iselignored"); - else + } else { err.jspError(n, "jsp.error.tag.invalid.iselignored"); + } } isELIgnoredValue = value; @@ -632,15 +640,16 @@ class PageInfo { boolean pagedir) throws JasperException { - if ("true".equalsIgnoreCase(value)) + if ("true".equalsIgnoreCase(value)) { deferredSyntaxAllowedAsLiteral = true; - else if ("false".equalsIgnoreCase(value)) + } else if ("false".equalsIgnoreCase(value)) { deferredSyntaxAllowedAsLiteral = false; - else { - if (pagedir) + } else { + if (pagedir) { err.jspError(n, "jsp.error.page.invalid.deferredsyntaxallowedasliteral"); - else + } else { err.jspError(n, "jsp.error.tag.invalid.deferredsyntaxallowedasliteral"); + } } deferredSyntaxAllowedAsLiteralValue = value; @@ -653,15 +662,16 @@ class PageInfo { boolean pagedir) throws JasperException { - if ("true".equalsIgnoreCase(value)) + if ("true".equalsIgnoreCase(value)) { trimDirectiveWhitespaces = true; - else if ("false".equalsIgnoreCase(value)) + } else if ("false".equalsIgnoreCase(value)) { trimDirectiveWhitespaces = false; - else { - if (pagedir) + } else { + if (pagedir) { err.jspError(n, "jsp.error.page.invalid.trimdirectivewhitespaces"); - else + } else { err.jspError(n, "jsp.error.tag.invalid.trimdirectivewhitespaces"); + } } trimDirectiveWhitespacesValue = value; diff --git a/java/org/apache/jasper/compiler/Parser.java b/java/org/apache/jasper/compiler/Parser.java index 98eb9c2..a630aa4 100644 --- a/java/org/apache/jasper/compiler/Parser.java +++ b/java/org/apache/jasper/compiler/Parser.java @@ -208,8 +208,9 @@ class Parser implements TagConstants { // Get the qualified name String qName = parseName(); - if (qName == null) + if (qName == null) { return false; + } boolean ignoreEL = pageInfo.isELIgnored(); @@ -228,13 +229,15 @@ class Parser implements TagConstants { } reader.skipSpaces(); - if (!reader.matches("=")) + if (!reader.matches("=")) { err.jspError(reader.mark(), "jsp.error.attribute.noequal"); + } reader.skipSpaces(); char quote = (char) reader.nextChar(); - if (quote != '\'' && quote != '"') + if (quote != '\'' && quote != '"') { err.jspError(reader.mark(), "jsp.error.attribute.noquote"); + } String watchString = ""; if (reader.matches("<%=")) { @@ -302,8 +305,9 @@ class Parser implements TagConstants { } catch (IllegalArgumentException iae) { err.jspError(start, iae.getMessage()); } - if (watch.length() == 1) // quote + if (watch.length() == 1) { return ret; + } // Put back delimiter '<%=' and '%>', since they are needed if the // attribute does not allow RTexpression. @@ -1303,8 +1307,9 @@ class Parser implements TagConstants { */ private void parseTemplateText(Node parent) { - if (!reader.hasMoreInput()) + if (!reader.hasMoreInput()) { return; + } CharArrayWriter ttext = new CharArrayWriter(); diff --git a/java/org/apache/jasper/compiler/ParserController.java b/java/org/apache/jasper/compiler/ParserController.java index e3d33d2..376df38 100644 --- a/java/org/apache/jasper/compiler/ParserController.java +++ b/java/org/apache/jasper/compiler/ParserController.java @@ -545,7 +545,9 @@ class ParserController implements TagConstants { Mark start = null; while ((start = reader.skipUntil("<")) != null) { int c = reader.nextChar(); - if (c != '!' && c != '?') break; + if (c != '!' && c != '?') { + break; + } } if (start == null) { return false; diff --git a/java/org/apache/jasper/compiler/ScriptingVariabler.java b/java/org/apache/jasper/compiler/ScriptingVariabler.java index 59c2db9..4d43342 100644 --- a/java/org/apache/jasper/compiler/ScriptingVariabler.java +++ b/java/org/apache/jasper/compiler/ScriptingVariabler.java @@ -95,10 +95,11 @@ class ScriptingVariabler { Node.CustomTag parent = n.getCustomTagParent(); if (scope == VariableInfo.AT_BEGIN || scope == VariableInfo.AT_END) { - if (parent == null) + if (parent == null) { ownRange = MAX_SCOPE; - else + } else { ownRange = parent.getNumCount(); + } } else { // NESTED ownRange = n.getNumCount(); diff --git a/java/org/apache/jasper/compiler/ServletWriter.java b/java/org/apache/jasper/compiler/ServletWriter.java index b34b8cf..f5d3057 100644 --- a/java/org/apache/jasper/compiler/ServletWriter.java +++ b/java/org/apache/jasper/compiler/ServletWriter.java @@ -67,14 +67,16 @@ public class ServletWriter implements AutoCloseable { public void pushIndent() { virtual_indent += TAB_WIDTH; - if (virtual_indent >= 0 && virtual_indent <= SPACES.length()) + if (virtual_indent >= 0 && virtual_indent <= SPACES.length()) { indent = virtual_indent; + } } public void popIndent() { virtual_indent -= TAB_WIDTH; - if (virtual_indent >= 0 && virtual_indent <= SPACES.length()) + if (virtual_indent >= 0 && virtual_indent <= SPACES.length()) { indent = virtual_indent; + } } /** diff --git a/java/org/apache/jasper/compiler/SmapStratum.java b/java/org/apache/jasper/compiler/SmapStratum.java index 334a077..304a15e 100644 --- a/java/org/apache/jasper/compiler/SmapStratum.java +++ b/java/org/apache/jasper/compiler/SmapStratum.java @@ -45,16 +45,18 @@ public class SmapStratum { private boolean lineFileIDSet = false; public void setInputStartLine(int inputStartLine) { - if (inputStartLine < 0) + if (inputStartLine < 0) { throw new IllegalArgumentException(Localizer.getMessage( "jsp.error.negativeParameter", Integer.valueOf(inputStartLine))); + } this.inputStartLine = inputStartLine; } public void setOutputStartLine(int outputStartLine) { - if (outputStartLine < 0) + if (outputStartLine < 0) { throw new IllegalArgumentException(Localizer.getMessage( "jsp.error.negativeParameter", Integer.valueOf(outputStartLine))); + } this.outputStartLine = outputStartLine; } @@ -67,24 +69,27 @@ public class SmapStratum { * @param lineFileID The new line file ID */ public void setLineFileID(int lineFileID) { - if (lineFileID < 0) + if (lineFileID < 0) { throw new IllegalArgumentException(Localizer.getMessage( "jsp.error.negativeParameter", Integer.valueOf(lineFileID))); + } this.lineFileID = lineFileID; this.lineFileIDSet = true; } public void setInputLineCount(int inputLineCount) { - if (inputLineCount < 0) + if (inputLineCount < 0) { throw new IllegalArgumentException(Localizer.getMessage( "jsp.error.negativeParameter", Integer.valueOf(inputLineCount))); + } this.inputLineCount = inputLineCount; } public void setOutputLineIncrement(int outputLineIncrement) { - if (outputLineIncrement < 0) + if (outputLineIncrement < 0) { throw new IllegalArgumentException(Localizer.getMessage( "jsp.error.negativeParameter", Integer.valueOf(outputLineIncrement))); + } this.outputLineIncrement = outputLineIncrement; } @@ -98,17 +103,21 @@ public class SmapStratum { * specified, as its necessity is sensitive to context). */ public String getString() { - if (inputStartLine == -1 || outputStartLine == -1) + if (inputStartLine == -1 || outputStartLine == -1) { throw new IllegalStateException(); + } StringBuilder out = new StringBuilder(); out.append(inputStartLine); - if (lineFileIDSet) + if (lineFileIDSet) { out.append("#" + lineFileID); - if (inputLineCount != 1) + } + if (inputLineCount != 1) { out.append("," + inputLineCount); + } out.append(":" + outputStartLine); - if (outputLineIncrement != 1) + if (outputLineIncrement != 1) { out.append("," + outputLineIncrement); + } out.append('\n'); return out.toString(); } @@ -244,17 +253,19 @@ public class SmapStratum { int outputLineIncrement) { // check the input - what are you doing here?? int fileIndex = filePathList.indexOf(inputFileName); - if (fileIndex == -1) // still + if (fileIndex == -1) { throw new IllegalArgumentException( "inputFileName: " + inputFileName); + } //Jasper incorrectly SMAPs certain Nodes, giving them an //outputStartLine of 0. This can cause a fatal error in //optimizeLineSection, making it impossible for Jasper to //compile the JSP. Until we can fix the underlying //SMAPping problem, we simply ignore the flawed SMAP entries. - if (outputStartLine == 0) + if (outputStartLine == 0) { return; + } // build the LineInfo LineInfo li = new LineInfo(); @@ -262,8 +273,9 @@ public class SmapStratum { li.setInputLineCount(inputLineCount); li.setOutputStartLine(outputStartLine); li.setOutputLineIncrement(outputLineIncrement); - if (fileIndex != lastFileID) + if (fileIndex != lastFileID) { li.setLineFileID(fileIndex); + } lastFileID = fileIndex; // save it diff --git a/java/org/apache/jasper/compiler/SmapUtil.java b/java/org/apache/jasper/compiler/SmapUtil.java index 86d2187..ca671f5 100644 --- a/java/org/apache/jasper/compiler/SmapUtil.java +++ b/java/org/apache/jasper/compiler/SmapUtil.java @@ -224,8 +224,9 @@ public class SmapUtil { copy(4 + 2 + 2); // magic min/maj version int constantPoolCountPos = genPos; int constantPoolCount = readU2(); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("constant pool count: " + constantPoolCount); + } writeU2(constantPoolCount); // copy old constant pool return index of SDE symbol, if found @@ -239,32 +240,37 @@ public class SmapUtil { ++constantPoolCount; randomAccessWriteU2(constantPoolCountPos, constantPoolCount); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("SourceDebugExtension not found, installed at: " + sdeIndex); + } } else { - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("SourceDebugExtension found at: " + sdeIndex); + } } copy(2 + 2 + 2); // access, this, super int interfaceCount = readU2(); writeU2(interfaceCount); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("interfaceCount: " + interfaceCount); + } copy(interfaceCount * 2); copyMembers(); // fields copyMembers(); // methods int attrCountPos = genPos; int attrCount = readU2(); writeU2(attrCount); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("class attrCount: " + attrCount); + } // copy the class attributes, return true if SDE attr found (not copied) if (!copyAttrs(attrCount)) { // we will be adding SDE and it isn't already counted ++attrCount; randomAccessWriteU2(attrCountPos, attrCount); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("class attrCount incremented"); + } } writeAttrForSDE(sdeIndex); } @@ -272,14 +278,16 @@ public class SmapUtil { void copyMembers() { int count = readU2(); writeU2(count); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("members count: " + count); + } for (int i = 0; i < count; ++i) { copy(6); // access, name, descriptor int attrCount = readU2(); writeU2(attrCount); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("member attr count: " + attrCount); + } copyAttrs(attrCount); } } @@ -291,15 +299,17 @@ public class SmapUtil { // don't write old SDE if (nameIndex == sdeIndex) { sdeFound = true; - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("SDE attr found"); + } } else { writeU2(nameIndex); // name int len = readU4(); writeU4(len); copy(len); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug("attr len: " + len); + } } } return sdeFound; @@ -379,13 +389,15 @@ public class SmapUtil { case 7 : // Class case 8 : // String case 16 : // MethodType - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug(i + " copying 2 bytes"); + } copy(2); break; case 15 : // MethodHandle - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug(i + " copying 3 bytes"); + } copy(3); break; case 9 : // Field @@ -395,14 +407,16 @@ public class SmapUtil { case 4 : // Float case 12 : // NameAndType case 18 : // InvokeDynamic - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug(i + " copying 4 bytes"); + } copy(4); break; case 5 : // Long case 6 : // Double - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug(i + " copying 8 bytes"); + } copy(8); i++; break; @@ -411,8 +425,9 @@ public class SmapUtil { writeU2(len); byte[] utf8 = readBytes(len); String str = new String(utf8, "UTF-8"); - if (log.isDebugEnabled()) + if (log.isDebugEnabled()) { log.debug(i + " read class attr -- '" + str + "'"); + } if (str.equals(nameSDE)) { sdeIndex = i; } diff --git a/java/org/apache/jasper/compiler/TagFileProcessor.java b/java/org/apache/jasper/compiler/TagFileProcessor.java index 7be773d..d76d433 100644 --- a/java/org/apache/jasper/compiler/TagFileProcessor.java +++ b/java/org/apache/jasper/compiler/TagFileProcessor.java @@ -262,8 +262,9 @@ class TagFileProcessor { err.jspError(n, "jsp.error.frgmentwithrtexprvalue"); } } else { - if (type == null) + if (type == null) { type = "java.lang.String"; + } if (deferredValue) { type = ValueExpression.class.getName(); @@ -309,13 +310,15 @@ class TagFileProcessor { } String className = n.getAttributeValue("variable-class"); - if (className == null) + if (className == null) { className = "java.lang.String"; + } String declareStr = n.getAttributeValue("declare"); boolean declare = true; - if (declareStr != null) + if (declareStr != null) { declare = JspUtil.booleanValue(declareStr); + } int scope = VariableInfo.NESTED; String scopeStr = n.getAttributeValue("scope"); diff --git a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java index a6f952d..949df62 100644 --- a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java +++ b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java @@ -385,8 +385,9 @@ class TagLibraryInfoImpl extends TagLibraryInfo implements TagConstants { */ public ValidationMessage[] validate(PageData thePage) { TagLibraryValidator tlv = getTagLibraryValidator(); - if (tlv == null) + if (tlv == null) { return null; + } String uri = getURI(); if (uri.startsWith("/")) { diff --git a/java/org/apache/jasper/compiler/TagPluginManager.java b/java/org/apache/jasper/compiler/TagPluginManager.java index b1ae5dc..99bc223 100644 --- a/java/org/apache/jasper/compiler/TagPluginManager.java +++ b/java/org/apache/jasper/compiler/TagPluginManager.java @@ -62,8 +62,9 @@ public class TagPluginManager { } private void init(ErrorDispatcher err) throws JasperException { - if (initialized) + if (initialized) { return; + } String blockExternalString = ctxt.getInitParameter( Constants.XML_BLOCK_EXTERNAL_INIT_PARAM); @@ -209,16 +210,18 @@ public class TagPluginManager { @Override public boolean isConstantAttribute(String attribute) { Node.JspAttribute attr = getNodeAttribute(attribute); - if (attr == null) + if (attr == null) { return false; + } return attr.isLiteral(); } @Override public String getConstantAttribute(String attribute) { Node.JspAttribute attr = getNodeAttribute(attribute); - if (attr == null) + if (attr == null) { return null; + } return attr.getValue(); } diff --git a/java/org/apache/jasper/compiler/Validator.java b/java/org/apache/jasper/compiler/Validator.java index 7805cd6..36107ba 100644 --- a/java/org/apache/jasper/compiler/Validator.java +++ b/java/org/apache/jasper/compiler/Validator.java @@ -197,8 +197,9 @@ class Validator { pageInfo.getInfo(), value); } } else if ("pageEncoding".equals(attr)) { - if (pageEncodingSeen) + if (pageEncodingSeen) { err.jspError(n, "jsp.error.page.multi.pageencoding"); + } // 'pageEncoding' can occur at most once per file pageEncodingSeen = true; String actual = comparePageEncodings(value, n); @@ -234,8 +235,9 @@ class Validator { } // Check for bad combinations - if (pageInfo.getBuffer() == 0 && !pageInfo.isAutoFlush()) + if (pageInfo.getBuffer() == 0 && !pageInfo.isAutoFlush()) { err.jspError(n, "jsp.error.page.badCombo"); + } // Attributes for imports for this node have been processed by // the parsers, just add them to pageInfo. @@ -270,8 +272,9 @@ class Validator { pageInfo.getIsELIgnored(), value); } } else if ("pageEncoding".equals(attr)) { - if (pageEncodingSeen) + if (pageEncodingSeen) { err.jspError(n, "jsp.error.tag.multi.pageencoding"); + } pageEncodingSeen = true; compareTagEncodings(value, n); n.getRoot().setPageEncoding(value); @@ -619,8 +622,9 @@ class Validator { boolean valueSpecified = n.getValue() != null; if ("*".equals(property)) { - if (param != null || valueSpecified) + if (param != null || valueSpecified) { err.jspError(n, "jsp.error.setProperty.invalid"); + } } else if (param != null && valueSpecified) { err.jspError(n, "jsp.error.setProperty.invalid"); @@ -640,23 +644,28 @@ class Validator { String type = n.getTextAttribute("type"); BeanRepository beanInfo = pageInfo.getBeanRepository(); - if (className == null && type == null) + if (className == null && type == null) { err.jspError(n, "jsp.error.usebean.missingType"); + } - if (beanInfo.checkVariable(name)) + if (beanInfo.checkVariable(name)) { err.jspError(n, "jsp.error.usebean.duplicate"); + } - if ("session".equals(scope) && !pageInfo.isSession()) + if ("session".equals(scope) && !pageInfo.isSession()) { err.jspError(n, "jsp.error.usebean.noSession"); + } Node.JspAttribute jattr = getJspAttribute(null, "beanName", null, null, n.getAttributeValue("beanName"), n, null, false); n.setBeanName(jattr); - if (className != null && jattr != null) + if (className != null && jattr != null) { err.jspError(n, "jsp.error.usebean.notBoth"); + } - if (className == null) + if (className == null) { className = type; + } beanInfo.addBean(n, name, className, scope); @@ -681,12 +690,15 @@ class Validator { throwErrorIfExpression(n, "iepluginurl", "jsp:plugin"); String type = n.getTextAttribute("type"); - if (type == null) + if (type == null) { err.jspError(n, "jsp.error.plugin.notype"); - if (!type.equals("bean") && !type.equals("applet")) + } + if (!type.equals("bean") && !type.equals("applet")) { err.jspError(n, "jsp.error.plugin.badtype"); - if (n.getTextAttribute("code") == null) + } + if (n.getTextAttribute("code") == null) { err.jspError(n, "jsp.error.plugin.nocode"); + } Node.JspAttribute width = getJspAttribute(null, "width", null, null, n.getAttributeValue("width"), n, null, false); @@ -736,8 +748,9 @@ class Validator { @Override public void visit(Node.ELExpression n) throws JasperException { // exit if we are ignoring EL all together - if (pageInfo.isELIgnored()) + if (pageInfo.isELIgnored()) { return; + } // JSP.2.2 - '#{' not allowed in template text if (n.getType() == '#') { @@ -1885,8 +1898,9 @@ class Validator { for (Object o : compiler.getPageInfo().getTaglibs()) { - if (!(o instanceof TagLibraryInfoImpl)) + if (!(o instanceof TagLibraryInfoImpl)) { continue; + } TagLibraryInfoImpl tli = (TagLibraryInfoImpl) o; ValidationMessage[] errors = tli.validate(xmlView); diff --git a/java/org/apache/jasper/el/ELContextWrapper.java b/java/org/apache/jasper/el/ELContextWrapper.java index 8c18293..4800ec6 100644 --- a/java/org/apache/jasper/el/ELContextWrapper.java +++ b/java/org/apache/jasper/el/ELContextWrapper.java @@ -45,7 +45,9 @@ public final class ELContextWrapper extends ELContext { @Override public FunctionMapper getFunctionMapper() { - if (this.fnMapper != null) return this.fnMapper; + if (this.fnMapper != null) { + return this.fnMapper; + } return this.target.getFunctionMapper(); } diff --git a/java/org/apache/jasper/el/JspMethodExpression.java b/java/org/apache/jasper/el/JspMethodExpression.java index ca6a384..c6f9fb4 100644 --- a/java/org/apache/jasper/el/JspMethodExpression.java +++ b/java/org/apache/jasper/el/JspMethodExpression.java @@ -54,13 +54,19 @@ public final class JspMethodExpression extends MethodExpression implements context.notifyAfterEvaluation(getExpressionString()); return result; } catch (MethodNotFoundException e) { - if (e instanceof JspMethodNotFoundException) throw e; + if (e instanceof JspMethodNotFoundException) { + throw e; + } throw new JspMethodNotFoundException(this.mark, e); } catch (PropertyNotFoundException e) { - if (e instanceof JspPropertyNotFoundException) throw e; + if (e instanceof JspPropertyNotFoundException) { + throw e; + } throw new JspPropertyNotFoundException(this.mark, e); } catch (ELException e) { - if (e instanceof JspELException) throw e; + if (e instanceof JspELException) { + throw e; + } throw new JspELException(this.mark, e); } } @@ -75,13 +81,19 @@ public final class JspMethodExpression extends MethodExpression implements context.notifyAfterEvaluation(getExpressionString()); return result; } catch (MethodNotFoundException e) { - if (e instanceof JspMethodNotFoundException) throw e; + if (e instanceof JspMethodNotFoundException) { + throw e; + } throw new JspMethodNotFoundException(this.mark, e); } catch (PropertyNotFoundException e) { - if (e instanceof JspPropertyNotFoundException) throw e; + if (e instanceof JspPropertyNotFoundException) { + throw e; + } throw new JspPropertyNotFoundException(this.mark, e); } catch (ELException e) { - if (e instanceof JspELException) throw e; + if (e instanceof JspELException) { + throw e; + } throw new JspELException(this.mark, e); } } diff --git a/java/org/apache/jasper/runtime/BodyContentImpl.java b/java/org/apache/jasper/runtime/BodyContentImpl.java index 0f3c11a..b368fa5 100644 --- a/java/org/apache/jasper/runtime/BodyContentImpl.java +++ b/java/org/apache/jasper/runtime/BodyContentImpl.java @@ -146,8 +146,9 @@ public class BodyContentImpl extends BodyContent { return; } - if (len >= bufferSize - nextChar) + if (len >= bufferSize - nextChar) { reAllocBuff (len); + } System.arraycopy(cbuf, off, cb, nextChar, len); nextChar+=len; @@ -183,8 +184,9 @@ public class BodyContentImpl extends BodyContent { writer.write(s, off, len); } else { ensureOpen(); - if (len >= bufferSize - nextChar) + if (len >= bufferSize - nextChar) { reAllocBuff(len); + } s.getChars(off, off + len, cb, nextChar); nextChar += len; @@ -367,7 +369,9 @@ public class BodyContentImpl extends BodyContent { */ @Override public void print(String s) throws IOException { - if (s == null) s = "null"; + if (s == null) { + s = "null"; + } if (writer != null) { writer.write(s); } else { diff --git a/java/org/apache/jasper/runtime/JspFactoryImpl.java b/java/org/apache/jasper/runtime/JspFactoryImpl.java index e815928..e8f7280 100644 --- a/java/org/apache/jasper/runtime/JspFactoryImpl.java +++ b/java/org/apache/jasper/runtime/JspFactoryImpl.java @@ -64,8 +64,9 @@ public class JspFactoryImpl extends JspFactory { @Override public void releasePageContext(PageContext pc) { - if( pc == null ) + if( pc == null ) { return; + } if( Constants.IS_SECURITY_ENABLED ) { PrivilegedReleasePageContext dp = new PrivilegedReleasePageContext( this,pc); diff --git a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java index 3a0cc1b..5b5c1c1 100644 --- a/java/org/apache/jasper/runtime/JspRuntimeLibrary.java +++ b/java/org/apache/jasper/runtime/JspRuntimeLibrary.java @@ -104,17 +104,19 @@ public class JspRuntimeLibrary { } public static boolean coerceToBoolean(String s) { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return false; - else + } else { return Boolean.parseBoolean(s); + } } public static byte coerceToByte(String s) { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return (byte) 0; - else + } else { return Byte.parseByte(s); + } } public static char coerceToChar(String s) { @@ -126,38 +128,43 @@ public class JspRuntimeLibrary { } public static double coerceToDouble(String s) { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return 0; - else + } else { return Double.parseDouble(s); + } } public static float coerceToFloat(String s) { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return 0; - else + } else { return Float.parseFloat(s); + } } public static int coerceToInt(String s) { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return 0; - else + } else { return Integer.parseInt(s); + } } public static short coerceToShort(String s) { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return (short) 0; - else + } else { return Short.parseShort(s); + } } public static long coerceToLong(String s) { - if (s == null || s.length() == 0) + if (s == null || s.length() == 0) { return 0; - else + } else { return Long.parseLong(s); + } } public static Object coerce(String s, Class<?> target) { @@ -170,43 +177,49 @@ public class JspRuntimeLibrary { } return Boolean.valueOf(s); } else if (target == Byte.class) { - if (isNullOrEmpty) + if (isNullOrEmpty) { return Byte.valueOf((byte) 0); - else + } else { return Byte.valueOf(s); + } } else if (target == Character.class) { - if (isNullOrEmpty) + if (isNullOrEmpty) { return Character.valueOf((char) 0); - else { + } else { @SuppressWarnings("null") Character result = Character.valueOf(s.charAt(0)); return result; } } else if (target == Double.class) { - if (isNullOrEmpty) + if (isNullOrEmpty) { return Double.valueOf(0); - else + } else { return Double.valueOf(s); + } } else if (target == Float.class) { - if (isNullOrEmpty) + if (isNullOrEmpty) { return Float.valueOf(0); - else + } else { return Float.valueOf(s); + } } else if (target == Integer.class) { - if (isNullOrEmpty) + if (isNullOrEmpty) { return Integer.valueOf(0); - else + } else { return Integer.valueOf(s); + } } else if (target == Short.class) { - if (isNullOrEmpty) + if (isNullOrEmpty) { return Short.valueOf((short) 0); - else + } else { return Short.valueOf(s); + } } else if (target == Long.class) { - if (isNullOrEmpty) + if (isNullOrEmpty) { return Long.valueOf(0); - else + } else { return Long.valueOf(s); + } } else { return null; } @@ -219,10 +232,11 @@ public class JspRuntimeLibrary { { try { if (s == null) { - if (t.equals(Boolean.class) || t.equals(Boolean.TYPE)) + if (t.equals(Boolean.class) || t.equals(Boolean.TYPE)) { s = "false"; - else + } else { return null; + } } if (propertyEditorClass != null) { return getValueFromBeanInfoPropertyEditor( @@ -337,7 +351,9 @@ public class JspRuntimeLibrary { Class<?> t = type.getComponentType(); String[] values = request.getParameterValues(param); //XXX Please check. - if(values == null) return; + if(values == null) { + return; + } if(t.equals(String.class)) { method.invoke(bean, new Object[] { values }); } else { @@ -345,10 +361,13 @@ public class JspRuntimeLibrary { propertyEditorClass); } } else { - if(value == null || (param != null && value.equals(""))) return; + if(value == null || (param != null && value.equals(""))) { + return; + } Object oval = convert(prop, value, type, propertyEditorClass); - if ( oval != null ) + if ( oval != null ) { method.invoke(bean, new Object[] { oval }); + } } } } catch (Exception ex) { @@ -445,83 +464,99 @@ public class JspRuntimeLibrary { method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(Integer.class)) { Integer []tmpval = new Integer[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Integer.valueOf(values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(Byte.class)) { Byte[] tmpval = new Byte[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Byte.valueOf(values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(Boolean.class)) { Boolean[] tmpval = new Boolean[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Boolean.valueOf(values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(Short.class)) { Short[] tmpval = new Short[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Short.valueOf(values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(Long.class)) { Long[] tmpval = new Long[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Long.valueOf(values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(Double.class)) { Double[] tmpval = new Double[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Double.valueOf(values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(Float.class)) { Float[] tmpval = new Float[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Float.valueOf(values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(Character.class)) { Character[] tmpval = new Character[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Character.valueOf(values[i].charAt(0)); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(int.class)) { int []tmpval = new int[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Integer.parseInt (values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(byte.class)) { byte[] tmpval = new byte[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Byte.parseByte (values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(boolean.class)) { boolean[] tmpval = new boolean[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Boolean.parseBoolean(values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(short.class)) { short[] tmpval = new short[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Short.parseShort (values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(long.class)) { long[] tmpval = new long[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Long.parseLong (values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(double.class)) { double[] tmpval = new double[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Double.parseDouble(values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(float.class)) { float[] tmpval = new float[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = Float.parseFloat(values[i]); + } method.invoke (bean, new Object[] {tmpval}); } else if (t.equals(char.class)) { char[] tmpval = new char[values.length]; - for (int i = 0 ; i < values.length; i++) + for (int i = 0 ; i < values.length; i++) { tmpval[i] = values[i].charAt(0); + } method.invoke (bean, new Object[] {tmpval}); } else { Object[] tmpval = new Integer[values.length]; @@ -894,10 +929,12 @@ public class JspRuntimeLibrary { public static String getContextRelativePath(ServletRequest request, String relativePath) { - if (relativePath.startsWith("/")) + if (relativePath.startsWith("/")) { return relativePath; - if (!(request instanceof HttpServletRequest)) + } + if (!(request instanceof HttpServletRequest)) { return relativePath; + } HttpServletRequest hrequest = (HttpServletRequest) request; String uri = (String) request.getAttribute( RequestDispatcher.INCLUDE_SERVLET_PATH); @@ -905,13 +942,15 @@ public class JspRuntimeLibrary { String pathInfo = (String) request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO); if (pathInfo == null) { - if (uri.lastIndexOf('/') >= 0) + if (uri.lastIndexOf('/') >= 0) { uri = uri.substring(0, uri.lastIndexOf('/')); + } } } else { uri = hrequest.getServletPath(); - if (uri.lastIndexOf('/') >= 0) + if (uri.lastIndexOf('/') >= 0) { uri = uri.substring(0, uri.lastIndexOf('/')); + } } return uri + '/' + relativePath; @@ -938,8 +977,9 @@ public class JspRuntimeLibrary { boolean flush) throws IOException, ServletException { - if (flush && !(out instanceof BodyContent)) + if (flush && !(out instanceof BodyContent)) { out.flush(); + } // FIXME - It is tempting to use request.getRequestDispatcher() to // resolve a relative path directly, but Catalina currently does not diff --git a/java/org/apache/jasper/runtime/JspWriterImpl.java b/java/org/apache/jasper/runtime/JspWriterImpl.java index 60cab2f..58cee61 100644 --- a/java/org/apache/jasper/runtime/JspWriterImpl.java +++ b/java/org/apache/jasper/runtime/JspWriterImpl.java @@ -65,8 +65,9 @@ public class JspWriterImpl extends JspWriter { public JspWriterImpl(ServletResponse response, int sz, boolean autoFlush) { super(sz, autoFlush); - if (sz < 0) + if (sz < 0) { throw new IllegalArgumentException(Localizer.getMessage("jsp.error.negativeBufferSize")); + } this.response = response; cb = sz == 0 ? null : new char[sz]; nextChar = 0; @@ -74,8 +75,9 @@ public class JspWriterImpl extends JspWriter { void init( ServletResponse response, int sz, boolean autoFlush ) { this.response= response; - if( sz > 0 && ( cb == null || sz > cb.length ) ) + if( sz > 0 && ( cb == null || sz > cb.length ) ) { cb=new char[sz]; + } nextChar = 0; this.autoFlush=autoFlush; this.bufferSize=sz; @@ -99,12 +101,14 @@ public class JspWriterImpl extends JspWriter { * @throws IOException Error writing buffered data */ protected final void flushBuffer() throws IOException { - if (bufferSize == 0) + if (bufferSize == 0) { return; + } flushed = true; ensureOpen(); - if (nextChar == 0) + if (nextChar == 0) { return; + } initOut(); out.write(cb, 0, nextChar); nextChar = 0; @@ -121,22 +125,25 @@ public class JspWriterImpl extends JspWriter { */ @Override public final void clear() throws IOException { - if ((bufferSize == 0) && (out != null)) + if ((bufferSize == 0) && (out != null)) { // clear() is illegal after any unbuffered output (JSP.5.5) throw new IllegalStateException( Localizer.getMessage("jsp.error.ise_on_clear")); - if (flushed) + } + if (flushed) { throw new IOException( Localizer.getMessage("jsp.error.attempt_to_clear_flushed_buffer")); + } ensureOpen(); nextChar = 0; } @Override public void clearBuffer() throws IOException { - if (bufferSize == 0) + if (bufferSize == 0) { throw new IllegalStateException( Localizer.getMessage("jsp.error.ise_on_clear")); + } ensureOpen(); nextChar = 0; } @@ -163,12 +170,14 @@ public class JspWriterImpl extends JspWriter { */ @Override public void close() throws IOException { - if (response == null || closed) + if (response == null || closed) { // multiple calls to close is OK return; + } flush(); - if (out != null) + if (out != null) { out.close(); + } out = null; closed = true; } @@ -183,8 +192,9 @@ public class JspWriterImpl extends JspWriter { /** check to make sure that the stream has not been closed */ private void ensureOpen() throws IOException { - if (response == null || closed) + if (response == null || closed) { throw new IOException(Localizer.getMessage("jsp.error.stream.closed")); + } } @@ -198,11 +208,13 @@ public class JspWriterImpl extends JspWriter { initOut(); out.write(c); } else { - if (nextChar >= bufferSize) - if (autoFlush) + if (nextChar >= bufferSize) { + if (autoFlush) { flushBuffer(); - else + } else { bufferOverflow(); + } + } cb[nextChar++] = (char) c; } } @@ -212,7 +224,9 @@ public class JspWriterImpl extends JspWriter { * out of file descriptors and we're trying to print a stack trace. */ private static int min(int a, int b) { - if (a < b) return a; + if (a < b) { + return a; + } return b; } @@ -253,10 +267,11 @@ public class JspWriterImpl extends JspWriter { /* If the request length exceeds the size of the output buffer, flush the buffer and then write the data directly. In this way buffered streams will cascade harmlessly. */ - if (autoFlush) + if (autoFlush) { flushBuffer(); - else + } else { bufferOverflow(); + } initOut(); out.write(cbuf, off, len); return; @@ -268,11 +283,13 @@ public class JspWriterImpl extends JspWriter { System.arraycopy(cbuf, b, cb, nextChar, d); b += d; nextChar += d; - if (nextChar >= bufferSize) - if (autoFlush) + if (nextChar >= bufferSize) { + if (autoFlush) { flushBuffer(); - else + } else { bufferOverflow(); + } + } } } @@ -307,11 +324,13 @@ public class JspWriterImpl extends JspWriter { s.getChars(b, b + d, cb, nextChar); b += d; nextChar += d; - if (nextChar >= bufferSize) - if (autoFlush) + if (nextChar >= bufferSize) { + if (autoFlush) { flushBuffer(); - else + } else { bufferOverflow(); + } + } } } diff --git a/java/org/apache/jasper/runtime/PageContextImpl.java b/java/org/apache/jasper/runtime/PageContextImpl.java index 2339c63..054df66 100644 --- a/java/org/apache/jasper/runtime/PageContextImpl.java +++ b/java/org/apache/jasper/runtime/PageContextImpl.java @@ -129,10 +129,12 @@ public class PageContextImpl extends PageContext { this.applicationContext = JspApplicationContextImpl.getInstance(context); // Setup session (if required) - if (request instanceof HttpServletRequest && needsSession) + if (request instanceof HttpServletRequest && needsSession) { this.session = ((HttpServletRequest) request).getSession(); - if (needsSession && session == null) + } + if (needsSession && session == null) { throw new IllegalStateException(Localizer.getMessage("jsp.error.page.sessionRequired")); + } // initialize the initial out ... depth = -1; @@ -151,8 +153,9 @@ public class PageContextImpl extends PageContext { setAttribute(REQUEST, request); setAttribute(RESPONSE, response); - if (session != null) + if (session != null) { setAttribute(SESSION, session); + } setAttribute(PAGE, servlet); setAttribute(CONFIG, config); @@ -324,8 +327,9 @@ public class PageContextImpl extends PageContext { if (session != null) { try { - if (session.getAttribute(name) != null) + if (session.getAttribute(name) != null) { return SESSION_SCOPE; + } } catch(IllegalStateException ise) { // Session has been invalidated. // Ignore and fall through to application scope. @@ -474,8 +478,9 @@ public class PageContextImpl extends PageContext { if (!path.startsWith("/")) { String uri = (String) request.getAttribute( RequestDispatcher.INCLUDE_SERVLET_PATH); - if (uri == null) + if (uri == null) { uri = ((HttpServletRequest) request).getServletPath(); + } String baseURI = uri.substring(0, uri.lastIndexOf('/')); path = baseURI + '/' + path; } @@ -522,8 +527,9 @@ public class PageContextImpl extends PageContext { final String path = getAbsolutePathRelativeToContext(relativeUrlPath); String includeUri = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH); - if (includeUri != null) + if (includeUri != null) { request.removeAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH); + } try { context.getRequestDispatcher(path).forward(request, response); } finally { @@ -643,12 +649,15 @@ public class PageContextImpl extends PageContext { // Otherwise throw the exception wrapped inside a ServletException. // Set the exception as the root cause in the ServletException // to get a stack trace for the real problem - if (t instanceof IOException) + if (t instanceof IOException) { throw (IOException) t; - if (t instanceof ServletException) + } + if (t instanceof ServletException) { throw (ServletException) t; - if (t instanceof RuntimeException) + } + if (t instanceof RuntimeException) { throw (RuntimeException) t; + } Throwable rootCause = null; if (t instanceof JspException || t instanceof ELException || diff --git a/java/org/apache/jasper/runtime/TagHandlerPool.java b/java/org/apache/jasper/runtime/TagHandlerPool.java index 6a753cc..dbc55f8 100644 --- a/java/org/apache/jasper/runtime/TagHandlerPool.java +++ b/java/org/apache/jasper/runtime/TagHandlerPool.java @@ -53,8 +53,9 @@ public class TagHandlerPool { result = null; } } - if (result == null) + if (result == null) { result = new TagHandlerPool(); + } result.init(config); return result; @@ -155,17 +156,21 @@ public class TagHandlerPool { protected static String getOption(ServletConfig config, String name, String defaultV) { - if (config == null) + if (config == null) { return defaultV; + } String value = config.getInitParameter(name); - if (value != null) + if (value != null) { return value; - if (config.getServletContext() == null) + } + if (config.getServletContext() == null) { return defaultV; + } value = config.getServletContext().getInitParameter(name); - if (value != null) + if (value != null) { return value; + } return defaultV; } diff --git a/java/org/apache/jasper/servlet/JasperLoader.java b/java/org/apache/jasper/servlet/JasperLoader.java index 4f37939..f8accc4 100644 --- a/java/org/apache/jasper/servlet/JasperLoader.java +++ b/java/org/apache/jasper/servlet/JasperLoader.java @@ -93,8 +93,9 @@ public class JasperLoader extends URLClassLoader { // (0) Check our previously loaded class cache clazz = findLoadedClass(name); if (clazz != null) { - if (resolve) + if (resolve) { resolveClass(clazz); + } return clazz; } @@ -120,8 +121,9 @@ public class JasperLoader extends URLClassLoader { // Class is not in org.apache.jsp, therefore, have our // parent load it clazz = getParent().loadClass(name); - if( resolve ) + if( resolve ) { resolveClass(clazz); + } return clazz; } diff --git a/java/org/apache/jasper/servlet/JspCServletContext.java b/java/org/apache/jasper/servlet/JspCServletContext.java index 3b49202..d2b3231 100644 --- a/java/org/apache/jasper/servlet/JspCServletContext.java +++ b/java/org/apache/jasper/servlet/JspCServletContext.java @@ -340,10 +340,12 @@ public class JspCServletContext implements ServletContext { */ @Override public String getRealPath(String path) { - if (!myResourceBaseURL.getProtocol().equals("file")) + if (!myResourceBaseURL.getProtocol().equals("file")) { return null; - if (!path.startsWith("/")) + } + if (!path.startsWith("/")) { return null; + } try { File f = new File(getResource(path).toURI()); return f.getAbsolutePath(); diff --git a/java/org/apache/jasper/servlet/JspServlet.java b/java/org/apache/jasper/servlet/JspServlet.java index de069ef..6073d46 100644 --- a/java/org/apache/jasper/servlet/JspServlet.java +++ b/java/org/apache/jasper/servlet/JspServlet.java @@ -139,7 +139,9 @@ public class JspServlet extends HttpServlet implements PeriodicEventListener { throw new ServletException(Localizer.getMessage("jsp.error.precompilation", jspFile), e); } catch (PrivilegedActionException e) { Throwable t = e.getCause(); - if (t instanceof ServletException) throw (ServletException)t; + if (t instanceof ServletException) { + throw (ServletException)t; + } throw new ServletException(Localizer.getMessage("jsp.error.precompilation", jspFile), e); } } diff --git a/java/org/apache/jasper/tagplugins/jstl/Util.java b/java/org/apache/jasper/tagplugins/jstl/Util.java index 7b75d16..a8d0b27 100644 --- a/java/org/apache/jasper/tagplugins/jstl/Util.java +++ b/java/org/apache/jasper/tagplugins/jstl/Util.java @@ -128,10 +128,14 @@ public class Util { int begin; int end; int index = input.toUpperCase(Locale.ENGLISH).indexOf(name.toUpperCase(Locale.ENGLISH)); - if (index == -1) return null; + if (index == -1) { + return null; + } index = index + name.length(); // positioned after the attribute name index = input.indexOf('=', index); // positioned at the '=' - if (index == -1) return null; + if (index == -1) { + return null; + } index += 1; // positioned after the '=' input = input.substring(index).trim(); @@ -139,12 +143,18 @@ public class Util { // attribute value is a quoted string begin = 1; end = input.indexOf('"', begin); - if (end == -1) return null; + if (end == -1) { + return null; + } } else { begin = 0; end = input.indexOf(';'); - if (end == -1) end = input.indexOf(' '); - if (end == -1) end = input.length(); + if (end == -1) { + end = input.indexOf(' '); + } + if (end == -1) { + end = input.length(); + } } return input.substring(begin, end).trim(); } @@ -247,17 +257,19 @@ public class Util { String url, String context, PageContext pageContext) throws JspException { // don't touch absolute URLs - if (isAbsoluteUrl(url)) + if (isAbsoluteUrl(url)) { return url; + } // normalize relative URLs against a context root HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); if (context == null) { - if (url.startsWith("/")) + if (url.startsWith("/")) { return request.getContextPath() + url; - else + } else { return url; + } } else { if (!context.startsWith("/") || !url.startsWith("/")) { throw new JspTagException(Localizer.getMessage("jstl.urlMustStartWithSlash")); @@ -312,16 +324,18 @@ public class Util { @Override public PrintWriter getWriter() { - if (isStreamUsed) + if (isStreamUsed) { throw new IllegalStateException(Localizer.getMessage("jstl.writerAfterOS")); + } isWriterUsed = true; return new PrintWriter(sw); } @Override public ServletOutputStream getOutputStream() { - if (isWriterUsed) + if (isWriterUsed) { throw new IllegalStateException(Localizer.getMessage("jstl.OSAfterWriter")); + } isStreamUsed = true; return sos; } @@ -355,15 +369,18 @@ public class Util { } public String getString() throws UnsupportedEncodingException { - if (isWriterUsed) + if (isWriterUsed) { return sw.toString(); - else if (isStreamUsed) { - if (this.charEncoding != null && !this.charEncoding.equals("")) + } else if (isStreamUsed) { + if (this.charEncoding != null && !this.charEncoding.equals("")) { return bos.toString(charEncoding); - else + } else { return bos.toString("ISO-8859-1"); - } else + } + } + else { return ""; // target didn't write anything + } } } diff --git a/res/checkstyle/checkstyle.xml b/res/checkstyle/checkstyle.xml index 75a7a3a..a13f048 100644 --- a/res/checkstyle/checkstyle.xml +++ b/res/checkstyle/checkstyle.xml @@ -53,7 +53,7 @@ <module name="AvoidNestedBlocks"> <property name="allowInSwitchCase" value="true"/> </module> - <!-- ~1000 errors + <!-- ~650 errors <module name="NeedBraces"/> --> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org