Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java/org/apache/catalina/ant/jmx/JMXAccessorCondition.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void setUnless(String c) {
* @return true if there is no if condition, or the named property exists
*/
protected boolean testIfCondition() {
if (ifCondition == null || "".equals(ifCondition)) {
if (ifCondition == null || ifCondition.isEmpty()) {
return true;
}
return getProject().getProperty(ifCondition) != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected void jmxCreate(MBeanServerConnection jmxServerConnection,
}
}
}
if (classLoader != null && !"".equals(classLoader)) {
if (classLoader != null && !classLoader.isEmpty()) {
if (isEcho()) {
handleOutput("create MBean " + name + " from class "
+ className + " with classLoader " + classLoader);
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/catalina/ant/jmx/JMXAccessorTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void setPort(String port) {
* @return Returns the useRef.
*/
public boolean isUseRef() {
return ref != null && !"".equals(ref);
return ref != null && !ref.isEmpty();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/catalina/core/ApplicationContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ public void declareRoles(String... roleNames) {
}

for (String role : roleNames) {
if (role == null || "".equals(role)) {
if (role == null || role.isEmpty()) {
throw new IllegalArgumentException(
sm.getString("applicationContext.role.iae",
getContextPath()));
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/catalina/core/StandardContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -2136,7 +2136,7 @@ public void setPath(String path) {
if (path == null || path.equals("/")) {
invalid = true;
this.path = "";
} else if ("".equals(path) || path.startsWith("/")) {
} else if (path.isEmpty() || path.startsWith("/")) {
this.path = path;
} else {
invalid = true;
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/catalina/core/StandardEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public void containerEvent(ContainerEvent event) {
if (disabled) return;
if (Container.ADD_CHILD_EVENT.equals(event.getType())) {
Context context = (Context) event.getData();
if ("".equals(context.getPath())) {
if (context.getPath().isEmpty()) {
// Force re-calculation and disable listener since it won't
// be re-used
engine.defaultAccessLog.set(null);
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/catalina/filters/WebdavFixFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void doFilter(ServletRequest request, ServletResponse response,
httpResponse.sendRedirect(buildRedirect(httpRequest));
} else if (ua.startsWith(UA_MINIDIR_5_2_3790)) {
// XP 64-bit SP2
if (!"".equals(httpRequest.getContextPath())) {
if (!httpRequest.getContextPath().isEmpty()) {
getServletContext().log(sm.getString("webDavFilter.xpRootContext"));
}
// Namespace issue maybe
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/catalina/ha/backend/TcpSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public int send(String mess) throws Exception {
// read all the headers.
String header = connectionReaders[i].readLine();
int contentLength = 0;
while (!"".equals(header)) {
while (!header.isEmpty()) {
int colon = header.indexOf(':');
String headerName = header.substring(0, colon).trim();
String headerValue = header.substring(colon + 1).trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ protected void changeRequestSessionID(Request request, String sessionId, String

// set original sessionid at request, to allow application detect the
// change
if (sessionIdAttribute != null && !"".equals(sessionIdAttribute)) {
if (sessionIdAttribute != null && !sessionIdAttribute.isEmpty()) {
if (log.isDebugEnabled()) {
log.debug(sm.getString("jvmRoute.set.orignalsessionid",sessionIdAttribute,sessionId));
}
Expand Down
9 changes: 5 additions & 4 deletions java/org/apache/catalina/manager/HTMLManagerServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,10 +443,11 @@ protected void list(HttpServletRequest request,
StringBuilder tmp = new StringBuilder();
tmp.append("path=");
tmp.append(URLEncoder.DEFAULT.encode(displayPath, StandardCharsets.UTF_8));
if (ctxt.getWebappVersion().length() > 0) {
final String webappVersion = ctxt.getWebappVersion();
if (webappVersion != null && webappVersion.length() > 0) {
tmp.append("&version=");
tmp.append(URLEncoder.DEFAULT.encode(
ctxt.getWebappVersion(), StandardCharsets.UTF_8));
webappVersion, StandardCharsets.UTF_8));
}
String pathVersion = tmp.toString();

Expand All @@ -463,10 +464,10 @@ protected void list(HttpServletRequest request,
+ URLEncoder.DEFAULT.encode(contextPath + "/", StandardCharsets.UTF_8)
+ "\" " + Constants.REL_EXTERNAL + ">"
+ Escape.htmlElementContent(displayPath) + "</a>";
if ("".equals(ctxt.getWebappVersion())) {
if (webappVersion == null || webappVersion.isEmpty()) {
args[1] = noVersion;
} else {
args[1] = Escape.htmlElementContent(ctxt.getWebappVersion());
args[1] = Escape.htmlElementContent(webappVersion);
}
if (ctxt.getDisplayName() == null) {
args[2] = "&nbsp;";
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/catalina/manager/ManagerServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ protected void findleaks(boolean statusLine, PrintWriter writer,
smClient.getString("managerServlet.findleaksList"));
}
for (String result : results) {
if ("".equals(result)) {
if (result.isEmpty()) {
result = "/";
}
writer.println(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public void init() throws ServletException {
host.addLifecycleListener(new HostConfig());

// Add host aliases
if ((aliases != null) && !("".equals(aliases))) {
if ((aliases != null) && !aliases.isEmpty()) {
StringTokenizer tok = new StringTokenizer(aliases, ", ");
while (tok.hasMoreTokens()) {
host.addAlias(tok.nextToken());
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/catalina/realm/RealmBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ public String toString() {

private static X509UsernameRetriever createUsernameRetriever(String className)
throws LifecycleException {
if(null == className || "".equals(className.trim()))
if(null == className || className.trim().isEmpty())
return new X509SubjectDnRetriever();

try {
Expand Down
8 changes: 4 additions & 4 deletions java/org/apache/catalina/servlets/CGIServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ protected boolean setCGIEnvironment(HttpServletRequest req) throws IOException {
* SHOULD NOT be defined.
*
*/
if (!("".equals(sPathInfoCGI))) {
if (!sPathInfoCGI.isEmpty()) {
sPathTranslatedCGI = context.getRealPath(sPathInfoCGI);
}
if (sPathTranslatedCGI == null || "".equals(sPathTranslatedCGI)) {
Expand Down Expand Up @@ -1386,9 +1386,9 @@ protected String nullsToString(String couldBeNull,
*/
protected String blanksToString(String couldBeBlank,
String subForBlanks) {
return (("".equals(couldBeBlank) || couldBeBlank == null)
return (couldBeBlank == null || couldBeBlank.isEmpty())
? subForBlanks
: couldBeBlank);
: couldBeBlank;
}


Expand Down Expand Up @@ -1689,7 +1689,7 @@ public void run () {
try {
//set headers
String line = null;
while (((line = cgiHeaderReader.readLine()) != null) && !("".equals(line))) {
while (((line = cgiHeaderReader.readLine()) != null) && !line.isEmpty()) {
if (log.isTraceEnabled()) {
log.trace("addHeader(\"" + line + "\")");
}
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/catalina/session/JDBCStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public String getSessionLastAccessedCol() {
* @param dataSourceName The JNDI name of the DataSource-factory
*/
public void setDataSourceName(String dataSourceName) {
if (dataSourceName == null || "".equals(dataSourceName.trim())) {
if (dataSourceName == null || dataSourceName.trim().isEmpty()) {
manager.getContext().getLogger().warn(
sm.getString(getStoreName() + ".missingDataSourceName"));
return;
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/catalina/storeconfig/StoreRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public IStoreFactory findStoreFactory(Class<?> aClass) {
*/
public void registerDescription(StoreDescription desc) {
String key = desc.getId();
if (key == null || "".equals(key)) {
if (key == null || key.isEmpty()) {
key = desc.getTagClass();
}
descriptors.put(key, desc);
Expand Down
18 changes: 9 additions & 9 deletions java/org/apache/catalina/util/ContextName.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public final class ContextName {
public static final String ROOT_NAME = "ROOT";
private static final String VERSION_MARKER = "##";
private static final String FWD_SLASH_REPLACEMENT = "#";
private static final char FWD_SLASH_REPLACEMENT = '#';

private final String baseName;
private final String path;
Expand Down Expand Up @@ -54,10 +54,10 @@ public ContextName(String name, boolean stripFileExtension) {
}

// Replace any remaining /
tmp1 = tmp1.replaceAll("/", FWD_SLASH_REPLACEMENT);
tmp1 = tmp1.replace('/', FWD_SLASH_REPLACEMENT);

// Insert the ROOT name if required
if (tmp1.startsWith(VERSION_MARKER) || "".equals(tmp1)) {
if (tmp1.startsWith(VERSION_MARKER) || tmp1.isEmpty()) {
tmp1 = ROOT_NAME + tmp1;
}

Expand All @@ -84,7 +84,7 @@ public ContextName(String name, boolean stripFileExtension) {
if (ROOT_NAME.equals(tmp2)) {
path = "";
} else {
path = "/" + tmp2.replaceAll(FWD_SLASH_REPLACEMENT, "/");
path = "/" + tmp2.replace(FWD_SLASH_REPLACEMENT, '/');
}

if (versionIndex > -1) {
Expand Down Expand Up @@ -116,21 +116,21 @@ public ContextName(String path, String version) {
}

// Name is path + version
if ("".equals(this.version)) {
if (this.version.isEmpty()) {
name = this.path;
} else {
name = this.path + VERSION_MARKER + this.version;
}

// Base name is converted path + version
StringBuilder tmp = new StringBuilder();
if ("".equals(this.path)) {
if (this.path.isEmpty()) {
tmp.append(ROOT_NAME);
} else {
tmp.append(this.path.substring(1).replaceAll("/",
tmp.append(this.path.substring(1).replace('/',
FWD_SLASH_REPLACEMENT));
}
if (this.version.length() > 0) {
if (!this.version.isEmpty()) {
tmp.append(VERSION_MARKER);
tmp.append(this.version);
}
Expand Down Expand Up @@ -161,7 +161,7 @@ public String getDisplayName() {
tmp.append(path);
}

if (!"".equals(version)) {
if (!version.isEmpty()) {
tmp.append(VERSION_MARKER);
tmp.append(version);
}
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/el/MethodExpressionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
this.expr = in.readUTF();
String type = in.readUTF();
if (!"".equals(type)) {
if (!type.isEmpty()) {
this.expectedType = ReflectionUtil.forName(type);
}
this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/el/MethodExpressionLiteral.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public boolean isLiteralText() {
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
this.expr = in.readUTF();
String type = in.readUTF();
if (!"".equals(type)) {
if (!type.isEmpty()) {
this.expectedType = ReflectionUtil.forName(type);
}
this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/el/ValueExpressionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
this.expr = in.readUTF();
String type = in.readUTF();
if (!"".equals(type)) {
if (!type.isEmpty()) {
this.expectedType = ReflectionUtil.forName(type);
}
this.fnMapper = (FunctionMapper) in.readObject();
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/el/ValueExpressionLiteral.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
this.value = in.readObject();
String type = in.readUTF();
if (!"".equals(type)) {
if (!type.isEmpty()) {
this.expectedType = ReflectionUtil.forName(type);
}
}
Expand Down
7 changes: 4 additions & 3 deletions java/org/apache/el/lang/ELSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -540,19 +540,20 @@ public static final Object coerceToType(final ELContext ctx, final Object obj,
if (obj == null)
return null;
if (obj instanceof String) {
String str = (String) obj;
PropertyEditor editor = PropertyEditorManager.findEditor(type);
if (editor == null) {
if ("".equals(obj)) {
if (str.isEmpty()) {
return null;
}
throw new ELException(MessageFactory.get("error.convert", obj,
obj.getClass(), type));
} else {
try {
editor.setAsText((String) obj);
editor.setAsText(str);
return editor.getValue();
} catch (RuntimeException e) {
if ("".equals(obj)) {
if (str.isEmpty()) {
return null;
}
throw new ELException(MessageFactory.get("error.convert",
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/el/lang/FunctionMapperImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {

this.prefix = in.readUTF();
if ("".equals(this.prefix)) this.prefix = null;
if (this.prefix.isEmpty()) this.prefix = null;
this.localName = in.readUTF();
this.owner = in.readUTF();
this.name = in.readUTF();
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/el/util/ReflectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private ReflectionUtil() {
}

public static Class<?> forName(String name) throws ClassNotFoundException {
if (null == name || "".equals(name)) {
if (null == name || name.isEmpty()) {
return null;
}
Class<?> c = forNamePrimitive(name);
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/jasper/JspC.java
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ public void generateWebMapping( String file, JspCompilationContext clctxt )
String packageName = clctxt.getServletPackageName();

String thisServletName;
if ("".equals(packageName)) {
if (packageName.isEmpty()) {
thisServletName = className;
} else {
thisServletName = packageName + '.' + className;
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/jasper/compiler/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ private void generateDestroy() {
* preamble generation)
*/
private void genPreamblePackage(String packageName) {
if (!"".equals(packageName) && packageName != null) {
if (packageName != null && !packageName.isEmpty()) {
out.printil("package " + packageName + ";");
out.println();
}
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/jasper/compiler/Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ private String[] getParameters(ELNode.Function func)
lastArg = true;
}
String arg = signature.substring(start, p).trim();
if (!"".equals(arg)) {
if (!arg.isEmpty()) {
params.add(arg);
}
if (lastArg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void begin(String namespace, String theName, Attributes attributes)

for (int i = 0; i < attributes.getLength(); i++) {
String name = attributes.getLocalName(i);
if ("".equals(name)) {
if (name.isEmpty()) {
name = attributes.getQName(i);
}
String value = attributes.getValue(i);
Expand Down
2 changes: 1 addition & 1 deletion java/org/apache/tomcat/util/net/SSLUtilBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static KeyStore getStore(String type, String provider, String path,
// Some key store types (e.g. hardware) expect the InputStream
// to be null
if(!("PKCS11".equalsIgnoreCase(type) ||
"".equalsIgnoreCase(path)) ||
path.isEmpty()) ||
"NONE".equalsIgnoreCase(path)) {
istream = ConfigFileLoader.getSource().getResource(path).getInputStream();
}
Expand Down
3 changes: 2 additions & 1 deletion java/org/apache/tomcat/websocket/WsWebSocketContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,8 @@ private static ByteBuffer createRequest(URI uri, Map<String,List<String>> reqHea

// Request line
result.put(GET_BYTES);
if (null == uri.getPath() || "".equals(uri.getPath())) {
final String path = uri.getPath();
if (null == path || path.isEmpty()) {
result.put(ROOT_URI_BYTES);
} else {
result.put(uri.getRawPath().getBytes(StandardCharsets.ISO_8859_1));
Expand Down