Hi all,

I'm using Camel2.5 SNMP component and encountered some problems.
I checked source code, made a patch (shown below) and it woked fine in my
environment.

I would like to confirm whether belows cases are bugs or not, and if these
are not bugs, 
how do I avoid them.

*case1
 When application calles doStop() method in SNMP component more than twice,
I got NullPointerException.
 
*case2
 I can not set protocol=tcp in SNMP component.

*path
 I applied the patch for org.apache.camel.component.snmp.SnmpOIDPoller class

--- org/SnmpOIDPoller.java      2010-10-25 16:30:46.000000000 +0900
+++ new/SnmpOIDPoller.java      2011-01-13 15:39:47.872629200 +0900
@@ -36,6 +36,7 @@
 import org.snmp4j.smi.OID;
 import org.snmp4j.smi.OctetString;
 import org.snmp4j.smi.VariableBinding;
+import org.snmp4j.transport.DefaultTcpTransportMapping;
 import org.snmp4j.transport.DefaultUdpTransportMapping;
 
 public class SnmpOIDPoller extends ScheduledPollConsumer implements
ResponseListener {
@@ -63,7 +64,11 @@
 
         LOG.debug("Activating oid poller");
         this.targetAddress =
GenericAddress.parse(this.endpoint.getAddress());
-        this.transport = new DefaultUdpTransportMapping();
+        if (this.endpoint.getProtocol().equalsIgnoreCase("tcp")) {//tcp
option
+               this.transport = new DefaultTcpTransportMapping();
+        } else {                                                  //simply
consider udp
+               this.transport = new DefaultUdpTransportMapping();
+        }
         this.snmp = new Snmp(this.transport);
         this.usm = new USM(SecurityProtocols.getInstance(), new
OctetString(MPv3.createLocalEngineID()), 0);
         SecurityModels.getInstance().addSecurityModel(usm);
@@ -85,9 +90,11 @@
     @Override
     protected void doStop() throws Exception {
         // stop listening to the transport
-        if (this.transport.isListening()) {
-            this.transport.close();
-        }
+       if (this.transport != null) {           //suppress
NullPointerException when doStop called more than twice
+               if (this.transport.isListening()) {
+                   this.transport.close();
+               }
+       }
 
         super.doStop();
     }
  
-- 
View this message in context: 
http://camel.465427.n5.nabble.com/camel-snmp-2-5-problems-tp3339373p3339373.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to