diff --git a/config/src/main/java/com/typesafe/config/waterdrop/impl/PathParser.java b/config/src/main/java/com/typesafe/config/waterdrop/impl/PathParser.java index 1edf039f3..191dc9e85 100644 --- a/config/src/main/java/com/typesafe/config/waterdrop/impl/PathParser.java +++ b/config/src/main/java/com/typesafe/config/waterdrop/impl/PathParser.java @@ -193,7 +193,7 @@ private static Collection splitTokenOnPeriod(Token t, ConfigSyntax flavor splitTokens.add(Tokens.newUnquotedText(t.origin(), ConfigParseOptions.pathTokenSeparator)); } - if (! tokenText.substring(tokenText.length() - ConfigParseOptions.pathTokenSeparator.length(), tokenText.length()).equals(ConfigParseOptions.pathTokenSeparator)) { + if (tokenText.length() < ConfigParseOptions.pathTokenSeparator.length() || ! tokenText.substring(tokenText.length() - ConfigParseOptions.pathTokenSeparator.length(), tokenText.length()).equals(ConfigParseOptions.pathTokenSeparator)) { splitTokens.remove(splitTokens.size() - 1); }