Skip to content

Commit

Permalink
Let try-with-resource handle file lock
Browse files Browse the repository at this point in the history
Addresses #42
  • Loading branch information
lesserwhirls committed Aug 3, 2019
1 parent a039838 commit f4af137
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions cdm/src/main/java/ucar/nc2/iosp/nexrad2/Level2VolumeScan.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,28 @@

package ucar.nc2.iosp.nexrad2;

import static ucar.nc2.iosp.nexrad2.Level2Record.REFLECTIVITY_HIGH;
import static ucar.nc2.iosp.nexrad2.Level2Record.VELOCITY_HIGH;

import java.io.*;
import java.util.*;
import java.nio.channels.FileLock;
import java.nio.channels.OverlappingFileLockException;

import ucar.nc2.util.CancelTask;
import ucar.nc2.util.DiskCache;
import ucar.unidata.io.RandomAccessFile;
import ucar.unidata.io.bzip2.CBZip2InputStream;
import ucar.unidata.io.bzip2.BZip2ReadException;
import ucar.unidata.io.bzip2.CBZip2InputStream;

import java.io.ByteArrayInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.channels.FileLock;
import java.nio.channels.OverlappingFileLockException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static ucar.nc2.iosp.nexrad2.Level2Record.REFLECTIVITY_HIGH;
import static ucar.nc2.iosp.nexrad2.Level2Record.VELOCITY_HIGH;

/**
* This class reads a NEXRAD level II data file. It can handle NCDC archives (ARCHIVE2), as well as
Expand Down Expand Up @@ -786,12 +795,7 @@ private void uncompress(RandomAccessFile inputRaf, String ufilename)
}
}
throw t;
} finally {
if (lock != null) {
lock.release();
}
} // try-with-resource

} // try-with-resource
}

// check if compressed file seems ok
Expand Down

0 comments on commit f4af137

Please sign in to comment.