Yuta HIGUCHI

Minor fixes

- Format string fix
- FlowRuleEventTest: minor bugfix
- HexString: accept null
- byte[] toString() format change

Change-Id: I9db419cfc211670cc2abd796a21396ba960e23a9
......@@ -85,7 +85,7 @@ public class ResourceAvailableCommand extends AbstractShellCommand {
}
} catch (Exception e) {
print("Invalid link", e.getMessage());
print("Invalid link %s", e.getMessage());
}
}
}
......
package org.onlab.onos.store.service;
import static org.onlab.util.HexString.toHexString;
import java.util.Arrays;
import com.google.common.base.MoreObjects;
......@@ -64,7 +66,7 @@ public class VersionedValue {
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("version", version)
.add("value", Arrays.toString(value))
.add("value", toHexString(value))
.toString();
}
}
......
......@@ -3,6 +3,7 @@ package org.onlab.onos.store.service;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onlab.onos.store.service.WriteRequest.Type.*;
import static org.onlab.util.HexString.toHexString;
import java.util.Objects;
......@@ -189,9 +190,9 @@ public class WriteRequest {
.add("type", type)
.add("tableName", tableName)
.add("key", key)
.add("newValue", newValue)
.add("newValue", toHexString(newValue))
.add("previousVersion", previousVersion)
.add("oldValue", oldValue)
.add("oldValue", toHexString(oldValue))
.toString();
}
......
......@@ -68,7 +68,7 @@ public class FlowRuleEventTest extends AbstractEventTest {
final long time = System.currentTimeMillis();
final FlowRule flowRule = new IntentTestsMocks.MockFlowRule(1);
final FlowRuleEvent event =
new FlowRuleEvent(FlowRuleEvent.Type.RULE_UPDATED, flowRule);
new FlowRuleEvent(FlowRuleEvent.Type.RULE_UPDATED, flowRule, time);
validateEvent(event, FlowRuleEvent.Type.RULE_UPDATED, flowRule, time);
}
}
......
......@@ -28,6 +28,9 @@ public final class HexString {
* @return "0f:ca:fe:de:ad:be:ef"
*/
public static String toHexString(final byte[] bytes) {
if (bytes == null) {
return "(null)";
}
int i;
StringBuilder ret = new StringBuilder(bytes.length * 3 - 1);
String tmp;
......