From 1bbdb10607c6c198cb80ec506cd5637098bb917d Mon Sep 17 00:00:00 2001 From: Jakub Morvay Date: Thu, 14 Jan 2016 17:02:42 +0100 Subject: [PATCH] Bug 4455 - Inconsistent COMMIT operation handling when no transactions are present Return positive response for commit operation in config subsystem netconf northbound even if no candidate transaction is open for session. Need to be merged after https://git.opendaylight.org/gerrit/#/c/32598/ Change-Id: Ia6ce2aa6ffdfafc47f69ae7315669f64b653c514 Signed-off-by: Jakub Morvay --- .../NoTransactionFoundException.java | 27 ------------------- .../xml/transactions/TransactionProvider.java | 15 +++++------ 2 files changed, 6 insertions(+), 36 deletions(-) delete mode 100644 opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/exception/NoTransactionFoundException.java diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/exception/NoTransactionFoundException.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/exception/NoTransactionFoundException.java deleted file mode 100644 index c1a9def35d..0000000000 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/exception/NoTransactionFoundException.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.config.facade.xml.exception; - -import java.util.Collections; -import java.util.Map; -import org.opendaylight.controller.config.util.xml.DocumentedException; - -public class NoTransactionFoundException extends DocumentedException { - private static final long serialVersionUID = 1L; - - public NoTransactionFoundException(final String message, final ErrorType errorType, final ErrorTag errorTag, - final ErrorSeverity errorSeverity) { - this(message, errorType, errorTag, errorSeverity, Collections. emptyMap()); - } - - public NoTransactionFoundException(final String message, final ErrorType errorType, final ErrorTag errorTag, - final ErrorSeverity errorSeverity, final Map errorInfo){ - super(message,errorType,errorTag,errorSeverity,errorInfo); - } - -} diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/transactions/TransactionProvider.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/transactions/TransactionProvider.java index 743be1e257..716ed79f72 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/transactions/TransactionProvider.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/transactions/TransactionProvider.java @@ -11,6 +11,7 @@ package org.opendaylight.controller.config.facade.xml.transactions; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Set; import javax.management.InstanceNotFoundException; @@ -18,10 +19,8 @@ import javax.management.ObjectName; import org.opendaylight.controller.config.api.ConflictingVersionException; import org.opendaylight.controller.config.api.ValidationException; import org.opendaylight.controller.config.api.jmx.CommitStatus; -import org.opendaylight.controller.config.facade.xml.exception.NoTransactionFoundException; import org.opendaylight.controller.config.util.ConfigRegistryClient; import org.opendaylight.controller.config.util.ConfigTransactionClient; -import org.opendaylight.controller.config.util.xml.DocumentedException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -123,8 +122,7 @@ public class TransactionProvider implements AutoCloseable { /** * Commit and notification send must be atomic */ - public CommitStatus commitTransaction() throws ValidationException, ConflictingVersionException, - NoTransactionFoundException { + public CommitStatus commitTransaction() throws ValidationException, ConflictingVersionException { return commitTransaction(configRegistryClient); } @@ -132,12 +130,11 @@ public class TransactionProvider implements AutoCloseable { * Commit and notification send must be atomic * @param configRegistryClient */ - public synchronized CommitStatus commitTransaction(final ConfigRegistryClient configRegistryClient) throws ValidationException, ConflictingVersionException, NoTransactionFoundException { + public synchronized CommitStatus commitTransaction(final ConfigRegistryClient configRegistryClient) throws ValidationException, ConflictingVersionException { if (!getTransaction().isPresent()){ - throw new NoTransactionFoundException("No transaction found for session " + sessionIdForReporting, - DocumentedException.ErrorType.application, - DocumentedException.ErrorTag.operation_failed, - DocumentedException.ErrorSeverity.error); + //making empty commit without prior opened transaction, just return commit status with empty lists + LOG.debug("Making commit without open candidate transaction for session {}", sessionIdForReporting); + return new CommitStatus(Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST); } final Optional maybeTaON = getTransaction(); ObjectName taON = maybeTaON.get(); -- 2.36.6