diff --git a/src/main/java/com/sunyard/snmp/SnmpTrapSender.java b/src/main/java/com/sunyard/snmp/SnmpTrapSender.java index b9e17ea..57439a6 100644 --- a/src/main/java/com/sunyard/snmp/SnmpTrapSender.java +++ b/src/main/java/com/sunyard/snmp/SnmpTrapSender.java @@ -23,7 +23,7 @@ public class SnmpTrapSender implements AutoCloseable{ private String community; private int version; - public SnmpTrapSender(Map map) throws IOException { + public SnmpTrapSender(Map map) throws Exception { loadConfig(map); initializeSNMP(); } @@ -36,13 +36,13 @@ public class SnmpTrapSender implements AutoCloseable{ version = Integer.parseInt(map.getOrDefault("snmp.version", "1")); } - private void initializeSNMP() throws IOException { + private void initializeSNMP() throws Exception { TransportMapping transport = new DefaultUdpTransportMapping(); snmp = new Snmp(transport); snmp.listen(); } - public ResponseEvent sendTrap(String message, int severity) throws IOException { + public ResponseEvent sendTrap(String message, int severity) throws Exception { ResponseEvent event = null; switch (version) { case SnmpConstants.version1: @@ -57,7 +57,7 @@ public class SnmpTrapSender implements AutoCloseable{ return event; } - private ResponseEvent sendV1Trap(String message, int severity) throws IOException { + private ResponseEvent sendV1Trap(String message, int severity) throws Exception { CommunityTarget target = createCommunityTarget(SnmpConstants.version1); PDUv1 pdu = new PDUv1(); configureCommonTrap(pdu, message, severity); @@ -65,7 +65,7 @@ public class SnmpTrapSender implements AutoCloseable{ return snmp.send(pdu, target); } - private ResponseEvent sendV2Trap(String message, int severity) throws IOException { + private ResponseEvent sendV2Trap(String message, int severity) throws Exception { CommunityTarget target = createCommunityTarget(SnmpConstants.version2c); PDU pdu = new PDU(); configureCommonTrap(pdu, message, severity); @@ -96,7 +96,7 @@ public class SnmpTrapSender implements AutoCloseable{ } @Override - public void close() throws IOException { + public void close() throws Exception { if (snmp != null) { snmp.close(); snmp = null;