diff --git a/co-simulation/fed/mosaic-carla/src/main/java/org/eclipse/mosaic/fed/carla/ambassador/CarlaAmbassador.java b/co-simulation/fed/mosaic-carla/src/main/java/org/eclipse/mosaic/fed/carla/ambassador/CarlaAmbassador.java index 5d34076c..1b48b41c 100644 --- a/co-simulation/fed/mosaic-carla/src/main/java/org/eclipse/mosaic/fed/carla/ambassador/CarlaAmbassador.java +++ b/co-simulation/fed/mosaic-carla/src/main/java/org/eclipse/mosaic/fed/carla/ambassador/CarlaAmbassador.java @@ -222,7 +222,6 @@ public void initialize(long startTime, long endTime) throws InternalFederateExce catch (MalformedURLException m) { log.error("Errors occurred with {}", m.getMessage()); - carlaXmlRpcClient.closeConnection(); } // Start the CARLA simulator startCarlaLocal(); @@ -379,6 +378,7 @@ public synchronized void processTimeAdvanceGrant(long time) throws InternalFeder } catch (XmlRpcException e) { log.error("Failed to connect to CARLA Adapter : ", e); + carlaXmlRpcClient.closeConnection(); } } diff --git a/co-simulation/fed/mosaic-carla/src/test/java/org/eclipse/mosaic/fed/carla/ambassador/CarlaAmbassadorTest.java b/co-simulation/fed/mosaic-carla/src/test/java/org/eclipse/mosaic/fed/carla/ambassador/CarlaAmbassadorTest.java index 92b929e3..b382b24d 100644 --- a/co-simulation/fed/mosaic-carla/src/test/java/org/eclipse/mosaic/fed/carla/ambassador/CarlaAmbassadorTest.java +++ b/co-simulation/fed/mosaic-carla/src/test/java/org/eclipse/mosaic/fed/carla/ambassador/CarlaAmbassadorTest.java @@ -19,6 +19,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import org.eclipse.mosaic.fed.carla.carlaconnect.CarlaXmlRpcClient; import org.eclipse.mosaic.lib.util.junit.TestFileRule; import org.eclipse.mosaic.rti.TIME; import org.eclipse.mosaic.rti.api.RtiAmbassador; @@ -55,6 +56,8 @@ public void setup() throws IOException { rtiMock = mock(RtiAmbassador.class); + + FederateDescriptor handleMock = mock(FederateDescriptor.class); File workingDir = temporaryFolder.getRoot();