Factor out request identifier creation.
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 19 Mar 2009 23:21:27 +0000 (00:21 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 19 Mar 2009 23:21:27 +0000 (00:21 +0100)
src/net/pterodactylus/fcp/highlevel/FcpClient.java

index 2bdcf73..1b695e9 100644 (file)
@@ -205,7 +205,8 @@ public class FcpClient {
                new ExtendedFcpAdapter() {
 
                        /** The ID of the “ListPeers” request. */
-                       private String identifier = "list-peers-" + System.currentTimeMillis();
+                       @SuppressWarnings("synthetic-access")
+                       private String identifier = createIdentifier("list-peers");
 
                        /**
                         * {@inheritDoc}
@@ -533,6 +534,21 @@ public class FcpClient {
                return sskKeypairWrapper.get();
        }
 
+       //
+       // PRIVATE METHODS
+       //
+
+       /**
+        * Creates a unique request identifier.
+        *
+        * @param basename
+        *            The basename of the request
+        * @return The created request identifier
+        */
+       private String createIdentifier(String basename) {
+               return basename + "-" + System.currentTimeMillis() + "-" + (int) (Math.random() * Integer.MAX_VALUE);
+       }
+
        /**
         * Implementation of an {@link FcpListener} that can store an
         * {@link FcpException} and wait for the arrival of a certain command.