X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fcontrollers%2FServiceController.java;h=bda5e09589d0d81983d46f8e884a2e0f4bdc9f7c;hb=4891734864ae374cf6ff357f41cc840c4f685300;hp=844d6e8640bb8dab884e46f83722be57f8f1a7b6;hpb=3e827b5c2bc00500577af25e9cb559b6243e1abd;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/controllers/ServiceController.java b/policy-agent/src/main/java/org/oransc/policyagent/controllers/ServiceController.java index 844d6e86..bda5e095 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/controllers/ServiceController.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/controllers/ServiceController.java @@ -20,13 +20,13 @@ package org.oransc.policyagent.controllers; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + import java.time.Duration; import java.util.Collection; import java.util.Vector; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - import org.oransc.policyagent.exceptions.ServiceException; import org.oransc.policyagent.repository.Service; import org.oransc.policyagent.repository.Services; @@ -86,15 +86,16 @@ public class ServiceController { } private Service toService(ServiceRegistrationInfo s) { - return new Service(s.name(), Duration.ofSeconds(s.keepAliveInterval())); + return new Service(s.name(), Duration.ofSeconds(s.keepAliveInterval()), s.callbackUrl()); } @GetMapping("/services") public ResponseEntity getServices() { - Collection allServices = this.services.getAll(); - Collection result = new Vector<>(allServices.size()); - for (Service s : allServices) { - result.add(toServiceStatus(s)); + Collection result = new Vector<>(); + synchronized (this.services) { + for (Service s : this.services.getAll()) { + result.add(toServiceStatus(s)); + } } return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); }