smolnar82 commented on code in PR #799:
URL: https://github.com/apache/knox/pull/799#discussion_r1350100257


##########
gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/TokenStateDatabase.java:
##########
@@ -192,7 +196,9 @@ Collection<KnoxToken> getDoAsTokens(String userName) throws 
SQLException {
   private Collection<KnoxToken> fetchTokens(String userName, String sql) 
throws SQLException {
     Map<String, KnoxToken> tokenMap = new LinkedHashMap<>();
     try (Connection connection = dataSource.getConnection(); PreparedStatement 
getTokenIdsStatement = connection.prepareStatement(sql)) {
-      getTokenIdsStatement.setString(1, userName);
+      if (userName != null) {
+        getTokenIdsStatement.setString(1, userName);

Review Comment:
   An SQL error is thrown here which is handled in `JDBCTokenStateService`:
   ```2023-10-09 11:25:29,822 84376fc3-8a56-42f3-a399-9f81f0ffe2da ERROR 
token.state (JDBCTokenStateService.java:getTokens(312)) - An error occurred 
while fetching tokens for user null from the database : No value specified for 
parameter 1.```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to