summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-12-02 18:32:24 -0500
committerSam Anthony <sam@samanthony.xyz>2024-12-02 18:32:24 -0500
commit63ac467e5c15ad7b6b3d164756ced039e3ec62fa (patch)
tree91c4ad50f73b75f82231c526f319222d6cf5a0a2
parent71fca772c5ed9eb68547def5a70e442f66442487 (diff)
downloadsoen423-63ac467e5c15ad7b6b3d164756ced039e3ec62fa.zip
replica2: parse coordinator ID
-rw-r--r--src/main/java/derms/replica2/CoordinatorID.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main/java/derms/replica2/CoordinatorID.java b/src/main/java/derms/replica2/CoordinatorID.java
index 5ec65de..a466796 100644
--- a/src/main/java/derms/replica2/CoordinatorID.java
+++ b/src/main/java/derms/replica2/CoordinatorID.java
@@ -16,12 +16,12 @@ class CoordinatorID implements Serializable {
}
static CoordinatorID parse(String str) throws IllegalArgumentException {
- if (str.length() != City.codeLen+ID.nDigits)
+ if (str.length() != City.codeLen+1+ID.nDigits)
throw new IllegalArgumentException("illegal coordinator ID: " + str);
try {
String city = str.substring(0, City.codeLen);
- short num = Short.parseShort(str.substring(City.codeLen));
+ short num = Short.parseShort(str.substring(City.codeLen+1));
return new CoordinatorID(city, num);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("illegal coordinator ID '" + str + "': " + e.getMessage());