keith-turner commented on code in PR #5549:
URL: https://github.com/apache/accumulo/pull/5549#discussion_r2110338991
##########
server/manager/src/main/java/org/apache/accumulo/manager/TableStateWatcher.java:
##########
@@ -46,12 +46,14 @@ public void accept(WatchedEvent event) {
TableId tableId = null;
- if (zPath != null && zPath.startsWith(Constants.ZTABLES + "/")) {
- String suffix = zPath.substring(Constants.ZTABLES.length() + 1);
- if (suffix.contains("/")) {
- String[] sa = suffix.split("/", 2);
- if (Constants.ZTABLE_STATE.equals("/" + sa[1])) {
- tableId = TableId.of(sa[0]);
+ if (zPath != null && zPath.startsWith(Constants.ZNAMESPACES + "/")) {
+ String[] parts = zPath.split("/");
+ if (parts.length >= 6 && Constants.ZNAMESPACES.equals(parts[1])
+ && Constants.ZTABLES.equals(parts[3])) {
+ String tableIdPart = parts[4];
+ String afterTableId = "/" + parts[5];
+ if (Constants.ZTABLE_STATE.equals(afterTableId)) {
+ tableId = TableId.of(tableIdPart);
Review Comment:
Could use endsWith to simplify this a bit and avoid splitting strings.
```suggestion
if (zPath != null && zPath.startsWith(Constants.ZNAMESPACES + "/") &&
zPath.endsWith(Constants.ZTABLE_STATE)) {
String[] parts = zPath.split("/");
if (parts.length == 6 && Constants.ZTABLES.equals(parts[3])) {
tableId = TableId.of(parts[4]);
```
--
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]