You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/08/31 17:10:54 UTC

[tomcat] branch main updated (035eef9 -> 36fa7bd)

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

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


    from 035eef9  Fix JSP API Javadoc warnings for Java 16
     new ba68069  Refactor to avoid NPE warnings in IDE
     new 36fa7bd  Fix IDE warnings. Use <> where possible.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../catalina/users/DataSourceUserDatabase.java     | 27 +++++++++++-----------
 1 file changed, 14 insertions(+), 13 deletions(-)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/02: Refactor to avoid NPE warnings in IDE

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit ba6806966148dc35ef5beef51c69541369fc2d22
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Aug 31 18:02:36 2021 +0100

    Refactor to avoid NPE warnings in IDE
---
 java/org/apache/catalina/users/DataSourceUserDatabase.java | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/users/DataSourceUserDatabase.java b/java/org/apache/catalina/users/DataSourceUserDatabase.java
index f90d1b0..dbe1a69 100644
--- a/java/org/apache/catalina/users/DataSourceUserDatabase.java
+++ b/java/org/apache/catalina/users/DataSourceUserDatabase.java
@@ -1092,11 +1092,13 @@ public class DataSourceUserDatabase extends SparseUserDatabase {
                 tempRelationDelete2.append(roleNameCol);
                 tempRelationDelete2.append(" = ?");
                 for (Role role : removedRoles.values()) {
-                    try (PreparedStatement stmt = dbConnection.prepareStatement(tempRelationDelete.toString())) {
-                        stmt.setString(1, role.getRolename());
-                        stmt.executeUpdate();
-                    } catch (SQLException e) {
-                        log.error(sm.getString("dataSourceUserDatabase.exception"), e);
+                    if (tempRelationDelete != null) {
+                        try (PreparedStatement stmt = dbConnection.prepareStatement(tempRelationDelete.toString())) {
+                            stmt.setString(1, role.getRolename());
+                            stmt.executeUpdate();
+                        } catch (SQLException e) {
+                            log.error(sm.getString("dataSourceUserDatabase.exception"), e);
+                        }
                     }
                     try (PreparedStatement stmt = dbConnection.prepareStatement(tempRelationDelete2.toString())) {
                         stmt.setString(1, role.getRolename());
@@ -1180,7 +1182,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase {
                     temp.append(" = ?");
                 }
                 for (Group group : modifiedGroups.values()) {
-                    if (roleAndGroupDescriptionCol != null) {
+                    if (temp != null) {
                         try (PreparedStatement stmt = dbConnection.prepareStatement(temp.toString())) {
                             stmt.setString(1, group.getDescription());
                             stmt.setString(2, group.getGroupname());

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/02: Fix IDE warnings. Use <> where possible.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 36fa7bd76fc2328c778081b0bb0c34c2a30d345f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Aug 31 18:03:42 2021 +0100

    Fix IDE warnings. Use <> where possible.
---
 java/org/apache/catalina/users/DataSourceUserDatabase.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/users/DataSourceUserDatabase.java b/java/org/apache/catalina/users/DataSourceUserDatabase.java
index dbe1a69..a5bff3a 100644
--- a/java/org/apache/catalina/users/DataSourceUserDatabase.java
+++ b/java/org/apache/catalina/users/DataSourceUserDatabase.java
@@ -559,7 +559,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase {
     public Group createGroup(String groupname, String description) {
         readLock.lock();
         try {
-            Group group = new GenericGroup<DataSourceUserDatabase>(this, groupname, description, null);
+            Group group = new GenericGroup<>(this, groupname, description, null);
             createdGroups.put(groupname, group);
             modifiedGroups.remove(groupname);
             removedGroups.remove(groupname);
@@ -573,7 +573,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase {
     public Role createRole(String rolename, String description) {
         readLock.lock();
         try {
-            Role role = new GenericRole<DataSourceUserDatabase>(this, rolename, description);
+            Role role = new GenericRole<>(this, rolename, description);
             createdRoles.put(rolename, role);
             modifiedRoles.remove(rolename);
             removedRoles.remove(rolename);
@@ -587,7 +587,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase {
     public User createUser(String username, String password, String fullName) {
         readLock.lock();
         try {
-            User user = new GenericUser<DataSourceUserDatabase>(this, username, password, fullName, null, null);
+            User user = new GenericUser<>(this, username, password, fullName, null, null);
             createdUsers.put(username, user);
             modifiedUsers.remove(username);
             removedUsers.remove(username);
@@ -657,7 +657,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase {
                                 log.error(sm.getString("dataSourceUserDatabase.exception"), e);
                             }
                         }
-                        group = new GenericGroup<DataSourceUserDatabase>(this, groupName, description, groupRoles);
+                        group = new GenericGroup<>(this, groupName, description, groupRoles);
                     }
                 }
             }
@@ -707,7 +707,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase {
                 if (rs.next()) {
                     if (rs.getString(1) != null) {
                         String description = (roleAndGroupDescriptionCol != null) ? rs.getString(2) : null;
-                        role = new GenericRole<DataSourceUserDatabase>(this, roleName, description);
+                        role = new GenericRole<>(this, roleName, description);
                     }
                 }
             }
@@ -811,8 +811,7 @@ public class DataSourceUserDatabase extends SparseUserDatabase {
             }
         }
 
-        User user = new GenericUser<DataSourceUserDatabase>(this, userName, dbCredentials,
-                fullName, groups, roles);
+        User user = new GenericUser<>(this, userName, dbCredentials, fullName, groups, roles);
         return user;
     }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org