Skip to content

Commit

Permalink
Merge pull request #274 from geosolutions-it/9.x
Browse files Browse the repository at this point in the history
GEOT-4577, GeoTiff writer easts exception
  • Loading branch information
Simone Giannecchini committed Sep 23, 2013
2 parents 5c61298 + b29adab commit 6ce73b5
Showing 1 changed file with 16 additions and 12 deletions.
Expand Up @@ -31,6 +31,8 @@
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.imageio.IIOException;
import javax.imageio.IIOImage;
Expand All @@ -47,7 +49,6 @@
import org.geotools.coverage.grid.io.AbstractGridCoverageWriter;
import org.geotools.coverage.grid.io.AbstractGridFormat;
import org.geotools.coverage.grid.io.imageio.GeoToolsWriteParams;
import org.geotools.coverage.grid.io.imageio.IIOMetadataDumper;
import org.geotools.coverage.grid.io.imageio.geotiff.CRS2GeoTiffMetadataAdapter;
import org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffConstants;
import org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffException;
Expand All @@ -61,6 +62,7 @@
import org.geotools.referencing.CRS.AxisOrder;
import org.geotools.referencing.operation.matrix.XAffineTransform;
import org.geotools.resources.coverage.CoverageUtilities;
import org.geotools.util.logging.Logging;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
Expand All @@ -85,7 +87,8 @@
*/
public class GeoTiffWriter extends AbstractGridCoverageWriter implements
GridCoverageWriter {

private final static Logger LOGGER= Logging.getLogger(GeoTiffWriter.class);

private final Map<String, String> metadataKeyValue = new HashMap<String, String>();

/**
Expand Down Expand Up @@ -419,31 +422,32 @@ private boolean writeImage(final RenderedImage image,
}
writer.write(writer.getDefaultStreamMetadata(params), new IIOImage(image, null, metadata), params);


// flush then close
outputStream.flush();

}finally{
//
// release resources
//
try{
if(outputStream!=null)
outputStream.flush();
}catch (Throwable e) {
// eat me
}
//

try{
if (!(destination instanceof ImageOutputStream)&&outputStream!=null)
outputStream.close();
}catch (Throwable e) {
// eat me
// eat me
if(LOGGER.isLoggable(Level.WARNING)){
LOGGER.log(Level.WARNING,e.getLocalizedMessage(),e);
}
}

try{
if (writer!=null)
writer.dispose();
}catch (Throwable e) {
// eat me
// eat me
if(LOGGER.isLoggable(Level.WARNING)){
LOGGER.log(Level.WARNING,e.getLocalizedMessage(),e);
}
}
}

Expand Down

0 comments on commit 6ce73b5

Please sign in to comment.