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'
identityManager.start();
webOfTrustUpdater.init();
webOfTrustUpdater.start();
- database.start();
+ database.startAsync();
}
/**
}
}
saveConfiguration();
- database.stop();
+ database.stopAsync();
webOfTrustUpdater.stop();
updateChecker.stop();
soneDownloader.stop();
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;
@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();
}
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;
@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();
}
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;
@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();
}
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;
@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();
}
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;
@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));