This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-jsp.git

commit 5bf1dcdc08eddd234a32f366bafbd1c313db2400
Author: Haris Adzemovic <[email protected]>
AuthorDate: Thu Nov 7 15:30:27 2019 +0100

    Strings and Boxed types should be compared using "equals()"
    
    This fixes 8 Sonarqube violations of rule S4973:
    https://rules.sonarsource.com/java/RSPEC-4973
    
    Sonarcloud violation URL:
    
https://sonarcloud.io/organizations/apache/issues?languages=java&open=AWpBn7x7o4hEA1R-5PL7&resolved=false&rules=squid%3AS4973&types=BUG
    
    Jira Ticket:
    https://issues.apache.org/jira/browse/SLING-8825
---
 .../sling/scripting/jsp/jasper/compiler/TagFileProcessor.java  |  4 ++--
 .../scripting/jsp/jasper/xmlparser/XMLEncodingDetector.java    | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
 
b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
index 57f3d4b..ba8ad44 100644
--- 
a/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
+++ 
b/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
@@ -445,10 +445,10 @@ class TagFileProcessor {
         private void checkUniqueName(String name, String type, Node n,
                 TagAttributeInfo attr) throws JasperException {
 
-            HashMap table = (type == VAR_NAME_FROM) ? nameFromTable : 
nameTable;
+            HashMap table = (type.equals(VAR_NAME_FROM)) ? nameFromTable : 
nameTable;
             NameEntry nameEntry = (NameEntry) table.get(name);
             if (nameEntry != null) {
-                if (type != TAG_DYNAMIC || nameEntry.getType() != TAG_DYNAMIC) 
{
+                if (!type.equals(TAG_DYNAMIC) || 
!nameEntry.getType().equals(TAG_DYNAMIC)) {
                     int line = nameEntry.getNode().getStart().getLineNumber();
                     err.jspError(n, "jsp.error.tagfile.nameNotUnique", type,
                             nameEntry.getType(), Integer.toString(line));
diff --git 
a/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/XMLEncodingDetector.java
 
b/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/XMLEncodingDetector.java
index 07524be..9fc0b42 100644
--- 
a/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/XMLEncodingDetector.java
+++ 
b/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/XMLEncodingDetector.java
@@ -1327,7 +1327,7 @@ public class XMLEncodingDetector {
             String name = scanPseudoAttribute(scanningTextDecl, fString);
             switch (state) {
                 case STATE_VERSION: {
-                    if (name == fVersionSymbol) {
+                    if (name.equals(fVersionSymbol)) {
                         if (!sawSpace) {
                             reportFatalError(scanningTextDecl
                                        ? 
"jsp.error.xml.spaceRequiredBeforeVersionInTextDecl"
@@ -1343,7 +1343,7 @@ public class XMLEncodingDetector {
                             err.jspError("jsp.error.xml.versionNotSupported",
                                         version);
                         }
-                    } else if (name == fEncodingSymbol) {
+                    } else if (name.equals(fEncodingSymbol)) {
                         if (!scanningTextDecl) {
                             err.jspError("jsp.error.xml.versionInfoRequired");
                         }
@@ -1366,7 +1366,7 @@ public class XMLEncodingDetector {
                     break;
                 }
                 case STATE_ENCODING: {
-                    if (name == fEncodingSymbol) {
+                    if (name.equals(fEncodingSymbol)) {
                         if (!sawSpace) {
                             reportFatalError(scanningTextDecl
                                       ? 
"jsp.error.xml.spaceRequiredBeforeEncodingInTextDecl"
@@ -1377,7 +1377,7 @@ public class XMLEncodingDetector {
                         state = scanningTextDecl ? STATE_DONE : 
STATE_STANDALONE;
                         // TODO: check encoding name; set encoding on
                         //       entity scanner
-                    } else if (!scanningTextDecl && name == fStandaloneSymbol) 
{
+                    } else if (!scanningTextDecl && 
name.equals(fStandaloneSymbol)) {
                         if (!sawSpace) {
                             
err.jspError("jsp.error.xml.spaceRequiredBeforeStandalone");
                         }
@@ -1392,7 +1392,7 @@ public class XMLEncodingDetector {
                     break;
                 }
                 case STATE_STANDALONE: {
-                    if (name == fStandaloneSymbol) {
+                    if (name.equals(fStandaloneSymbol)) {
                         if (!sawSpace) {
                             
err.jspError("jsp.error.xml.spaceRequiredBeforeStandalone");
                         }

Reply via email to