Source:
<code>public void setActivityCalendar(final DlmsDeviceMessageMetadata messageMetadata, final ActivityCalendar activityCalendar, final DeviceResponseMessageSender responseMessageSender) { this.logStart(LOGGER, messageMetadata, "setActivityCalendar"); ClientConnection conn = null; DlmsDevice device = null; try { final String deviceIdentification = messageMetadata.getDeviceIdentification(); device = this.domainHelperService.findDlmsDevice(deviceIdentification); LOGGER.info("Device for Activity Calendar is: {}", device); conn = this.dlmsConnectionFactory.getConnection(device); this.setActivityCalendarCommandExecutor.execute(conn, activityCalendar); final MethodResultCode methodResult = this.setActivityCalendarCommandActivationExecutor.execute(conn, null); <START> if (MethodResultCode.SUCCESS != methodResult) { <END> throw new ProtocolAdapterException("AccessResultCode for set Activity Calendar: " + methodResult); } this.sendResponseMessage(messageMetadata, ResponseMessageResultType.OK, null, responseMessageSender, "Set Activity Calendar Result is OK for device id: " + deviceIdentification + " calendar name: " + activityCalendar.getCalendarName()); } catch (final Exception e) { LOGGER.error("Unexpected exception during setActivityCalendar", e); final OsgpException ex = this.ensureOsgpException(e); this.sendResponseMessage(messageMetadata, ResponseMessageResultType.NOT_OK, ex, responseMessageSender); } finally { if (conn != null && conn.isConnected()) { LOGGER.info("Closing connection with {}", device.getDeviceIdentification()); conn.close(); } } }</code><technical_language>equals instead of !=. Handling of AccessResultCode in this class is done right for example</technical_language>

Target:
public void setActivityCalendar(final DlmsDeviceMessageMetadata messageMetadata, final ActivityCalendar activityCalendar, final DeviceResponseMessageSender responseMessageSender) { this.logStart(LOGGER, messageMetadata, "setActivityCalendar"); ClientConnection conn = null; DlmsDevice device = null; try { final String deviceIdentification = messageMetadata.getDeviceIdentification(); device = this.domainHelperService.findDlmsDevice(deviceIdentification); LOGGER.info("Device for Activity Calendar is: {}", device); conn = this.dlmsConnectionFactory.getConnection(device); this.setActivityCalendarCommandExecutor.execute(conn, activityCalendar); final MethodResultCode methodResult = this.setActivityCalendarCommandActivationExecutor.execute(conn, null); if (!MethodResultCode.SUCCESS.equals(methodResult)) { throw new ProtocolAdapterException("AccessResultCode for set Activity Calendar: " + methodResult); } this.sendResponseMessage(messageMetadata, ResponseMessageResultType.OK, null, responseMessageSender, "Set Activity Calendar Result is OK for device id: " + deviceIdentification + " calendar name: " + activityCalendar.getCalendarName()); } catch (final Exception e) { LOGGER.error("Unexpected exception during setActivityCalendar", e); final OsgpException ex = this.ensureOsgpException(e); this.sendResponseMessage(messageMetadata, ResponseMessageResultType.NOT_OK, ex, responseMessageSender); } finally { if (conn != null && conn.isConnected()) { LOGGER.info("Closing connection with {}", device.getDeviceIdentification()); conn.close(); } } }