<FindBugsFilter>
  <!-- Allow command line utilities, which follow pattern *Main.java, to call
       system exit -->
  <Match>
    <Class name="~org\.apache\.zookeeper\..*Main" />
    <Bug pattern="DM_EXIT" />
  </Match>

  <!-- This is too complicated to resolve/ingrained into the architecture
       In particular we want to make sure we exit if this occurs
       Also notice logged as fatal error -->
  <Match>
    <Class name="org.apache.zookeeper.server.SyncRequestProcessor" />
    <Method name="run" />
    <Bug pattern="DM_EXIT" />
  </Match>

  <!-- In particular we want to make sure we exit if this occurs, unrecoverable.
       Also notice logged as fatal error -->
  <Match>
    <Class name="org.apache.zookeeper.server.ZooKeeperServer" />
    <Method name="takeSnapshot" />
    <Bug pattern="DM_EXIT" />
  </Match>


  <!-- We want to catch all exceptions and cleanup, regardless of source
       (incl runtime) -->
  <Match>
    <Class name="org.apache.zookeeper.ClientCnxn$SendThread" />
    <Method name="run" />
    <Bug pattern="REC_CATCH_EXCEPTION" />
  </Match>

   <!-- If we cannot open a socket to elect a leader, then we should
            simply exit -->
   <Match>
     <Class name="org.apache.zookeeper.server.quorum.LeaderElection" />
       <Method name="lookForLeader" />
       <Bug pattern="DM_EXIT" />
   </Match>

   <!-- Committing out of order is an unrecoverable error, so we should
              really exit  -->
   <Match>
     <Class name="org.apache.zookeeper.server.quorum.FollowerZooKeeperServer" />
       <Method name="commit" />
       <Bug pattern="DM_EXIT" />
     </Match>

   <!-- Two unrecoverable errors while following the leader  -->
   <Match>
     <Class name="org.apache.zookeeper.server.quorum.Learner" />
       <Method name="syncWithLeader" />
       <Bug pattern="DM_EXIT" />
   </Match>

  <Match>
    <Package name="org.apache.jute.compiler.generated" />
  </Match>

  <Match>
    <Package name="~org\.apache\.zookeeper\.(proto|data|txn)" />
    <Bug code="EI, EI2" />
  </Match>

  <Match>
    <Class name="org.apache.zookeeper.server.DataNode" />
      <Bug code="EI2"/>
  </Match>

  <Match>
    <Class name="org.apache.zookeeper.server.quorum.QuorumPacket" />
       <Bug code="EI2, EI" />
  </Match>

  <Match>
    <Class name="org.apache.zookeeper.ClientCnxn"/>
      <Bug code="EI, EI2" />
  </Match>

  <Match>
    <Class name="org.apache.zookeeper.server.DataNode"/>
      <Field name="children"/> 
      <Bug code="IS"/>
  </Match>
 <Match>
   <Class name="org.apache.zookeeper.server.quorum.Leader"/>
     <Field name="lastProposed"/>
     <Bug code="IS"/>
  </Match>
  <Match>
     <Class name="org.apache.zookeeper.server.quorum.LearnerSessionTracker"/>
       <Bug code="UrF"/>
  </Match>
  <Match>
    <Class name="org.apache.zookeeper.server.quorum.AuthFastLeaderElection$Messenger$WorkerSender"/>
    <Method name="process"/>
    <Bug code="RV"/>
  </Match>

  <!-- these are old classes just for upgrading and should go away -->
  <Match>
    <Class name="org.apache.zookeeper.server.upgrade.DataNodeV1"/>
  </Match> 

  <Match>
    <Class name="org.apache.zookeeper.server.upgrade.DataTreeV1"/>
  </Match>

  <!-- References code in a generated file that may or maynot be null -->
  <Match>
    <Class name="org.apache.zookeeper.Version" />
    <Method name="getVersion" />
    <Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE" />
  </Match>

  <!-- sync'd object is also being used to protect the isrunning flag, this is ok -->
  <Match>
    <Class name="org.apache.zookeeper.ClientCnxn$EventThread"/>
    <Bug code="JLM"/>
    <Or>
      <Method name="queuePacket" />
      <Method name="run" />
    </Or>
  </Match>

</FindBugsFilter>
