#vulnerable code 
                                public void writeObjectData(ObjectOutputStream out) throws IOException {
        try (ObjectOutputStream outputStream = new ObjectOutputStream(out)) {
            if (this.principal instanceof Serializable) {
                outputStream.writeBoolean(true);
                outputStream.writeObject(this.principal);
            } else {
                outputStream.writeBoolean(false);
            }
            outputStream.flush();
        }
    } 
                            #location 5 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                public void writeObjectData(ObjectOutputStream out) throws IOException {
        try (ObjectOutputStream outputStream = new ObjectOutputStream(out)) {
            outputStream.writeObject(this);
            outputStream.flush();
        }
    }