/*
 * Copyright 2002-2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.reactive.web.dispatch;

import org.reactivestreams.Publisher;

import org.springframework.core.Ordered;
import org.springframework.reactive.web.http.ServerHttpRequest;
import org.springframework.reactive.web.http.ServerHttpResponse;

/**
 * Supports {@link HandlerResult} with a {@code Publisher<Void>} value.
 *
 * @author Sebastien Deleuze
 */
public class SimpleHandlerResultHandler implements Ordered, HandlerResultHandler {

	private int order = Ordered.LOWEST_PRECEDENCE;

	@Override
	public int getOrder() {
		return this.order;
	}

	@Override
	public boolean supports(HandlerResult result) {
		Object value = result.getValue();
		return value != null && Publisher.class.isAssignableFrom(value.getClass());
	}

	@Override
	public Publisher<Void> handleResult(ServerHttpRequest request, ServerHttpResponse response, HandlerResult result) {
		return (Publisher<Void>)result.getValue();
	}
}

@@ -704,16 +704,43 @@
 blisher;
+%0Aimport reactor.Publishers;
 %0A%0Aimport
@@ -1525,16 +1525,39 @@
 %09return 
+Publishers.completable(
 (Publish
@@ -1559,20 +1559,17 @@
 blisher%3C
-Void
+?
 %3E)result
@@ -1579,15 +1579,16 @@
 tValue()
+)
 ;%0A%09%7D%0A%7D%0A

Fix SimpleHandlerResultHandler by using Publishers.completable()