X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneInserter.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneInserter.java;h=3c32f7f3dea049221ef21475593ee2f97f1969de;hp=26135eab701f49ddb385ca43f9393ba06c3754ed;hb=8e313509a42a8c638fcac018dd73dd975bf9cb68;hpb=943bbf6848a5975cb994f75f812ef215af62475f diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index 26135ea..3c32f7f 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; @@ -125,20 +124,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 +218,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()));