### Question:
Poller { @SuppressWarnings({ "unchecked" }) public void start() { if (log.isDebugEnabled()) log.debug("Starting poll for {} (using {})", new Object[] {entity, this}); if (started) { throw new IllegalStateException(String.format("Attempt to start poller %s of entity %s when already running", this, entity)); } started = true; for (final Callable<?> oneOffJob : oneOffJobs) { Task<?> task = Tasks.builder().dynamic(false).body((Callable<Object>) oneOffJob).displayName("Poll").description("One-time poll job "+oneOffJob).build(); oneOffTasks.add(((EntityInternal)entity).getExecutionContext().submit(task)); } for (final PollJob<V> pollJob : pollJobs) { final String scheduleName = pollJob.handler.getDescription(); if (pollJob.pollPeriod.compareTo(Duration.ZERO) > 0) { Callable<Task<?>> pollingTaskFactory = new Callable<Task<?>>() { public Task<?> call() { DynamicSequentialTask<Void> task = new DynamicSequentialTask<Void>(MutableMap.of("displayName", scheduleName, "entity", entity), new Callable<Void>() { public Void call() { if (onlyIfServiceUp && !Boolean.TRUE.equals(entity.getAttribute(Attributes.SERVICE_UP))) { return null; } pollJob.wrappedJob.run(); return null; } } ); BrooklynTaskTags.setTransient(task); return task; } }; Map<String, ?> taskFlags = MutableMap.of("displayName", "scheduled:" + scheduleName); ScheduledTask task = new ScheduledTask(taskFlags, pollingTaskFactory) .period(pollJob.pollPeriod) .cancelOnException(false); tasks.add(Entities.submit(entity, task)); } else { if (log.isDebugEnabled()) log.debug("Activating poll (but leaving off, as period {}) for {} (using {})", new Object[] {pollJob.pollPeriod, entity, this}); } } } @Deprecated  Poller(EntityLocal entity);  Poller(EntityLocal entity, boolean onlyIfServiceUp); void submit(Callable<?> job); void scheduleAtFixedRate(Callable<V> job, PollHandler<? super V> handler, long period); void scheduleAtFixedRate(Callable<V> job, PollHandler<? super V> handler, Duration period); @SuppressWarnings({ "unchecked" }) void start(); void stop(); boolean isRunning(); String toString(); static final Logger log; }### Answer:
@Test(dataProvider = "specProvider") public void testFeedContinuesWhenPollerThrows(EntitySpec<FeedExceptionEntity> spec) { Map<?, ?> timeoutFlags = ImmutableMap.of("timeout", "100ms"); FeedExceptionEntity fee = app.createAndManageChild(spec); app.start(ImmutableList.of(app.newSimulatedLocation())); EntityAsserts.assertAttributeEqualsEventually(timeoutFlags, fee, FeedExceptionEntity.FLAG, true); fee.startThrowingPollExceptions(); EntityAsserts.assertAttributeEqualsEventually(timeoutFlags, fee, FeedExceptionEntity.FLAG, false); EntityAsserts.assertAttributeEqualsContinually(timeoutFlags, fee, FeedExceptionEntity.FLAG, false); fee.stopThrowingPollExceptions(); EntityAsserts.assertAttributeEqualsEventually(timeoutFlags, fee, FeedExceptionEntity.FLAG, true); EntityAsserts.assertAttributeEqualsContinually(timeoutFlags, fee, FeedExceptionEntity.FLAG, true); }