From 86130160d596c64b92fb877abcc3be7bfb21aaae Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Sat, 31 Oct 2015 12:19:37 +0000 Subject: 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 --- .../com/healthmarketscience/jackcess/impl/TableImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main') 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 -- cgit v1.2.3