Skip to content

Migration of the cf-java-client dependency - #1907

Open
karrgov wants to merge 9 commits into
masterfrom
cf_java_client_poc
Open

karrgov wants to merge 9 commits into
masterfrom
cf_java_client_poc

Conversation

@karrgov

@karrgov karrgov commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Migration of the cf-java-client dependency

@sonarqubecloud

Copy link
Copy Markdown

Comment on lines +6 to 14
public String getValue() {
return name().toLowerCase();
}

@Override
public String toString() {
return this.name().toLowerCase();
return this.name()
.toLowerCase();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why don't you use just of the two methods because they are the same?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you are right, fixed

Comment on lines +18 to +19
this.labels = labels == null ? Collections.emptyMap() : Collections.unmodifiableMap(new LinkedHashMap<>(labels));
this.annotations = annotations == null ? Collections.emptyMap() : Collections.unmodifiableMap(new LinkedHashMap<>(annotations));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you use Map.copyOf instead of Collections.unmodifiableMap(new LinkedHashMap<>(...)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Have thought about this, but wanted to be a bit more sure, since copyOf() does not allow the key value pairs to have nulls, while the unmodifiableMap() allows it.

Comment on lines +82 to +92
public Builder labels(Map<String, String> labels) {
if (labels != null) {
this.labels.putAll(labels);
}

return this;
}

public Builder putAllLabels(Map<String, String> labels) {
return labels(labels);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you leave only one method because are the same but with differnet name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks

Comment on lines +99 to +109
public Builder annotations(Map<String, String> annotations) {
if (annotations != null) {
this.annotations.putAll(annotations);
}

return this;
}

public Builder putAllAnnotations(Map<String, String> annotations) {
return annotations(annotations);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same

Comment on lines +20 to +23
public record V3Application(@JsonProperty("guid") String guid, @JsonProperty("name") String name, @JsonProperty("state") String state,
@JsonProperty("created_at") String createdAt, @JsonProperty("updated_at") String updatedAt,
@JsonProperty("lifecycle") V3Lifecycle lifecycle, @JsonProperty("metadata") V3Metadata metadata,
@JsonProperty("relationships") V3Relationships relationships) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we extract these string in a constant calss because they are repeated more in other classes

}
}

@SuppressWarnings("unchecked")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove this

Comment on lines +182 to +183
return (Map<String, Object>) JsonUtil.convertJsonToMap(response.body())
.get(Constants.ROOT_DOCUMENT_LINKS_LIST);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use micsutil cast

requestTags.forEach(requestBuilder::header);
HttpResponse<String> response = getSimpleHttpClient().send(requestBuilder.build(), HttpResponse.BodyHandlers.ofString());

if (response.statusCode() / 100 != 2) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think if you add a range will be easier to understand :D

}

@SuppressWarnings("unchecked")
private Map<String, Object> getCloudControllerRootDocumentLinks(URL controllerUrl, Map<String, String> requestTags) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This method has a lot of nested structure and is long. Extract to new methods

import reactor.netty.http.client.HttpClient;

@Value.Immutable
public abstract class CloudControllerRestClientFactory {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this class does many things like creating a lot of client and extracting url-s. Can you move some of the methods to a new class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants