[
https://issues.apache.org/jira/browse/KNOX-3236?focusedWorklogId=998855&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-998855
]
ASF GitHub Bot logged work on KNOX-3236:
----------------------------------------
Author: ASF GitHub Bot
Created on: 06/Jan/26 19:37
Start Date: 06/Jan/26 19:37
Worklog Time Spent: 10m
Work Description: smolnar82 commented on code in PR #1135:
URL: https://github.com/apache/knox/pull/1135#discussion_r2666049792
##########
gateway-i18n-logging-sl4j/src/main/java/org/apache/knox/gateway/i18n/messages/loggers/sl4j/Sl4jMessageLogger.java:
##########
@@ -31,15 +31,13 @@ public class Sl4jMessageLogger implements MessageLogger {
@Override
public boolean isLoggable( MessageLevel level ) {
- switch( level ) {
- case FATAL: return logger.isErrorEnabled();
- case ERROR: return logger.isErrorEnabled();
- case WARN: return logger.isWarnEnabled();
- case INFO: return logger.isInfoEnabled();
- case DEBUG: return logger.isDebugEnabled();
- case TRACE: return logger.isTraceEnabled();
- default: return false;
Review Comment:
```
public enum MessageLevel {
FATAL, ERROR, WARN, INFO, DEBUG, TRACE
}
```
All cases are handled, no need for the 'default' case (even PMD marks it as
redundant).
##########
gateway-i18n/src/main/java/org/apache/knox/gateway/i18n/messages/loggers/jdk/JdkMessageLogger.java:
##########
@@ -50,15 +50,13 @@ public void log( final StackTraceElement caller, final
MessageLevel level, final
}
private static Level toLevel( final MessageLevel level ) {
- switch( level ) {
- case FATAL: return Level.SEVERE;
- case ERROR: return Level.SEVERE;
- case WARN: return Level.WARNING;
- case INFO: return Level.INFO;
- case DEBUG: return Level.FINE;
- case TRACE: return Level.FINEST;
- default: return Level.OFF;
Review Comment:
```
public enum MessageLevel {
FATAL, ERROR, WARN, INFO, DEBUG, TRACE
}
```
All cases are handled, no need for the 'default' case (even PMD marks it as
redundant).
##########
gateway-service-knoxtoken/src/test/java/org/apache/knox/gateway/service/knoxtoken/TokenServiceResourceTest.java:
##########
@@ -1689,19 +1689,12 @@ private Map.Entry<TestTokenStateService, Response>
doTestTokenLifecyle(final Tok
final TokenResource tr = new TokenResource();
final String accessToken = getAccessToken(tr);
- Response response;
- switch (operation) {
- case Renew:
- response = requestTokenRenewal(tr, accessToken, caller);
- break;
- case Revoke:
- response = requestTokenRevocation(tr, accessToken, caller);
- break;
- default:
- throw new Exception("Invalid operation: " + operation);
Review Comment:
```
private enum TokenLifecycleOperation {
Renew,
Revoke
}
```
All cases are handled, no need for the 'default' case (even PMD marks it as
redundant).
##########
gateway-provider-rewrite-func-inbound-query-param/src/main/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessor.java:
##########
@@ -47,14 +47,10 @@ public List<String> resolve( UrlRewriteContext context,
List<String> parameters
if( parameters == null || parameters.isEmpty()) {
return Collections.emptyList();
} else {
- switch( context.getDirection() ) {
- case IN:
- return Collections.emptyList();
- case OUT:
- return context.getParameters().resolve(
UrlRewriteResponse.INBOUND_QUERY_PARAM_PREFIX + parameters.get( 0 ));
- default:
- return Collections.emptyList();
- }
+ return switch (context.getDirection()) {
+ case IN -> Collections.emptyList();
+ case OUT ->
context.getParameters().resolve(UrlRewriteResponse.INBOUND_QUERY_PARAM_PREFIX +
parameters.get(0));
+ };
Review Comment:
```
public interface UrlRewriter {
enum Direction { IN, OUT }
...
}
```
It's 100% sure that either `IN` or `OUT` will be handled by the
corresponding case -> the `default` case would never hit.
##########
gateway-server/src/main/java/org/apache/knox/gateway/database/DataSourceFactory.java:
##########
@@ -26,6 +26,7 @@
public class DataSourceFactory {
+ @SuppressWarnings("PMD.ExhaustiveSwitchHasDefault")
Review Comment:
[KNOX-3237](https://issues.apache.org/jira/browse/KNOX-3237)
Issue Time Tracking
-------------------
Worklog Id: (was: 998855)
Time Spent: 1h 10m (was: 1h)
> Upgrade Maven PMD plugin to 3.28.0
> ----------------------------------
>
> Key: KNOX-3236
> URL: https://issues.apache.org/jira/browse/KNOX-3236
> Project: Apache Knox
> Issue Type: Task
> Components: Build
> Affects Versions: 2.1.0, 3.0.0
> Reporter: Sandor Molnar
> Assignee: Sandor Molnar
> Priority: Critical
> Fix For: 3.0.0
>
> Attachments: image-2026-01-06-13-56-44-933.png
>
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> I noticed that my build occasionally hanging here:
> {code:java}
> [INFO] --- pmd:3.26.0:pmd (pmd) @ gateway-provider-security-shiro ---
> [INFO] PMD version: 7.7.0 {code}
> The last time it happened I got a thread dump (see attachment) which
> confirmed my suspicion that PMD indeed has an intermittent issue running on
> multiple threads.
> I also found this bug of theirs: [https://github.com/pmd/pmd/issues/5293]
> So, I checked and found that the latest Maven PMD plugin version, 3.28.0,
> comes with PMD 7.17.0, where this issue is resolved.
> !image-2026-01-06-13-56-44-933.png|height=400!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)