From b782bfe5ddfe62489591eda0537a9c335ed4c624 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 20 Mar 2009 00:21:27 +0100 Subject: [PATCH] Factor out request identifier creation. --- src/net/pterodactylus/fcp/highlevel/FcpClient.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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. -- 2.7.4