title: java :OverlappingFileLockException
body: <p>I want to  lock   file and  then make  some   updates    on it   but  every  time  i  want to make this   operation  i  got  :java.nio.channels.overlappingFilelockException,  i  tried  to  add catch  clause  with  this  exception with this   peace  of  code:</p>
  
  <pre><code>catch(OverlappingFilelockException e){
  lock.relese();
  }
  </code></pre>
  
  <p>but  this doesn't  work   for me. here is  my   java code , what should i  do   to get  rid  of  this  exception?</p>
  
  <pre><code>     File file = new File("C://Users//user//Desktop//conf1.xml");
          String content = '';
          BufferedReader s;
          BufferedWriter w;
          RandomAccessFile  ini=new RandomAccessFile(file, "rwd");;
          FileLock lock= ini.getChannel().tryLock();;
          def flowFile1=session.create();
  
          DocumentBuilder dBuilder = null;
          Document  doc=null;
          String start, startDate, endDate, runAs, makeVersion, patch;
          try {
  
              String sCurrentLine;
              s = new BufferedReader(Channels.newReader(ini.getChannel(), "UTF-8"));
  
  
              while ((sCurrentLine = s.readLine()) != null) {
                  content += sCurrentLine;
              }
              ini.seek(0);
  
  
  
  
              TransformerFactory transformerFactory = TransformerFactory.newInstance();
              Transformer transformer = transformerFactory.newTransformer();
              DOMSource source = new DOMSource(doc);
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              StreamResult result1 = new StreamResult(bos);
              try {
                  transformer.transform(source, result1);
              } catch (TransformerException e) {
                  e.printStackTrace();
              }
              byte[] array = bos.toByteArray();
              String data = bos.toString();
              if (!data.isEmpty()) {
                  ini.setLength(0);
                  w = new BufferedWriter(Channels.newWriter(ini.getChannel(), "UTF-8"));
                  w.write(data);
                  lock.release();
                  w.close();
  
  
  
              }
  
  
  
          }catch (FileNotFoundException e) {
              Thread.sleep(5000);
  
  
          } catch (Exception e) {
              e.printStackTrace();
          }
          finally {
  
  
  
              lock.release();
              ini.close();
          } 
  </code></pre>