!htp #18028 fix signature of Java-side handleWebsocketMessages directive

This commit is contained in:
Johannes Rudolph 2015-07-23 16:48:42 +02:00
parent 9a3d8104fd
commit 3e7621c836
3 changed files with 3 additions and 10 deletions

View file

@ -31,9 +31,9 @@ public class WebsocketRoutingExample extends HttpApp {
* A handler that treats incoming messages as a name,
* and responds with a greeting to that name
*/
public static Flow<Message, Message, Object> greeter() {
public static Flow<Message, Message, ?> greeter() {
return
upcastMaterializerToObject(Flow.<Message>create())
Flow.<Message>create()
.collect(new JavaPartialFunction<Message, Message>() {
@Override
public Message apply(Message msg, boolean isCheck) throws Exception {
@ -51,10 +51,4 @@ public class WebsocketRoutingExample extends HttpApp {
else // ... this would suffice to handle all text messages in a streaming fashion
return TextMessage.create(Source.single("Hello ").concat(msg.getStreamedText()));
}
// needed because of #18028, see https://github.com/akka/akka/issues/18028
@SuppressWarnings("unchecked")
public static <T, U> Flow<T, U, Object> upcastMaterializerToObject(Flow< T, U, ?> flow) {
return (Flow<T, U, Object>) flow;
}
}

View file

@ -4,7 +4,6 @@
package akka.http.javadsl.model.ws
import akka.stream.Materializer
import akka.stream.javadsl.Flow
import akka.http.javadsl.model._
import akka.http.impl.util.JavaMapping.Implicits._

View file

@ -14,6 +14,6 @@ abstract class WebsocketDirectives extends SchemeDirectives {
* Handles websocket requests with the given handler and rejects other requests with a
* [[ExpectedWebsocketRequestRejection]].
*/
def handleWebsocketMessages(handler: Flow[Message, Message, Any]): Route =
def handleWebsocketMessages(handler: Flow[Message, Message, _]): Route =
RouteStructure.HandleWebsocketMessages(handler)
}