From: David ‘Bombe’ Roden Date: Wed, 25 Jun 2014 18:20:17 +0000 (+0200) Subject: Declare variables closer to where they’re first used. X-Git-Tag: 0.9-rc1^2~3^2~231 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=00a7e47e114cf24f9ab5731bcbe1abeafe435577;p=Sone.git Declare variables closer to where they’re first used. --- 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);