From 9259bdc01074ac2dfe5da51cb0baf036671c55db Mon Sep 17 00:00:00 2001 From: Stephen Kitt Date: Tue, 10 Nov 2015 09:47:34 +0100 Subject: [PATCH] Avoid logging stacktraces for schema version mismatches Change-Id: Ic3db3d3526491bb488d396be64adc9e41e09a3d6 Signed-off-by: Stephen Kitt --- .../error/SchemaVersionMismatchException.java | 17 +++-------------- .../ovsdb/lib/schema/typed/TyperUtils.java | 10 +++------- .../ovsdb/southbound/SouthboundMapper.java | 3 ++- .../ovsdb/transact/ProtocolUpdateCommand.java | 5 +++-- .../md/OpenVSwitchUpdateCommand.java | 6 ++++-- .../md/OvsdbBridgeUpdateCommand.java | 3 ++- 6 files changed, 17 insertions(+), 27 deletions(-) diff --git a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/error/SchemaVersionMismatchException.java b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/error/SchemaVersionMismatchException.java index a358245e0..3f710d00f 100644 --- a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/error/SchemaVersionMismatchException.java +++ b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/error/SchemaVersionMismatchException.java @@ -24,19 +24,8 @@ public class SchemaVersionMismatchException extends RuntimeException { super(message, cause); } - public static String createMessage(Version currentVersion, Version requiredVersion) { - String message = - "The schema version used to access this Table/Column does not match the required version.\n" - + "Current Version: " + currentVersion.toString() + "\n"; - - if (currentVersion.compareTo(requiredVersion) > 1) { - message += "Removed in Version: " + requiredVersion.toString(); - - } else { - message += "Added in Version: " + requiredVersion.toString(); - - } - - return message; + public SchemaVersionMismatchException(Version schemaVersion, Version fromVersion, Version untilVersion) { + this("The schema version used to access the table/column (" + schemaVersion + ") does not match the required " + + "version (from " + fromVersion + " to " + untilVersion + ")"); } } diff --git a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/schema/typed/TyperUtils.java b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/schema/typed/TyperUtils.java index 0932d9546..8c9adceb1 100644 --- a/library/impl/src/main/java/org/opendaylight/ovsdb/lib/schema/typed/TyperUtils.java +++ b/library/impl/src/main/java/org/opendaylight/ovsdb/lib/schema/typed/TyperUtils.java @@ -196,13 +196,9 @@ public class TyperUtils { } private static void checkVersion(Version schemaVersion, Version fromVersion, Version untilVersion) { - if (!fromVersion.equals(Version.NULL) && schemaVersion.compareTo(fromVersion) < 0) { - String message = SchemaVersionMismatchException.createMessage(schemaVersion, fromVersion); - throw new SchemaVersionMismatchException(message); - } - if (!untilVersion.equals(Version.NULL) && schemaVersion.compareTo(untilVersion) > 0) { - String message = SchemaVersionMismatchException.createMessage(schemaVersion, untilVersion); - throw new SchemaVersionMismatchException(message); + if ((!fromVersion.equals(Version.NULL) && schemaVersion.compareTo(fromVersion) < 0) || (!untilVersion.equals( + Version.NULL) && schemaVersion.compareTo(untilVersion) > 0)) { + throw new SchemaVersionMismatchException(schemaVersion, fromVersion, untilVersion); } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java index 8ffe4275a..6055ca05f 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/SouthboundMapper.java @@ -245,7 +245,8 @@ public class SouthboundMapper { try { protocols = bridge.getProtocolsColumn().getData(); } catch (SchemaVersionMismatchException e) { - LOG.warn("protocols not supported by this version of ovsdb", e); + // We don't care about the exception stack trace here + LOG.warn("protocols not supported by this version of ovsdb: {}", e.getMessage()); } List protocolList = new ArrayList<>(); if (protocols != null && protocols.size() > 0) { diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolUpdateCommand.java index f32cfac2d..e76b96682 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/ProtocolUpdateCommand.java @@ -53,7 +53,7 @@ public class ProtocolUpdateCommand extends AbstractTransactCommand { entry.getKey().firstIdentifierOf(OvsdbBridgeAugmentation.class); Optional bridgeOptional = getOperationalState().getOvsdbBridgeAugmentation(bridgeIid); - OvsdbBridgeAugmentation ovsdbBridge = null; + OvsdbBridgeAugmentation ovsdbBridge; if (bridgeOptional.isPresent()) { ovsdbBridge = bridgeOptional.get(); } else { @@ -74,7 +74,8 @@ public class ProtocolUpdateCommand extends AbstractTransactCommand { .where(bridge.getNameColumn().getSchema().opEqual(bridge.getNameColumn().getData())) .build()); } catch (SchemaVersionMismatchException e) { - LOG.warn("protocol not supported by this version of ovsdb", e); + // We don't care about the exception stack trace here + LOG.warn("protocol not supported by this version of ovsdb: {}", e.getMessage()); } } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java index dc8bd53c9..2ca74ee34 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java @@ -209,7 +209,8 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand { } ovsdbNodeBuilder.setInterfaceTypeEntry(ifEntryList); } catch (SchemaVersionMismatchException e) { - LOG.debug("Iface types not supported by this version of ovsdb",e); + // We don't care about the exception stack trace here + LOG.debug("Iface types not supported by this version of ovsdb: {}", e.getMessage()); } } @@ -233,7 +234,8 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand { } ovsdbNodeBuilder.setDatapathTypeEntry(dpEntryList); } catch (SchemaVersionMismatchException e) { - LOG.debug("Datapath types not supported by this version of ovsdb",e); + // We don't care about the exception stack trace here + LOG.debug("Datapath types not supported by this version of ovsdb: {}", e.getMessage()); } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommand.java index 55aba8b98..47767f9da 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbBridgeUpdateCommand.java @@ -185,7 +185,8 @@ public class OvsdbBridgeUpdateCommand extends AbstractTransactionCommand { } } } catch (SchemaVersionMismatchException e) { - LOG.warn("protocol not supported by this version of ovsdb", e); + // We don't care about the exception stack trace here + LOG.warn("protocol not supported by this version of ovsdb: {}", e.getMessage()); } return result; } -- 2.36.6