diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2015-10-31 12:19:37 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2015-10-31 12:19:37 +0000 |
commit | 86130160d596c64b92fb877abcc3be7bfb21aaae (patch) | |
tree | 68d5f54482a54912c05e4c74a8dcaf71c2c6d235 /src/main | |
parent | beb77e7da50a2e9bc761e08010491e2eee98a138 (diff) | |
download | jackcess-86130160d596c64b92fb877abcc3be7bfb21aaae.tar.gz jackcess-86130160d596c64b92fb877abcc3be7bfb21aaae.zip |
Throw a prettier exception when maxing out the row size during row creation. fixes #127
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@960 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java index 7aea12a..541b27b 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java @@ -19,6 +19,7 @@ package com.healthmarketscience.jackcess.impl; import java.io.BufferedWriter; import java.io.IOException; import java.io.StringWriter; +import java.nio.BufferOverflowException; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.ArrayList; @@ -1571,7 +1572,7 @@ public class TableImpl implements Table int rowSize = rowData.remaining(); if (rowSize > getFormat().MAX_ROW_SIZE) { throw new IOException(withErrorContext( - "Row size " + rowSize + " is too large")); + "Row size " + rowSize + " is too large")); } // get page with space @@ -2148,7 +2149,14 @@ public class TableImpl implements Table // above. add that space back so we don't double count maxRowSize += getFormat().SIZE_LONG_VALUE_DEF; } - buffer.put(varDataBuf); + try { + buffer.put(varDataBuf); + } catch(BufferOverflowException e) { + // if the data is too big for the buffer, then we have gone over + // the max row size + throw new IOException(withErrorContext( + "Row size " + buffer.limit() + " is too large")); + } } // we do a loop here so that we fill in offsets for deleted columns |