Conversation
LMCROSSITXSADEPLOY-3563
… from poms LMCROSSITXSADEPLOY-3054
LMCROSSITXSADEPLOY-3563
LMCROSSITXSADEPLOY-3563
LMCROSSITXSADEPLOY-3563
2b06745 to
698462b
Compare
LMCROSSITXSADEPLOY-3563
LMCROSSITXSADEPLOY-3563
LMCROSSITXSADEPLOY-3563
|
| public String getValue() { | ||
| return name().toLowerCase(); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return this.name().toLowerCase(); | ||
| return this.name() | ||
| .toLowerCase(); | ||
| } |
There was a problem hiding this comment.
Why don't you use just of the two methods because they are the same?
There was a problem hiding this comment.
you are right, fixed
| this.labels = labels == null ? Collections.emptyMap() : Collections.unmodifiableMap(new LinkedHashMap<>(labels)); | ||
| this.annotations = annotations == null ? Collections.emptyMap() : Collections.unmodifiableMap(new LinkedHashMap<>(annotations)); |
There was a problem hiding this comment.
Can you use Map.copyOf instead of Collections.unmodifiableMap(new LinkedHashMap<>(...)?
There was a problem hiding this comment.
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.
| 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); | ||
| } |
There was a problem hiding this comment.
Can you leave only one method because are the same but with differnet name
| 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); | ||
| } |
| 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) { |
There was a problem hiding this comment.
Can we extract these string in a constant calss because they are repeated more in other classes
| } | ||
| } | ||
|
|
||
| @SuppressWarnings("unchecked") |
| return (Map<String, Object>) JsonUtil.convertJsonToMap(response.body()) | ||
| .get(Constants.ROOT_DOCUMENT_LINKS_LIST); |
| requestTags.forEach(requestBuilder::header); | ||
| HttpResponse<String> response = getSimpleHttpClient().send(requestBuilder.build(), HttpResponse.BodyHandlers.ofString()); | ||
|
|
||
| if (response.statusCode() / 100 != 2) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
| V3ListResponse<R> firstPage = restClient.get() | ||
| .uri(firstPageRelativeUri) | ||
| .retrieve() | ||
| .body(pageType); |
There was a problem hiding this comment.
I would extract this to a new method because is it deplicated in a few places
| } | ||
|
|
||
| private static CloudOperationException jobFailed(V3Job job) { | ||
| String detail = "Job failed"; |
There was a problem hiding this comment.
Extract this as a message and maybe add more details if possible
| detail = job.errors() | ||
| .stream() | ||
| .map(V3Job.V3Error::detail) | ||
| .reduce((a, b) -> a + "\n" + b) |
There was a problem hiding this comment.
Find better names instead of a and b
| private static void sleep(Duration interval) { | ||
| try { | ||
| Thread.sleep(interval.toMillis()); | ||
| } catch (InterruptedException e) { | ||
| Thread.currentThread() | ||
| .interrupt(); | ||
| throw new CloudException(MessageFormat.format(Messages.INTERRUPTED_WHILE_POLLING_ASYNC_JOB_0, e.getMessage()), e); | ||
| } | ||
| } |
There was a problem hiding this comment.
in MiscUtil we have method for sleep
| long elapsedNanos = System.nanoTime() - startTimeNanos; | ||
| if (elapsedNanos >= timeoutNanos) { | ||
| throw new CloudOperationException(HttpStatus.GATEWAY_TIMEOUT, Messages.JOB_TIMEOUT, | ||
| MessageFormat.format(Messages.JOB_0_DID_NOT_COMPLETE_WITHIN_1, jobGuid, timeout)); | ||
| } | ||
|
|
||
| long remainingNanos = timeoutNanos - elapsedNanos; |
There was a problem hiding this comment.
Can you move these to a new method
| .toBodilessEntity(); | ||
| } | ||
|
|
||
| @SuppressWarnings("unchecked") |
| } | ||
|
|
||
| private void assertSpaceProvided(String operation) { | ||
| Assert.notNull(target, "Unable to " + operation + " without specifying organization and space to use."); |
| V3ServiceBinding createdServiceKey = getServiceKeyResourceByNameAndServiceInstanceGuid(keyModel.getName(), | ||
| serviceInstance.getGuid()); |
There was a problem hiding this comment.
Cant you get the id from the post request instead of making new request
| String query = CloudControllerV3Endpoints.SERVICE_CREDENTIAL_BINDINGS + CloudControllerV3Endpoints.QUERY_PER_PAGE | ||
| + CloudControllerV3Endpoints.DEFAULT_PAGE_SIZE + CloudControllerV3Endpoints.AMPERSAND_TYPE + "key" | ||
| + CloudControllerV3Endpoints.AMPERSAND_SERVICE_INSTANCE_GUIDS + serviceInstanceGuid + CloudControllerV3Endpoints.AMPERSAND_NAMES | ||
| + name; |
| @Target(ElementType.METHOD) | ||
| @Retention(RetentionPolicy.CLASS) | ||
| public @interface AllowNulls { |
There was a problem hiding this comment.
What the difference between this and nullable?
There was a problem hiding this comment.
well if talk about collections, if a map is declared as Nullable, this only tells us that we allow the whole map to be null, but if we need to allow for the values of a pair inside the map to hold a null, (for example "someKey" : null) - in order to achieve this we need this custom annotation AllowNulls, since before the migration we used the already provided one from the cf-java-client dependency. Thats how it was directly in the cf-java-client:




Migration of the cf-java-client dependency