⬆️ Update Guava to 27.0.1
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 2 Mar 2019 19:32:38 +0000 (20:32 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 2 Mar 2019 19:32:38 +0000 (20:32 +0100)
build.gradle
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/data/Profile.java
src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java
src/main/java/net/pterodactylus/sone/data/impl/ImageImpl.java
src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java
src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java

index 5334200..7e5604f 100644 (file)
@@ -46,7 +46,7 @@ dependencies {
     compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib'
     compile group: 'net.pterodactylus', name: 'utils', version: '0.12.4'
     compile group: 'com.google.inject', name: 'guice', version: '3.0'
-    compile group: 'com.google.guava', name: 'guava', version: '14.0.1'
+    compile group: 'com.google.guava', name: 'guava', version: '27.0.1-android'
     compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.1'
     compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.9.1'
     compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
index 0bc64bf..b0df7a9 100644 (file)
@@ -1328,7 +1328,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                identityManager.start();
                webOfTrustUpdater.init();
                webOfTrustUpdater.start();
-               database.start();
+               database.startAsync();
        }
 
        /**
@@ -1368,7 +1368,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                        }
                }
                saveConfiguration();
-               database.stop();
+               database.stopAsync();
                webOfTrustUpdater.stop();
                updateChecker.stop();
                soneDownloader.stop();
index 7d8a0bd..76e0acf 100644 (file)
@@ -20,6 +20,7 @@ package net.pterodactylus.sone.data;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -429,34 +430,34 @@ public class Profile implements Fingerprintable {
        @Override
        public String getFingerprint() {
                Hasher hash = Hashing.sha256().newHasher();
-               hash.putString("Profile(");
+               hash.putString("Profile(", UTF_8);
                if (firstName != null) {
-                       hash.putString("FirstName(").putString(firstName).putString(")");
+                       hash.putString("FirstName(", UTF_8).putString(firstName, UTF_8).putString(")", UTF_8);
                }
                if (middleName != null) {
-                       hash.putString("MiddleName(").putString(middleName).putString(")");
+                       hash.putString("MiddleName(", UTF_8).putString(middleName, UTF_8).putString(")", UTF_8);
                }
                if (lastName != null) {
-                       hash.putString("LastName(").putString(lastName).putString(")");
+                       hash.putString("LastName(", UTF_8).putString(lastName, UTF_8).putString(")", UTF_8);
                }
                if (birthDay != null) {
-                       hash.putString("BirthDay(").putInt(birthDay).putString(")");
+                       hash.putString("BirthDay(", UTF_8).putInt(birthDay).putString(")", UTF_8);
                }
                if (birthMonth != null) {
-                       hash.putString("BirthMonth(").putInt(birthMonth).putString(")");
+                       hash.putString("BirthMonth(", UTF_8).putInt(birthMonth).putString(")", UTF_8);
                }
                if (birthYear != null) {
-                       hash.putString("BirthYear(").putInt(birthYear).putString(")");
+                       hash.putString("BirthYear(", UTF_8).putInt(birthYear).putString(")", UTF_8);
                }
                if (avatar != null) {
-                       hash.putString("Avatar(").putString(avatar).putString(")");
+                       hash.putString("Avatar(", UTF_8).putString(avatar, UTF_8).putString(")", UTF_8);
                }
-               hash.putString("ContactInformation(");
+               hash.putString("ContactInformation(", UTF_8);
                for (Field field : fields) {
-                       hash.putString(field.getName()).putString("(").putString(field.getValue()).putString(")");
+                       hash.putString(field.getName(), UTF_8).putString("(", UTF_8).putString(field.getValue(), UTF_8).putString(")", UTF_8);
                }
-               hash.putString(")");
-               hash.putString(")");
+               hash.putString(")", UTF_8);
+               hash.putString(")", UTF_8);
 
                return hash.hash().toString();
        }
index b910fdd..3ec362f 100644 (file)
@@ -21,6 +21,7 @@ import static com.google.common.base.Optional.absent;
 import static com.google.common.base.Optional.fromNullable;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -296,28 +297,28 @@ public class AlbumImpl implements Album {
        @Override
        public String getFingerprint() {
                Hasher hash = Hashing.sha256().newHasher();
-               hash.putString("Album(");
-               hash.putString("ID(").putString(id).putString(")");
-               hash.putString("Title(").putString(title).putString(")");
-               hash.putString("Description(").putString(description).putString(")");
+               hash.putString("Album(", UTF_8);
+               hash.putString("ID(", UTF_8).putString(id, UTF_8).putString(")", UTF_8);
+               hash.putString("Title(", UTF_8).putString(title, UTF_8).putString(")", UTF_8);
+               hash.putString("Description(", UTF_8).putString(description, UTF_8).putString(")", UTF_8);
 
                /* add nested albums. */
-               hash.putString("Albums(");
+               hash.putString("Albums(", UTF_8);
                for (Album album : albums) {
-                       hash.putString(album.getFingerprint());
+                       hash.putString(album.getFingerprint(), UTF_8);
                }
-               hash.putString(")");
+               hash.putString(")", UTF_8);
 
                /* add images. */
-               hash.putString("Images(");
+               hash.putString("Images(", UTF_8);
                for (Image image : getImages()) {
                        if (image.isInserted()) {
-                               hash.putString(image.getFingerprint());
+                               hash.putString(image.getFingerprint(), UTF_8);
                        }
                }
-               hash.putString(")");
+               hash.putString(")", UTF_8);
 
-               hash.putString(")");
+               hash.putString(")", UTF_8);
                return hash.hash().toString();
        }
 
index 84e8d1d..a54a8de 100644 (file)
@@ -21,6 +21,7 @@ import static com.google.common.base.Optional.fromNullable;
 import static com.google.common.base.Optional.of;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.util.UUID;
 
@@ -246,11 +247,11 @@ public class ImageImpl implements Image {
        @Override
        public String getFingerprint() {
                Hasher hash = Hashing.sha256().newHasher();
-               hash.putString("Image(");
-               hash.putString("ID(").putString(id).putString(")");
-               hash.putString("Title(").putString(title).putString(")");
-               hash.putString("Description(").putString(description).putString(")");
-               hash.putString(")");
+               hash.putString("Image(", UTF_8);
+               hash.putString("ID(", UTF_8).putString(id, UTF_8).putString(")", UTF_8);
+               hash.putString("Title(", UTF_8).putString(title, UTF_8).putString(")", UTF_8);
+               hash.putString("Description(", UTF_8).putString(description, UTF_8).putString(")", UTF_8);
+               hash.putString(")", UTF_8);
                return hash.hash().toString();
        }
 
index ce0f5c1..3366448 100644 (file)
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.data.impl;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static java.lang.String.format;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static java.util.logging.Logger.getLogger;
 
 import java.net.MalformedURLException;
@@ -634,46 +635,46 @@ public class SoneImpl implements Sone {
        @Override
        public synchronized String getFingerprint() {
                Hasher hash = Hashing.sha256().newHasher();
-               hash.putString(profile.getFingerprint());
+               hash.putString(profile.getFingerprint(), UTF_8);
 
-               hash.putString("Posts(");
+               hash.putString("Posts(", UTF_8);
                for (Post post : getPosts()) {
-                       hash.putString("Post(").putString(post.getId()).putString(")");
+                       hash.putString("Post(", UTF_8).putString(post.getId(), UTF_8).putString(")", UTF_8);
                }
-               hash.putString(")");
+               hash.putString(")", UTF_8);
 
                List<PostReply> replies = new ArrayList<>(getReplies());
                Collections.sort(replies, Reply.TIME_COMPARATOR);
-               hash.putString("Replies(");
+               hash.putString("Replies(", UTF_8);
                for (PostReply reply : replies) {
-                       hash.putString("Reply(").putString(reply.getId()).putString(")");
+                       hash.putString("Reply(", UTF_8).putString(reply.getId(), UTF_8).putString(")", UTF_8);
                }
-               hash.putString(")");
+               hash.putString(")", UTF_8);
 
                List<String> likedPostIds = new ArrayList<>(getLikedPostIds());
                Collections.sort(likedPostIds);
-               hash.putString("LikedPosts(");
+               hash.putString("LikedPosts(", UTF_8);
                for (String likedPostId : likedPostIds) {
-                       hash.putString("Post(").putString(likedPostId).putString(")");
+                       hash.putString("Post(", UTF_8).putString(likedPostId, UTF_8).putString(")", UTF_8);
                }
-               hash.putString(")");
+               hash.putString(")", UTF_8);
 
                List<String> likedReplyIds = new ArrayList<>(getLikedReplyIds());
                Collections.sort(likedReplyIds);
-               hash.putString("LikedReplies(");
+               hash.putString("LikedReplies(", UTF_8);
                for (String likedReplyId : likedReplyIds) {
-                       hash.putString("Reply(").putString(likedReplyId).putString(")");
+                       hash.putString("Reply(", UTF_8).putString(likedReplyId, UTF_8).putString(")", UTF_8);
                }
-               hash.putString(")");
+               hash.putString(")", UTF_8);
 
-               hash.putString("Albums(");
+               hash.putString("Albums(", UTF_8);
                for (Album album : rootAlbum.getAlbums()) {
                        if (!Album.NOT_EMPTY.apply(album)) {
                                continue;
                        }
-                       hash.putString(album.getFingerprint());
+                       hash.putString(album.getFingerprint(), UTF_8);
                }
-               hash.putString(")");
+               hash.putString(")", UTF_8);
 
                return hash.hash().toString();
        }
index 94eabb0..31d7b6b 100644 (file)
@@ -1,7 +1,7 @@
 package net.pterodactylus.sone.core;
 
 import static com.google.common.io.ByteStreams.toByteArray;
-import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
+import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
 import static java.lang.System.currentTimeMillis;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.containsString;
@@ -64,7 +64,7 @@ public class SoneInserterTest {
 
        @Test
        public void insertionDelayIsForwardedToSoneInserter() {
-               EventBus eventBus = new AsyncEventBus(sameThreadExecutor());
+               EventBus eventBus = new AsyncEventBus(directExecutor());
                eventBus.register(new SoneInserter(core, eventBus, freenetInterface, "SoneId"));
                eventBus.post(new InsertionDelayChangedEvent(15));
                assertThat(SoneInserter.getInsertionDelay().get(), is(15));