Fixed a potential NullPointerException when UDP client tries to send an SECCDiscoveryReq message although the getLinkLocalAddress method of the class shared.utils.MiscUtils doesn't find a valid network interface according to the name found in the EVCCConfig.properties file.

This commit is contained in:
Marc Mültin 2020-05-02 15:03:09 +02:00
parent b3ff868ad5
commit ebd66e446e
1 changed files with 7 additions and 8 deletions

View File

@ -79,9 +79,12 @@ public class V2GCommunicationSessionHandlerEVCC implements Observer {
}
private boolean initialize() {
private void initialize() {
UDPClient udpClient = UDPClient.getInstance();
udpClient.initialize();
if (!udpClient.initialize()) {
logger.fatal("UDP client cannot be initialized, ISO 15118 communication cannot continue");
return;
};
byte[] udpResponse = null;
SECCDiscoveryRes seccDiscoveryRes = null;
@ -105,12 +108,8 @@ public class V2GCommunicationSessionHandlerEVCC implements Observer {
}
}
/*
* Establish a new V2GCommunicationSessionEVCC if SECCDiscoveryRes was successful and initiate
* the respective TCP client connection
*/
if (startNewSession(seccDiscoveryRes)) return true;
else return false;
// SECCDiscoveryRes was successful, establish a new V2GCommunicationSessionEVCC and initiate the respective TCP client connection
startNewSession(seccDiscoveryRes);
}