Skip to content

Commit ec45a9e

Browse files
ramkcursoragent
andcommitted
RANGER-5643: fix Spotbugs and Checkstyle in InMemoryJAASConfiguration
Use entrySet iterators and StringBuilder for keyPrefix; remove blank line after opening brace in test class. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent cd2f4ab commit ec45a9e

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

agents-audit/core/src/main/java/org/apache/ranger/audit/utils/InMemoryJAASConfiguration.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,15 @@ private void initialize(Properties properties) {
243243
}
244244
}
245245

246-
for (String jaasClient : jaasClients.keySet()) {
247-
for (Integer index : jaasClients.get(jaasClient)) {
246+
for (Map.Entry<String, SortedSet<Integer>> jaasClientEntry : jaasClients.entrySet()) {
247+
String jaasClient = jaasClientEntry.getKey();
248+
SortedSet<Integer> indexList = jaasClientEntry.getValue();
249+
250+
for (Integer index : indexList) {
248251
String keyPrefix = JAAS_CONFIG_PREFIX_PARAM + jaasClient + ".";
249252

250253
if (index > -1) {
251-
keyPrefix = keyPrefix + index + ".";
254+
keyPrefix = new StringBuilder(keyPrefix).append(index).append('.').toString();
252255
}
253256

254257
String keyParam = keyPrefix + JAAS_CONFIG_LOGIN_MODULE_NAME_PARAM;
@@ -333,10 +336,9 @@ private void initialize(Properties properties) {
333336
sb.append("\tloginModule: [").append(loginModuleName).append("]\n");
334337
sb.append("\tcontrolFlag: [").append(loginControlFlag).append("]\n");
335338

336-
for (String key : options.keySet()) {
337-
String val = options.get(key);
338-
339-
sb.append("\tOptions: [").append(key).append("] => [").append(val).append("]\n");
339+
for (Map.Entry<String, String> optionEntry : options.entrySet()) {
340+
sb.append("\tOptions: [").append(optionEntry.getKey()).append("] => [")
341+
.append(optionEntry.getValue()).append("]\n");
340342
}
341343

342344
LOG.debug(sb.toString());

agents-audit/core/src/test/java/org/apache/ranger/audit/utils/InMemoryJAASConfigurationTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
import static org.junit.jupiter.api.Assertions.assertEquals;
2828
import static org.junit.jupiter.api.Assertions.assertNotNull;
2929

30-
class InMemoryJAASConfigurationTest {
31-
30+
public class InMemoryJAASConfigurationTest {
3231
@Test
3332
void resolveJaasPrincipalExpandsHostForServicePrincipal() throws Exception {
3433
String resolved = InMemoryJAASConfiguration.resolveJaasPrincipal(

0 commit comments

Comments
 (0)