You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2021/09/01 11:01:28 UTC
[tomcat] 07/13: Refactor to avoid NPE warnings in IDE
This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 785e07613175dc5bfcd5dffd34eb705fa907621d
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