adoroszlai commented on code in PR #7687:
URL: https://github.com/apache/ozone/pull/7687#discussion_r1912479814
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneTenantShell.java:
##########
@@ -102,10 +102,8 @@ public class TestOzoneTenantShell {
private static OzoneShell ozoneSh = null;
private static TenantShell tenantShell = null;
- private final ByteArrayOutputStream out = new ByteArrayOutputStream();
- private final ByteArrayOutputStream err = new ByteArrayOutputStream();
- private static final PrintStream OLD_OUT = System.out;
- private static final PrintStream OLD_ERR = System.err;
+ private static final StringWriter OUT = new StringWriter();
+ private static final StringWriter ERR = new StringWriter();
Review Comment:
We can significantly reduce change in this class by keeping these
non-`static`:
```suggestion
private final StringWriter out = new StringWriter();
private final StringWriter err = new StringWriter();
```
If assignment is moved to `setup()`, then `reset()` can even be removed.
##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/ldb/ValueSchema.java:
##########
@@ -99,11 +96,11 @@ public Void call() throws Exception {
return null;
}
- public static boolean getValueFields(String dbPath, Map<String, Object>
valueSchema, int d, String table,
- String dnDBSchemaVersion) {
+ public boolean getValueFields(String dbPath, Map<String, Object>
valueSchema, int d, String table,
+ String dndbschemaversion) {
Review Comment:
Instead of using slightly different name to avoid `'dnDBSchemaVersion' hides
a field`, let's remove parameters that were required only because the method
was `static`.
```java
public boolean getValueFields(String dbPath, Map<String, Object>
valueSchema) {
```
(needs corresponding changes in caller and where parameters are used)
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneTenantShell.java:
##########
@@ -204,10 +199,11 @@ public void reset() {
private int execute(GenericCli shell, String[] args) {
LOG.info("Executing shell command with args {}", Arrays.asList(args));
CommandLine cmd = shell.getCmd();
-
CommandLine.IExecutionExceptionHandler exceptionHandler =
(ex, commandLine, parseResult) -> {
- new PrintStream(err, true,
DEFAULT_ENCODING).println(ex.getMessage());
+ try (PrintWriter writer = new PrintWriter(ERR)) {
+ writer.println(ex.getMessage());
+ }
Review Comment:
Can be simplified:
```suggestion
commandLine.getErr().println(ex.getMessage());
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]