Change to fix spurious stack trace on connection close, #34
This commit is contained in:
parent
c0e97f8138
commit
387da6e6cd
|
|
@ -14,6 +14,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import javax.net.SocketFactory;
|
import javax.net.SocketFactory;
|
||||||
import me.legrange.mikrotik.ApiConnection;
|
import me.legrange.mikrotik.ApiConnection;
|
||||||
import me.legrange.mikrotik.ApiConnectionException;
|
import me.legrange.mikrotik.ApiConnectionException;
|
||||||
|
|
@ -199,18 +201,25 @@ public final class ApiConnectionImpl extends ApiConnection {
|
||||||
try {
|
try {
|
||||||
String s = Util.decode(in);
|
String s = Util.decode(in);
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
queue.put(s);
|
put(s);
|
||||||
}
|
}
|
||||||
} catch (ApiDataException ex) {
|
} catch (ApiDataException ex) {
|
||||||
|
put(ex);
|
||||||
|
} catch (ApiConnectionException ex) {
|
||||||
|
if (connected || !sock.isClosed()) {
|
||||||
|
put(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void put(Object data) {
|
||||||
try {
|
try {
|
||||||
queue.put(ex);
|
queue.put(data);
|
||||||
} catch (InterruptedException ex2) {
|
} catch (InterruptedException ex) {
|
||||||
}
|
|
||||||
} catch (ApiConnectionException | InterruptedException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final LinkedBlockingQueue queue = new LinkedBlockingQueue(40);
|
private final LinkedBlockingQueue queue = new LinkedBlockingQueue(40);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue