Skip to content

Commit 034ed24

Browse files
authored
Fixed: String comparison (OFBIZ-13320) #926
In several locations strings are compared with == and != Should be compared with equals, unless they are interned. But even for interned strings equals() is safe Thanks: Dmitriy Kryukov --------- Signed-off-by: Dmitry Kryukov <dk2k@ya.ru>
1 parent 45f6a3e commit 034ed24

5 files changed

Lines changed: 7 additions & 6 deletions

File tree

applications/accounting/src/main/java/org/apache/ofbiz/accounting/thirdparty/eway/GatewayResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public GatewayResponse(InputStream xmlstream, GatewayRequest req) throws Excepti
185185
Node rootnode = doc.getDocumentElement();
186186
String root = rootnode.getNodeName();
187187

188-
if ("ewayResponse" != root) {
188+
if (!"ewayResponse".equals(root)) {
189189
throw new Exception("Bad root element in response: " + root);
190190
}
191191

@@ -195,7 +195,7 @@ public GatewayResponse(InputStream xmlstream, GatewayRequest req) throws Excepti
195195
for (int i = 0; i < length; i++) {
196196
Node node = list.item(i);
197197
String name = node.getNodeName();
198-
if ("ewayResponse" == name) {
198+
if ("ewayResponse".equals(name)) {
199199
continue;
200200
}
201201
Text textnode = (Text) node.getFirstChild();

framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.HashSet;
2626
import java.util.List;
2727
import java.util.Map;
28+
import java.util.Objects;
2829
import java.util.Set;
2930
import java.util.concurrent.Callable;
3031
import java.util.concurrent.Future;
@@ -260,7 +261,7 @@ private static Host prepareVirtualHost(Tomcat tomcat, List<String> virtualHosts)
260261
}
261262

262263
virtualHosts.stream()
263-
.filter(virtualHost -> virtualHost != hostName).forEach(virtualHost -> host.addAlias(virtualHost));
264+
.filter(virtualHost -> !Objects.equals(virtualHost, hostName)).forEach(virtualHost -> host.addAlias(virtualHost));
264265

265266
return host;
266267
}

framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ public void doRequest(HttpServletRequest request, HttpServletResponse response,
10421042
* @param requestResponse
10431043
*/
10441044
private void setUserMessageResponseToRequest(HttpServletRequest request, ConfigXMLReader.RequestResponse requestResponse) {
1045-
final String fieldMessageName = requestResponse.getName() == "error"
1045+
final String fieldMessageName = "error".equals(requestResponse.getName())
10461046
? "_ERROR_MESSAGE_"
10471047
: "_EVENT_MESSAGE_";
10481048
final String customMessageField = "_CUSTOM" + fieldMessageName;

framework/widget/src/main/java/org/apache/ofbiz/widget/model/CommonWidgetModels.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ public Link(Element linkElement) {
400400
} else {
401401
Node formElement = autoFormParamsElement;
402402
while (formElement != null
403-
&& formElement.getLocalName() != "form") {
403+
&& !"form".equals(formElement.getLocalName())) {
404404
formElement = formElement.getParentNode();
405405
}
406406
if (formElement != null && formElement.getLocalName() != null) {

framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelForm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2323,7 +2323,7 @@ public UpdateArea(Element updateAreaElement, String defaultServiceName, String d
23232323
} else {
23242324
Node formElement = autoFormParamsElement;
23252325
while (formElement != null
2326-
&& formElement.getLocalName() != "form") {
2326+
&& !"form".equals(formElement.getLocalName())) {
23272327
formElement = formElement.getParentNode();
23282328
}
23292329
if (formElement != null && formElement.getLocalName() != null) {

0 commit comments

Comments
 (0)