Merge pull request #776 from mapsforge/buffer

ReadBuffer.readFromFile: handle byte allocation
This commit is contained in:
Emux
2020-07-14 15:04:45 +03:00
committed by GitHub

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2017-2018 devemux86 * Copyright 2017-2020 devemux86
* Copyright 2017 Gustl22 * Copyright 2017 Gustl22
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -27,6 +27,7 @@ import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
@@ -84,7 +85,12 @@ public class ReadBuffer {
LOG.warning("invalid read length: " + length); LOG.warning("invalid read length: " + length);
return false; return false;
} }
mBufferData = new byte[length]; try {
mBufferData = new byte[length];
} catch (Throwable t) {
LOG.log(Level.SEVERE, t.getMessage(), t);
return false;
}
} }
mBufferPosition = 0; mBufferPosition = 0;