#vulnerable code 
                                public static Optional<TimeUntilDisconnectNotification> fromMessage(final Message msg) {

        if (MessageHelper.isDeviceCurrentlyConnected(msg)) {
            final String tenantId = MessageHelper.getTenantIdAnnotation(msg);
            final String deviceId = MessageHelper.getDeviceId(msg);

            if (tenantId != null && deviceId != null) {
                final Integer ttd = MessageHelper.getTimeUntilDisconnect(msg);
                final Instant creationTime = Instant.ofEpochMilli(msg.getCreationTime());

                final TimeUntilDisconnectNotification notification =
                        new TimeUntilDisconnectNotification(tenantId, deviceId, getReadyUntilInstantFromTtd(ttd, creationTime));
                return Optional.of(notification);
            }
        }

        return Optional.empty();
    } 
                            #location 12 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                public static Optional<TimeUntilDisconnectNotification> fromMessage(final Message msg) {

        final Integer ttd = MessageHelper.getTimeUntilDisconnect(msg);

        if (ttd == null) {
            return Optional.empty();
        } else if (ttd == 0 || MessageHelper.isDeviceCurrentlyConnected(msg)) {
            final String tenantId = MessageHelper.getTenantIdAnnotation(msg);
            final String deviceId = MessageHelper.getDeviceId(msg);

            if (tenantId != null && deviceId != null) {
                final Instant creationTime = Instant.ofEpochMilli(msg.getCreationTime());

                final TimeUntilDisconnectNotification notification =
                        new TimeUntilDisconnectNotification(tenantId, deviceId, getReadyUntilInstantFromTtd(ttd, creationTime));
                return Optional.of(notification);
            }
        }
        return Optional.empty();
    }