projects
/
jFCPlib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clean up imports
[jFCPlib.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
fcp
/
FcpConnection.java
diff --git
a/src/main/java/net/pterodactylus/fcp/FcpConnection.java
b/src/main/java/net/pterodactylus/fcp/FcpConnection.java
index
84f7ce9
..
cc13d4a
100644
(file)
--- a/
src/main/java/net/pterodactylus/fcp/FcpConnection.java
+++ b/
src/main/java/net/pterodactylus/fcp/FcpConnection.java
@@
-31,8
+31,6
@@
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import java.util.Map;
import java.util.logging.Logger;
-import net.pterodactylus.util.logging.Logging;
-
/**
* An FCP connection to a Freenet node.
*
/**
* An FCP connection to a Freenet node.
*
@@
-41,7
+39,7
@@
import net.pterodactylus.util.logging.Logging;
public class FcpConnection implements Closeable {
/** Logger. */
public class FcpConnection implements Closeable {
/** Logger. */
- private static final Logger logger = Logg
ing
.getLogger(FcpConnection.class.getName());
+ private static final Logger logger = Logg
er
.getLogger(FcpConnection.class.getName());
/** The default port for FCP v2. */
public static final int DEFAULT_PORT = 9481;
/** The default port for FCP v2. */
public static final int DEFAULT_PORT = 9481;
@@
-68,7
+66,7
@@
public class FcpConnection implements Closeable {
private FcpConnectionHandler connectionHandler;
/** Incoming message statistics. */
private FcpConnectionHandler connectionHandler;
/** Incoming message statistics. */
- private Map<String, Integer> incomingMessageStatistics = Collections.synchronizedMap(new HashMap<String, Integer>());
+ private
static final
Map<String, Integer> incomingMessageStatistics = Collections.synchronizedMap(new HashMap<String, Integer>());
/**
* Creates a new FCP connection to the freenet node running on localhost,
/**
* Creates a new FCP connection to the freenet node running on localhost,
@@
-134,6
+132,10
@@
public class FcpConnection implements Closeable {
this.port = port;
}
this.port = port;
}
+ public synchronized boolean isClosed() {
+ return connectionHandler == null;
+ }
+
//
// LISTENER MANAGEMENT
//
//
// LISTENER MANAGEMENT
//
@@
-193,9
+195,10
@@
public class FcpConnection implements Closeable {
}
/**
}
/**
- * Closes the connection. If there is no connection to the node, this
method
- * does nothing.
+ * Closes the connection. If there is no connection to the node, this
+ *
method
does nothing.
*/
*/
+ @Override
public void close() {
handleDisconnect(null);
}
public void close() {
handleDisconnect(null);
}
@@
-323,8
+326,8
@@
public class FcpConnection implements Closeable {
* Handles a disconnect from the node.
*
* @param throwable
* Handles a disconnect from the node.
*
* @param throwable
- * The exception that caused the disconnect, or
<code>null</code>
- * if there was no exception
+ * The exception that caused the disconnect, or
+ *
<code>null</code>
if there was no exception
*/
synchronized void handleDisconnect(Throwable throwable) {
FcpUtils.close(remoteInputStream);
*/
synchronized void handleDisconnect(Throwable throwable) {
FcpUtils.close(remoteInputStream);
@@
-372,8
+375,8
@@
public class FcpConnection implements Closeable {
}
/**
}
/**
- * A wrapper around an {@link InputStream} that only supplies a limit
number
- * of bytes from the underlying input stream.
+ * A wrapper around an {@link InputStream} that only supplies a limit
+ *
number
of bytes from the underlying input stream.
*
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
*
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
@@
-454,7
+457,7
@@
public class FcpConnection implements Closeable {
* @see java.io.FilterInputStream#mark(int)
*/
@Override
* @see java.io.FilterInputStream#mark(int)
*/
@Override
- public void mark(int readlimit) {
+ public
synchronized
void mark(int readlimit) {
/* do nothing. */
}
/* do nothing. */
}
@@
-476,7
+479,7
@@
public class FcpConnection implements Closeable {
* @see java.io.FilterInputStream#reset()
*/
@Override
* @see java.io.FilterInputStream#reset()
*/
@Override
- public void reset() throws IOException {
+ public
synchronized
void reset() throws IOException {
/* do nothing. */
}
/* do nothing. */
}