X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneInserter.java;h=ba5d0a93bfa7deb5c76bab89c26be732cd165e71;hp=26135eab701f49ddb385ca43f9393ba06c3754ed;hb=62573c314957b1851f4fbe693b8746686caa940a;hpb=87d9d82c6f671d69cba305b5ddf3cd81ecedc115 diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index 26135ea..ba5d0a9 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -59,7 +59,6 @@ import net.pterodactylus.util.template.XmlFilter; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Charsets; -import com.google.common.base.Optional; import com.google.common.collect.FluentIterable; import com.google.common.collect.Ordering; import com.google.common.eventbus.EventBus; @@ -73,8 +72,6 @@ import freenet.support.io.ArrayBucket; /** * A Sone inserter is responsible for inserting a Sone if it has changed. - * - * @author David ‘Bombe’ Roden */ public class SoneInserter extends AbstractService { @@ -125,20 +122,20 @@ public class SoneInserter extends AbstractService { this(core, eventBus, freenetInterface, soneId, new SoneModificationDetector(new LockableFingerprintProvider() { @Override public boolean isLocked() { - final Optional sone = core.getSone(soneId); - if (!sone.isPresent()) { + Sone sone = core.getSone(soneId); + if (sone == null) { return false; } - return core.isLocked(sone.get()); + return core.isLocked(sone); } @Override public String getFingerprint() { - final Optional sone = core.getSone(soneId); - if (!sone.isPresent()) { + Sone sone = core.getSone(soneId); + if (sone == null) { return null; } - return sone.get().getFingerprint(); + return sone.getFingerprint(); } }, insertionDelay), 1000); } @@ -219,12 +216,11 @@ public class SoneInserter extends AbstractService { sleep(delay); if (soneModificationDetector.isEligibleForInsert()) { - Optional soneOptional = core.getSone(soneId); - if (!soneOptional.isPresent()) { + Sone sone = core.getSone(soneId); + if (sone == null) { logger.log(Level.WARNING, format("Sone %s has disappeared, exiting inserter.", soneId)); return; } - Sone sone = soneOptional.get(); InsertInformation insertInformation = new InsertInformation(sone); logger.log(Level.INFO, String.format("Inserting Sone “%s”…", sone.getName())); @@ -282,8 +278,6 @@ public class SoneInserter extends AbstractService { * Container for information that are required to insert a Sone. This * container merely exists to copy all relevant data without holding a lock * on the {@link Sone} object for too long. - * - * @author David ‘Bombe’ Roden */ @VisibleForTesting class InsertInformation implements Closeable { @@ -358,8 +352,6 @@ public class SoneInserter extends AbstractService { /** * Creates manifest elements for an insert by rendering a template. - * - * @author David ‘Bombe’ Roden */ @VisibleForTesting static class ManifestCreator implements Closeable {