Skip to content

Commit

Permalink
Fix NPE problems when no scheme can be resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
snaggedagge authored Sep 29, 2022
1 parent a14671f commit ec6bd80
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,26 @@ public static boolean isAnchor(String ref) {

public static String readURI(String absoluteUri, List<AuthorizationValue> auths) throws Exception {
URI resolved = new URI(absoluteUri);
if (resolved.getScheme().startsWith("http")) {
return readHttp(absoluteUri, auths);
} else if (resolved.getScheme().startsWith("file")) {
return readFile(absoluteUri);
} else if (resolved.getScheme().startsWith("classpath")) {
return readClasspath(absoluteUri);
} else {
// try file
String content = null;
try {
content = readFile(absoluteUri);
} catch (Exception e) {
//
if (StringUtils.isNotBlank(resolved.getScheme())) {
if (resolved.getScheme().startsWith("http")) {
return readHttp(absoluteUri, auths);
} else if (resolved.getScheme().startsWith("file")) {
return readFile(absoluteUri);
} else if (resolved.getScheme().startsWith("classpath")) {
return readClasspath(absoluteUri);
}
if (StringUtils.isBlank(content)) {
content = readClasspath(absoluteUri);
}
return content;
}
// If no matches exists, try file
String content = null;
try {
content = readFile(absoluteUri);
} catch (Exception e) {
//
}
if (StringUtils.isBlank(content)) {
content = readClasspath(absoluteUri);
}
return content;
}

public static JsonNode deserializeIntoTree(String content) throws Exception {
Expand Down

0 comments on commit ec6bd80

Please sign in to comment.