#fixed code
                                @SuppressWarnings("unchecked")
    protected void onCommand(RTMPConnection conn, Channel channel, Header header, Notify notify) {
        super.onCommand(conn, channel, header, notify);
        System.out.println("onInvoke - header: " + header.toString() + " notify: " + notify.toString());
        Object obj = notify.getCall().getArguments().length > 0 ? notify.getCall().getArguments()[0] : null;
        if (obj instanceof Map) {
            Map<String, String> map = (Map<String, String>) obj;
            String code = map.get("code");
            if (StatusCodes.NS_PLAY_STOP.equals(code)) {
                finished = true;
                disconnect();
                System.out.println("Disconnected");
            }
        }

    }
#vulnerable code 
                                @SuppressWarnings("unchecked")
    protected void onCommand(RTMPConnection conn, Channel channel, Header header, Notify notify) {
        super.onCommand(conn, channel, header, notify);
        System.out.println("onInvoke, header = " + header.toString());
        System.out.println("onInvoke, notify = " + notify.toString());
        Object obj = notify.getCall().getArguments().length > 0 ? notify.getCall().getArguments()[0] : null;
        if (obj instanceof Map) {
            Map<String, String> map = (Map<String, String>) obj;
            String code = map.get("code");
            if (StatusCodes.NS_PLAY_STOP.equals(code)) {
                synchronized (ClientTest.class) {
                    finished = true;
                    ClientTest.class.notifyAll();
                }
                disconnect();
                System.out.println("Disconnected");
            }
        }

    } 
                            #location 3 
                            #vulnerability type THREAD_SAFETY_VIOLATION