При нажатии на кнопку валидации вылетает вот такая ошибка. Не могу понять - это какой-то мой косяк или сервера:
На всякий случай - код:
package com.javarush.task.task30.task3008.client;
import com.javarush.task.task30.task3008.Connection;
import com.javarush.task.task30.task3008.ConsoleHelper;
import com.javarush.task.task30.task3008.Message;
import com.javarush.task.task30.task3008.MessageType;
import java.io.IOException;
public class Client {
protected Connection connection;
private volatile boolean clientConnected = false;
public void run() {
getSocketThread().setDaemon(true);
getSocketThread().start();
try {
synchronized (this) {
this.wait();
}
} catch (InterruptedException e) {
ConsoleHelper.writeMessage("Возникла ошибка при попытке поставить текущий поток на ожидание;");
try {
connection.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
if (clientConnected) {
ConsoleHelper.writeMessage("Соединение установлено. Для выхода наберите команду 'exit'.");
} else ConsoleHelper.writeMessage("Произошла ошибка во время работы клиента.");
String text;
while (clientConnected) {
text = ConsoleHelper.readString();
if (text=="exit") break;
if (shouldSendTextFromConsole()) {
sendTextMessage(text);
}
}
}
protected String getServerAddress() {
System.out.println("введите адрес сервера: ");
return ConsoleHelper.readString();
}
protected int getServerPort(){
System.out.println("введите порт сервера: ");
return ConsoleHelper.readInt();
}
protected String getUserName() {
System.out.println("введите имя пользователя: ");
return ConsoleHelper.readString();
}
protected boolean shouldSendTextFromConsole(){
return true;
}
protected SocketThread getSocketThread(){
return new SocketThread();
}
protected void sendTextMessage(String text){
try {
connection.send(new Message(MessageType.TEXT, text));
} catch (IOException e) {
System.out.println("Возникло исключение;");
clientConnected = false;
}
}
public static void main(String[] args) {
Client client = new Client();
client.run();
}
public class SocketThread extends Thread{
protected void processIncomingMessage(String message) {
ConsoleHelper.writeMessage(message);
}
protected void informAboutAddingNewUser(String userName) {
ConsoleHelper.writeMessage("Участник " + userName + " подключился;");
}
protected void informAboutDeletingNewUser(String userName) {
ConsoleHelper.writeMessage("Участник " + userName + " покинул чат.");
}
protected void notifyConnectionStatusChanged(boolean clientConnected) {
Client.this.clientConnected = clientConnected;
synchronized (Client.this) {
Client.this.notify();
}
}
}
}