Skip to content
Open
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
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2014 Atlassian
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* Temporary fix until https://bitbucket.org/atlassian/jira-rest-java-client/pull-requests/170 is fixed */

package com.atlassian.jira.rest.client.api.domain.util;

import java.net.URI;
import java.util.List;

public class UriUtil {
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

The utility class lacks class-level and method-level documentation. Public methods should have Javadoc explaining their parameters, return values, and behavior, especially edge cases (e.g., what happens with null inputs, relative URIs, or URIs without hosts).

Copilot uses AI. Check for mistakes.

private static final List<String> CLOUD_DOMAINS = List.of("atlassian.net", "jira.com", "api.atlassian.com");
private static final List<String> DC_DOMAINS = List.of("localhost");
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

The DC_DOMAINS list containing only 'localhost' is insufficient and the logic is unclear. The current implementation excludes URIs containing 'localhost' from being classified as cloud, but this doesn't meaningfully distinguish DC instances since most DC instances won't be on localhost. Consider clarifying the purpose of this list or removing it if it's not serving a meaningful validation purpose.

Copilot uses AI. Check for mistakes.

public static URI path(final URI uri, final String path) {
final String uriString = uri.toString();
final StringBuilder sb = new StringBuilder(uriString);
if (!uriString.endsWith("/")) {
sb.append('/');
}
sb.append(path.startsWith("/") ? path.substring(1) : path);
return URI.create(sb.toString());
}

public static boolean isURICloud(URI uri) {
String host = uri.getHost().toLowerCase();
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

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

Potential NullPointerException if uri.getHost() returns null. The getHost() method can return null for URIs that don't have a host component (e.g., relative URIs or opaque URIs like 'mailto:[email protected]'). Add a null check or document that this method requires URIs with a host component.

Suggested change
String host = uri.getHost().toLowerCase();
String host = uri.getHost();
if (host == null) {
return false;
}
host = host.toLowerCase();

Copilot uses AI. Check for mistakes.
return CLOUD_DOMAINS.stream().anyMatch(host::contains)
&& DC_DOMAINS.stream().noneMatch(host::contains);
}
}
Loading