Skip to content

Commit 85e7f29

Browse files
committed
Initialize session in synchronized block
1 parent 3f04eba commit 85e7f29

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,14 @@ public LifecycleManager(AppConfig appConfig, BaseTransportConfig config, Lifecyc
7676
void initialize() {
7777
super.initialize();
7878

79-
if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.MULTIPLEX)) {
80-
this.session = new SdlSession(sdlSessionListener, (MultiplexTransportConfig) _transportConfig);
81-
} else if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.TCP)) {
82-
this.session = new SdlSession(sdlSessionListener, (TCPTransportConfig) _transportConfig);
83-
} else {
84-
DebugTool.logError(TAG, "Unable to create session for transport type");
79+
synchronized (SESSION_LOCK) {
80+
if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.MULTIPLEX)) {
81+
this.session = new SdlSession(sdlSessionListener, (MultiplexTransportConfig) _transportConfig);
82+
} else if (_transportConfig != null && _transportConfig.getTransportType().equals(TransportType.TCP)) {
83+
this.session = new SdlSession(sdlSessionListener, (TCPTransportConfig) _transportConfig);
84+
} else {
85+
DebugTool.logError(TAG, "Unable to create session for transport type");
86+
}
8587
}
8688
}
8789

0 commit comments

Comments
 (0)