Declare variables closer to where they’re first used.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 25 Jun 2014 18:20:17 +0000 (20:20 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 25 Jun 2014 18:20:17 +0000 (20:20 +0200)
src/main/java/net/pterodactylus/sone/core/FreenetInterface.java
src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManager.java
src/main/java/net/pterodactylus/sone/web/UploadImagePage.java

index e92cf8e..914e9a7 100644 (file)
@@ -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) {
index 77e0480..9f9ab7f 100644 (file)
@@ -167,12 +167,11 @@ public class IdentityManager extends AbstractService {
                        Map<OwnIdentity, Map<String, Identity>> currentIdentities = new HashMap<OwnIdentity, Map<String, Identity>>();
                        Map<String, OwnIdentity> currentOwnIdentities = new HashMap<String, OwnIdentity>();
 
-                       Set<OwnIdentity> 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<OwnIdentity> ownIdentities = webOfTrustConnector.loadAllOwnIdentities();
                                logger.finest(String.format("Loaded %d Own Identities.", ownIdentities.size()));
 
                                /* load trusted identities. */
index 3844082..2079cac 100644 (file)
@@ -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);