Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle potentially invalid Olog resource URL #3223

Merged
merged 1 commit into from
Dec 31, 2024
Merged
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 @@ -26,6 +26,8 @@
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
Expand Down Expand Up @@ -163,9 +165,16 @@ public void updateItem(Object item, boolean empty){
break;
case "resource":
final String resourceURL = propertyItem.getValue();
final URI resource = URI.create(resourceURL);
URI _resource;
try {
_resource = URI.create(resourceURL);
} catch (IllegalArgumentException e) { // E.g. if string contains space char
logger.log(Level.WARNING, "Encountered invalid URL: \"" + resourceURL + "\", will be URL encoded.");
_resource = URI.create(URLEncoder.encode(resourceURL, StandardCharsets.UTF_8));
}
final Hyperlink resourceLink = new Hyperlink(resourceURL);
setGraphic(resourceLink);
final URI resource = _resource;
resourceLink.setOnAction((e) -> {
final List<AppResourceDescriptor> applications = ApplicationService.getApplications(resource);
// If resource URI contains valid app name, use it
Expand Down
Loading