From: David ‘Bombe’ Roden Date: Thu, 19 Mar 2009 23:21:27 +0000 (+0100) Subject: Factor out request identifier creation. X-Git-Tag: v0.1.1~74 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b782bfe5ddfe62489591eda0537a9c335ed4c624;p=jFCPlib.git Factor out request identifier creation. --- diff --git a/src/net/pterodactylus/fcp/highlevel/FcpClient.java b/src/net/pterodactylus/fcp/highlevel/FcpClient.java index 2bdcf73..1b695e9 100644 --- a/src/net/pterodactylus/fcp/highlevel/FcpClient.java +++ b/src/net/pterodactylus/fcp/highlevel/FcpClient.java @@ -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.