Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
939: Improve robustness and error reporting on invalid fixVersion
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Mar 30, 2021
1 parent 3a40804 commit 2234a03
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Expand Up @@ -31,7 +31,7 @@
import java.io.*;
import java.nio.file.*;
import java.util.*;
import java.util.logging.Logger;
import java.util.logging.*;
import java.util.regex.Pattern;
import java.util.stream.*;

Expand Down Expand Up @@ -126,9 +126,11 @@ private List<Throwable> handleRef(Repository localRepo, UpdateHistory history, R
try {
handleUpdatedRef(localRepo, ref, commits, listener);
} catch (NonRetriableException e) {
log.log(Level.INFO, "Non retriable exception occurred", e);
errors.add(e.cause());
} catch (RuntimeException e) {
// Attempt to roll back
log.log(Level.INFO, "Retriable exception occurred", e);
history.setBranchHash(branch, listener.name(), lastHash.get());
errors.add(e);
}
Expand Down
Expand Up @@ -157,6 +157,19 @@ private Map<String, String> versions() {
return ret;
}

private String versionId(String name) {
var ret = versions().get(name);
if (ret == null) {
// Ensure this is not due to a stale cache
projectMetadataCache = null;
ret = versions().get(name);
if (ret == null) {
throw new RuntimeException("Unknown version `" + name + "`");
}
}
return ret;
}

private void populateLinkTypesIfNeeded() {
if (linkTypes != null) {
return;
Expand Down Expand Up @@ -252,7 +265,7 @@ Optional<JSONValue> encodeProperty(String name, JSONValue value) {
case "versions":
return Optional.of(new JSONArray(value.stream()
.map(JSONValue::asString)
.map(s -> JSON.object().put("id", versions().get(s)))
.map(s -> JSON.object().put("id", versionId(s)))
.collect(Collectors.toList())));
case "components":
return Optional.of(new JSONArray(value.stream()
Expand Down

1 comment on commit 2234a03

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.