fix callback handling 32/20632/2
authorMartin Bobak <mbobak@cisco.com>
Mon, 18 May 2015 09:25:42 +0000 (11:25 +0200)
committerMartin Bobak <mbobak@cisco.com>
Mon, 18 May 2015 12:29:16 +0000 (14:29 +0200)
Change-Id: I911d8614d8ad477b5f856e67caf94e05bfde064d
Signed-off-by: Martin Bobak <mbobak@cisco.com>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/PacketProcessingServiceImpl.java

index 2308fc126be931be74fef99dfd6738e808586d6a..db78b0036456374a2a64e4bdc2376b4a1a8cde04 100644 (file)
@@ -23,7 +23,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
+import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 public class PacketProcessingServiceImpl extends CommonService implements PacketProcessingService {
 
@@ -49,24 +51,16 @@ public class PacketProcessingServiceImpl extends CommonService implements Packet
                 outboundQueue.commitEntry(xid.getValue(), message, new FutureCallback<OfHeader>() {
                     @Override
                     public void onSuccess(final OfHeader ofHeader) {
-                        if (ofHeader instanceof RpcResult) {
-                            @SuppressWarnings("unchecked")
-                            RpcResult<Void> rpcResult = (RpcResult<Void>) ofHeader;
-                            if (!rpcResult.isSuccessful()) {
-                                getMessageSpy().spyMessage(message.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-                                settableFuture.set(rpcResult);
-                            } else {
-                                getMessageSpy().spyMessage(message.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
-                                settableFuture.cancel(true);
-                            }
-                        }
+                        getMessageSpy().spyMessage(message.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_SUCCESS);
+                        final RpcResultBuilder<Void> rpcResultBuilder = RpcResultBuilder.<Void>success();
+                        settableFuture.set(rpcResultBuilder.build());
                     }
 
                     @Override
                     public void onFailure(final Throwable throwable) {
                         getMessageSpy().spyMessage(message.getImplementedInterface(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMIT_FAILURE);
-
-                        settableFuture.cancel(true);
+                        final RpcResultBuilder<Void> rpcResultBuilder = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, throwable.getMessage(), throwable);
+                        settableFuture.set(rpcResultBuilder.build());
                     }
                 });
                 return settableFuture;