private void sendAlert(byte level, byte description) {
        // the connectionState cannot be cs_START
        if (connectionState >= cs_CLOSED) {
            return;
        }

        // For initial handshaking, don't send alert message to peer if
        // handshaker has not started.
        if (connectionState == cs_HANDSHAKE &&
            (handshaker == null || !handshaker.started())) {
            return;
        }

        EngineOutputRecord r = new EngineOutputRecord(Record.ct_alert, this);
        r.setVersion(protocolVersion);

        boolean useDebug = debug != null && Debug.isOn("ssl");
        if (useDebug) {
            synchronized (System.out) {
                System.out.print(threadName());
                System.out.print(", SEND " + protocolVersion + " ALERT:  ");
                if (level == Alerts.alert_fatal) {
                    System.out.print("fatal, ");
                } else if (level == Alerts.alert_warning) {
                    System.out.print("warning, ");
                } else {
                    System.out.print("<level = " + (0x0ff & level) + ">, ");
                }
                System.out.println("description = "
                        + Alerts.alertDescription(description));
            }
        }

        r.write(level);
        r.write(description);
        try {
            writeRecord(r);
        } catch (IOException e) {
            if (useDebug) {
                System.out.println(threadName() +
                    ", Exception sending alert: " + e);
            }
        }
    }
private void sendAlert ( byte level , byte description ) { if ( connectionState >= cs_CLOSED ) { return ; } if ( connectionState == cs_HANDSHAKE && ( handshaker == null || ! handshaker . started ( ) ) ) { return ; } EngineOutputRecord r = new EngineOutputRecord ( Record . ct_alert , this ) ; r . setVersion ( protocolVersion ) ; boolean useDebug = debug != null && Debug . isOn ( "ssl" ) ; if ( useDebug ) { synchronized ( System . out ) { System . out . print ( threadName ( ) ) ; System . out . print ( ", SEND " + protocolVersion + " ALERT:  " ) ; if ( level == Alerts . alert_fatal ) { System . out . print ( "fatal, " ) ; } else if ( level == Alerts . alert_warning ) { System . out . print ( "warning, " ) ; } else { System . out . print ( "<level = " + ( 0x0ff & level ) + ">, " ) ; } System . out . println ( "description = " + Alerts . alertDescription ( description ) ) ; } } r . write ( level ) ; r . write ( description ) ; try { writeRecord ( r ) ; } catch ( IOException e ) { if ( useDebug ) { System . out . println ( threadName ( ) + ", Exception sending alert: " + e ) ; } } }
/*
Emit alerts.  Caller must have synchronized with "this".