Skip to content

Commit

Permalink
Fix Bug Illegal taskname in deleteReminderTask(). fixes #291 @1h
Browse files Browse the repository at this point in the history
  • Loading branch information
みぞ@CrazyBeatCoder committed Jan 21, 2018
1 parent 8786065 commit 61d683e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions lily-white-line-bot.iml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.9" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.9" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
</component>
</module>
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ Copyright 2015 Google Inc.
</dependency>
<!-- [END Jackson] -->

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>

</dependencies>
<build>
<!-- for hot reload of the web application -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.appengine.api.taskqueue.TaskOptions;
import com.mizo0203.lilywhite.push_task.ReminderTaskServlet;

import javax.annotation.Nonnull;
import java.util.logging.Logger;

/* package */ class PushQueueRepository {
Expand Down Expand Up @@ -43,7 +44,7 @@ protected String enqueueReminderTask(String source_id, long etaMillis, String me
.getName();
}

public void deleteReminderTask(String taskName) {
public void deleteReminderTask(@Nonnull String taskName) {
// Delete an individual task...
mQueue.deleteTask(taskName);
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/mizo0203/lilywhite/repo/Repository.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public void clearEvent(String sourceId) {
}

private void deleteReminderTask(LineTalkRoomConfig config) {
mPushQueueRepository.deleteReminderTask(config.getReminderEnqueuedTaskName());
String taskName = config.getReminderEnqueuedTaskName();
if (taskName == null || taskName.isEmpty()) {
return;
}
mPushQueueRepository.deleteReminderTask(taskName);
config.setReminderEnqueuedTaskName(null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.googlecode.objectify.annotation.Id;
import com.mizo0203.lilywhite.repo.objectify.OfyHelper;

import javax.annotation.Nullable;

/**
* The @Entity tells Objectify about our entity. We also register it in {@link OfyHelper} Our
* primary key @Id is set automatically by the Google Datastore for us.
Expand Down Expand Up @@ -50,6 +52,7 @@ public boolean isReminderEnqueued() {
return reminderEnqueuedTaskName != null;
}

@Nullable
public String getReminderEnqueuedTaskName() {
return reminderEnqueuedTaskName;
}
Expand Down

0 comments on commit 61d683e

Please sign in to comment.