Skip to content

Commit d9970b3

Browse files
committed
KNOX-3278: Correcting pmd findings.
1 parent 028198c commit d9970b3

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

gateway-shell/src/main/java/org/apache/knox/gateway/shell/Shell.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,14 @@ private static void startInteractiveShell() throws Exception {
139139
while (true) {
140140
try {
141141
String line = reader.readLine("knox> ");
142-
if (line == null) break;
142+
if (line == null) {
143+
break;
144+
}
143145

144146
String trimmed = line.trim();
145-
if (trimmed.isEmpty()) continue;
147+
if (trimmed.isEmpty()) {
148+
continue;
149+
}
146150

147151
// --- BUILT-IN COMMANDS ---
148152
if (":exit".equalsIgnoreCase(trimmed) || ":quit".equalsIgnoreCase(trimmed)) {

gateway-shell/src/main/java/org/apache/knox/gateway/shell/commands/WebHDFSCommand.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@ public Object execute(List<String> args) {
7373
String action = (args == null || args.isEmpty()) ? "ls" : args.get(0);
7474

7575
if ("mount".equalsIgnoreCase(action)) {
76-
if (args.size() < 3) return printError("Usage: :fs mount <target-topology-url> <mountpoint-name>");
76+
if (args.size() < 3) {
77+
return printError("Usage: :fs mount <target-topology-url> <mountpoint-name>");
78+
}
7779
return mount(mounts, args.get(1), args.get(2));
7880
}
7981
else if ("unmount".equalsIgnoreCase(action)) {
80-
if (args.size() < 2) return printError("Usage: :fs unmount <mountpoint-name>");
82+
if (args.size() < 2) {
83+
return printError("Usage: :fs unmount <mountpoint-name>");
84+
}
8185
unmount(mounts, args.get(1));
8286
return "Unmounted " + args.get(1);
8387
}
@@ -94,7 +98,9 @@ else if ("ls".equalsIgnoreCase(action)) {
9498
else if ("put".equalsIgnoreCase(action)) {
9599
// Hdfs.put( session ).file( dataFile ).to( dataDir + "/" + dataFile ).now()
96100
// :fs put from-path to-path
97-
if (args.size() < 3) return printError("Usage: :fs put <from-path> <to-path> [permissions]");
101+
if (args.size() < 3) {
102+
return printError("Usage: :fs put <from-path> <to-path> [permissions]");
103+
}
98104
String localFile = args.get(1);
99105
String path = args.get(2);
100106
int permission = 755;
@@ -110,26 +116,34 @@ else if ("put".equalsIgnoreCase(action)) {
110116
else if ("rm".equalsIgnoreCase(action)) {
111117
// Hdfs.rm( session ).file( dataFile ).now()
112118
// :fs rm target-path
113-
if (args.size() < 2) return printError("Usage: :fs rm <target-path>");
119+
if (args.size() < 2) {
120+
return printError("Usage: :fs rm <target-path>");
121+
}
114122
return remove(mounts, args.get(1));
115123
}
116124
else if ("cat".equalsIgnoreCase(action)) {
117125
// println Hdfs.get( session ).from( dataDir + "/" + dataFile ).now().string
118126
// :fs cat target-path
119-
if (args.size() < 2) return printError("Usage: :fs cat <target-path>");
127+
if (args.size() < 2) {
128+
return printError("Usage: :fs cat <target-path>");
129+
}
120130
return cat(mounts, args.get(1));
121131
}
122132
else if ("mkdir".equalsIgnoreCase(action)) {
123133
// println Hdfs.mkdir( session ).dir( directoryPath ).perm( "777" ).now().string
124134
// :fs mkdir target-path [perms]
125-
if (args.size() < 2) return printError("Usage: :fs mkdir <target-path> [perms]");
135+
if (args.size() < 2) {
136+
return printError("Usage: :fs mkdir <target-path> [perms]");
137+
}
126138
String perms = (args.size() == 3) ? args.get(2) : null;
127139
return mkdir(mounts, args.get(1), perms);
128140
}
129141
else if ("get".equalsIgnoreCase(action)) {
130142
// println Hdfs.get( session ).from( dataDir + "/" + dataFile ).now().string
131143
// :fs get from-path [to-path]
132-
if (args.size() < 2) return printError("Usage: :fs get <from-path> [to-path]");
144+
if (args.size() < 2) {
145+
return printError("Usage: :fs get <from-path> [to-path]");
146+
}
133147
String path = args.get(1);
134148
String mountPoint = determineMountPoint(path);
135149
KnoxSession session = getSessionForMountPoint(mounts, mountPoint);

0 commit comments

Comments
 (0)