Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@ public static TransportVersionDefinition fromString(Path file, String contents)
String name = filename.substring(0, filename.length() - 4);
List<TransportVersionId> ids = new ArrayList<>();

String idsLine = null;
if (contents.isEmpty() == false) {
for (String rawId : contents.split(",")) {
String[] lines = contents.split(System.lineSeparator());
for (String line : lines) {
line = line.replaceAll("\\s+", "");
if (line.startsWith("#") == false) {
idsLine = line;
break;
}
}
}
if (idsLine != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if idsLine is null doesn't that mean we have an empty file (which should be an error)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was preserving how this already was, but happy to change it. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think it should be an error. Having an empty file isn't ever valid.

Copy link
Contributor Author

@jdconrad jdconrad Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want comments available, so I will follow up and add better error coverage to both these methods in a follow up. There's a few more things to look for in the parsing that we do in ES, but not gradle still.

for (String rawId : idsLine.split(",")) {
try {
ids.add(TransportVersionId.fromString(rawId));
} catch (NumberFormatException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ public static TransportVersionUpperBound fromString(Path file, String contents)
int slashIndex = filename.lastIndexOf('/');
String branch = filename.substring(slashIndex == -1 ? 0 : (slashIndex + 1), filename.length() - 4);

String[] parts = contents.split(",");
String idsLine = null;
String[] lines = contents.split(System.lineSeparator());
for (String line : lines) {
line = line.replaceAll("\\s+", "");
if (line.startsWith("#") == false) {
idsLine = line;
break;
}
}
String[] parts = idsLine.split(",");
if (parts.length != 2) {
throw new IllegalStateException("Invalid transport version upper bound file [" + file + "]: " + contents);
}
Expand Down