Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ limitations under the License.
<exclude name="SimplifiableTestAssertion" />
<exclude name="DoubleBraceInitialization" />
<exclude name="UseCollectionIsEmpty" />
<exclude name="ImplicitFunctionalInterface" />
<exclude name="UnnecessaryWarningSuppression" />
</rule>

<!--<rule ref="category/java/codestyle.xml" />-->
Expand Down Expand Up @@ -98,6 +100,8 @@ limitations under the License.
<exclude name="CloneMethodReturnTypeMustMatchClassName" />
<exclude name="CloseResource" />
<exclude name="CompareObjectsWithEquals" />
<exclude name="ReplaceJavaUtilCalendar" />
<exclude name="ReplaceJavaUtilDate" />
</rule>
<rule ref="category/java/multithreading.xml">
<exclude name="AvoidSynchronizedAtMethodLevel" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,7 @@ private static class TestFaultyDiscoveryApiClient extends TestDiscoveryApiClient
super(gatewayConfig, sdConfig, aliasService);
}

@SuppressWarnings("PMD.UselessPureMethodCall")
@Override
public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException {
if (executeCount.get() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ public final void log( final StackTraceElement caller, final MessageLevel messag
}

private static Level toLevel(final MessageLevel level ) {
switch( level ) {
case FATAL: return Level.FATAL;
case ERROR: return Level.ERROR;
case WARN: return Level.WARN;
case INFO: return Level.INFO;
case DEBUG: return Level.DEBUG;
case TRACE: return Level.TRACE;
default: return Level.OFF;
}
return switch (level) {
case FATAL -> Level.FATAL;
case ERROR -> Level.ERROR;
case WARN -> Level.WARN;
case INFO -> Level.INFO;
case DEBUG -> Level.DEBUG;
case TRACE -> Level.TRACE;
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
return switch (level) {
case FATAL, ERROR -> logger.isErrorEnabled();
case WARN -> logger.isWarnEnabled();
case INFO -> logger.isInfoEnabled();
case DEBUG -> logger.isDebugEnabled();
case TRACE -> logger.isTraceEnabled();
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
return switch (level) {
case FATAL, ERROR -> Level.SEVERE;
case WARN -> Level.WARNING;
case INFO -> Level.INFO;
case DEBUG -> Level.FINE;
case TRACE -> Level.FINEST;
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,10 @@ public void run() {

private void executeAction(final KnoxSession gatewayKnoxSession, final KnoxSession tokenBasedKnoxSession) {
try {
switch (this.action) {
case ACQUIRE:
knoxTokenCache.saveKnoxToken(acquireKnoxToken(gatewayKnoxSession));
break;
case RENEW:
renewKnoxToken(gatewayKnoxSession);
break;
case USE_TOKEN:
useKnoxToken(tokenBasedKnoxSession);
break;
default:
// NOP
break;
switch (action) {
case ACQUIRE -> knoxTokenCache.saveKnoxToken(acquireKnoxToken(gatewayKnoxSession));
case RENEW -> renewKnoxToken(gatewayKnoxSession);
case USE_TOKEN -> useKnoxToken(tokenBasedKnoxSession);
}
} catch (Exception e) {
LOG.failedToExecuteKnoxTokenAction(action, e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

public class DataSourceFactory {

@SuppressWarnings("PMD.ExhaustiveSwitchHasDefault")
public static DataSource getDataSource(GatewayConfig gatewayConfig, AliasService aliasService) throws AliasServiceException, SQLException {
DatabaseType dbType = DatabaseType.fromString(gatewayConfig.getDatabaseType());
AbstractDataSource dsFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,11 @@ private void archiveTokens(Map<String, TokenData> tokenDataMap) throws AliasServ
log("Archiving token aliases in the " + cluster + " credential store...");
final long start = System.currentTimeMillis();
final Map<String, String> tokenAliasesToArchive = new HashMap<>();
tokenDataMap.entrySet().forEach(tokenDataMapEntry -> {
String tokenId = tokenDataMapEntry.getKey();
tokenDataMapEntry.getValue();
tokenAliasesToArchive.put(tokenId, String.valueOf(tokenDataMapEntry.getValue().expiration));
tokenAliasesToArchive.put(tokenId + TOKEN_MAX_LIFETIME_POSTFIX, String.valueOf(tokenDataMapEntry.getValue().maxLifeTime));
tokenAliasesToArchive.put(tokenId + TOKEN_ISSUE_TIME_POSTFIX, String.valueOf(tokenDataMapEntry.getValue().issueTime));
tokenAliasesToArchive.put(tokenId + TOKEN_META_POSTFIX, tokenDataMapEntry.getValue().metadata.toJSON());
tokenDataMap.forEach((tokenId, value) -> {
tokenAliasesToArchive.put(tokenId, String.valueOf(value.expiration));
tokenAliasesToArchive.put(tokenId + TOKEN_MAX_LIFETIME_POSTFIX, String.valueOf(value.maxLifeTime));
tokenAliasesToArchive.put(tokenId + TOKEN_ISSUE_TIME_POSTFIX, String.valueOf(value.issueTime));
tokenAliasesToArchive.put(tokenId + TOKEN_META_POSTFIX, value.metadata.toJSON());
});
aliasService.addAliasesForCluster(cluster, tokenAliasesToArchive);
log("Archived token related aliases in the " + cluster + " credential store in " + (System.currentTimeMillis() - start) + " millsieconds ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

return new AbstractMap.SimpleEntry<>(tss, response);
Response response = switch (operation) {
case Renew -> requestTokenRenewal(tr, accessToken, caller);
case Revoke -> requestTokenRevocation(tr, accessToken, caller);
};

return new AbstractMap.SimpleEntry<>(tss, response);
}

private String getAccessToken(TokenResource tokenResource) throws KeyLengthException, AliasServiceException, ServiceLifecycleException, ServletException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import jakarta.xml.bind.annotation.XmlElementWrapper;
import jakarta.xml.bind.annotation.XmlRootElement;

@SuppressWarnings("PMD.OverrideBothEqualsAndHashCodeOnComparable")
@XmlRootElement(name = "topology")
public class TopologyInformation implements Comparable<TopologyInformation>{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,12 @@ protected List<String> getPathElements() {
}

protected HttpRequestBase createRequest() {
HttpRequestBase request;

switch (getRequestType()) {
case POST:
request = new HttpPost(requestURI);
break;
case PUT:
request = new HttpPut(requestURI);
break;
case DELETE:
request = new HttpDelete(requestURI);
break;
case GET:
default:
request = new HttpGet(requestURI);
break;
}
return request;
return switch (getRequestType()) {
case POST -> new HttpPost(requestURI);
case PUT -> new HttpPut(requestURI);
case DELETE -> new HttpDelete(requestURI);
default -> new HttpGet(requestURI);
};
}

protected AliasResponse createResponse(HttpResponse response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ public KnoxShellTable sort(List<Comparable<? extends Object>> col,
return table;
}

@SuppressWarnings("PMD.OverrideBothEqualsAndHashCodeOnComparable")
private static class RowIndex implements Comparable<RowIndex> {
Comparable value;
int index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.List;

@SuppressWarnings("PMD.OverrideBothEqualsAndHashCodeOnComparable")
class KnoxShellTableCell<T extends Comparable<T>> implements Comparable<KnoxShellTableCell<T>>{
int rowIndex;
int colIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ public void testNullCellRendering() {

table.row().value(null).value("456").value("344444444");
table.row().value("789").value("012").value("844444444");

table.toString();
}

@Test
Expand Down Expand Up @@ -172,7 +170,6 @@ public void testMultipleRowsTableMismatchedColAndHeadersCountError() {
table.row().value("789").value("012").value("844444444");

assertNull(table.toString());
table.toString();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Date;
import java.util.Locale;

@SuppressWarnings("PMD.OverrideBothEqualsAndHashCodeOnComparable")
public class KnoxToken implements Comparable<KnoxToken> {
private static final Comparator<KnoxToken> COMPARATOR = Comparator
.comparingLong((KnoxToken kt) -> kt.issueTime)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-dependency-plugin.version>3.6.1</maven-dependency-plugin.version>
<maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
<maven-pmd-plugin.version>3.26.0</maven-pmd-plugin.version>
<maven-pmd-plugin.version>3.28.0</maven-pmd-plugin.version>
<metrics.version>4.1.16</metrics.version>
<mina.version>2.2.4</mina.version>
<netty.version>4.1.127.Final</netty.version>
Expand Down
Loading