From 00a7e47e114cf24f9ab5731bcbe1abeafe435577 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 25 Jun 2014 20:20:17 +0200 Subject: [PATCH] =?utf8?q?Declare=20variables=20closer=20to=20where=20they?= =?utf8?q?=E2=80=99re=20first=20used.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/core/FreenetInterface.java | 3 +-- src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManager.java | 3 +-- src/main/java/net/pterodactylus/sone/web/UploadImagePage.java | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java index e92cf8e..914e9a7 100644 --- a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java +++ b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java @@ -111,11 +111,10 @@ public class FreenetInterface { * @return The result of the fetch, or {@code null} if an error occured */ public Fetched fetchUri(FreenetURI uri) { - FetchResult fetchResult = null; FreenetURI currentUri = new FreenetURI(uri); while (true) { try { - fetchResult = client.fetch(currentUri); + FetchResult fetchResult = client.fetch(currentUri); return new Fetched(currentUri, fetchResult); } catch (FetchException fe1) { if (fe1.getMode() == FetchException.PERMANENT_REDIRECT) { diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManager.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManager.java index 77e0480..9f9ab7f 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManager.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManager.java @@ -167,12 +167,11 @@ public class IdentityManager extends AbstractService { Map> currentIdentities = new HashMap>(); Map currentOwnIdentities = new HashMap(); - Set ownIdentities = null; boolean identitiesLoaded = false; try { /* get all identities with the wanted context from WoT. */ logger.finer("Getting all Own Identities from WoT..."); - ownIdentities = webOfTrustConnector.loadAllOwnIdentities(); + Set ownIdentities = webOfTrustConnector.loadAllOwnIdentities(); logger.finest(String.format("Loaded %d Own Identities.", ownIdentities.size())); /* load trusted identities. */ diff --git a/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java b/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java index 3844082..2079cac 100644 --- a/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java +++ b/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java @@ -96,7 +96,6 @@ public class UploadImagePage extends SoneTemplatePage { Bucket fileBucket = uploadedFile.getData(); InputStream imageInputStream = null; ByteArrayOutputStream imageDataOutputStream = null; - net.pterodactylus.sone.data.Image image = null; try { imageInputStream = fileBucket.getInputStream(); /* TODO - check length */ @@ -122,7 +121,7 @@ public class UploadImagePage extends SoneTemplatePage { } String mimeType = getMimeType(imageData); TemporaryImage temporaryImage = webInterface.getCore().createTemporaryImage(mimeType, imageData); - image = webInterface.getCore().createImage(currentSone, parent, temporaryImage); + net.pterodactylus.sone.data.Image image = webInterface.getCore().createImage(currentSone, parent, temporaryImage); image.modify().setTitle(name).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)).setWidth(uploadedImage.getWidth(null)).setHeight(uploadedImage.getHeight(null)).update(); } catch (IOException ioe1) { logger.log(Level.WARNING, "Could not read uploaded image!", ioe1); -- 2.7.4