aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/com
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2013-09-14 13:20:39 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2013-09-14 13:20:39 +0000
commit012c3e7c30a0e09f788e8b43374549c07657ca5d (patch)
tree01b278dfba509888113a3e60d133549315cb47a8 /src/main/java/com
parente7409f5aa21e2b845623579db69b0db620113f2c (diff)
downloadjackcess-012c3e7c30a0e09f788e8b43374549c07657ca5d.tar.gz
jackcess-012c3e7c30a0e09f788e8b43374549c07657ca5d.zip
Ignore invalid column usage map definitions, fixes issue 97
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@800 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java21
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/UsageMap.java5
2 files changed, 20 insertions, 6 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java
index 4cd3365..240ebf6 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java
@@ -48,7 +48,6 @@ import com.healthmarketscience.jackcess.Column;
import com.healthmarketscience.jackcess.ColumnBuilder;
import com.healthmarketscience.jackcess.CursorBuilder;
import com.healthmarketscience.jackcess.DataType;
-import com.healthmarketscience.jackcess.Index;
import com.healthmarketscience.jackcess.IndexBuilder;
import com.healthmarketscience.jackcess.PropertyMap;
import com.healthmarketscience.jackcess.Row;
@@ -270,11 +269,21 @@ public class TableImpl implements Table
break;
}
- UsageMap colOwnedPages = UsageMap.read(
- getDatabase(), tableBuffer, false);
- UsageMap colFreeSpacePages = UsageMap.read(
- getDatabase(), tableBuffer, false);
-
+ int pos = tableBuffer.position();
+ UsageMap colOwnedPages = null;
+ UsageMap colFreeSpacePages = null;
+ try {
+ colOwnedPages = UsageMap.read(getDatabase(), tableBuffer, false);
+ colFreeSpacePages = UsageMap.read(getDatabase(), tableBuffer, false);
+ } catch(IllegalStateException e) {
+ // ignore invalid usage map info
+ colOwnedPages = null;
+ colFreeSpacePages = null;
+ tableBuffer.position(pos + 8);
+ LOG.warn("Table " + _name + " invalid column " + umapColNum +
+ " usage map definition: " + e);
+ }
+
for(ColumnImpl col : _columns) {
if(col.getColumnNumber() == umapColNum) {
col.setUsageMaps(colOwnedPages, colFreeSpacePages);
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/UsageMap.java b/src/main/java/com/healthmarketscience/jackcess/impl/UsageMap.java
index 9169582..ac49c44 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/UsageMap.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/UsageMap.java
@@ -134,6 +134,11 @@ public class UsageMap
int rowNum, boolean assumeOutOfRangeBitsOn)
throws IOException
{
+ if(pageNum <= 0) {
+ // usage maps will never appear on page 0 (or less)
+ throw new IllegalStateException("Invalid usage map page number " + pageNum);
+ }
+
JetFormat format = database.getFormat();
PageChannel pageChannel = database.getPageChannel();
ByteBuffer tableBuffer = pageChannel.createPageBuffer();