提交 48e87d3b authored 作者: noelgrandin's avatar noelgrandin

simplify code - reduce some catching and rethrowing

上级 c82c7ab6
......@@ -197,8 +197,7 @@ public class ValueLob extends Value {
return (int) m;
}
private void createFromReader(char[] buff, int len, Reader in, long remaining, DataHandler h) {
try {
private void createFromReader(char[] buff, int len, Reader in, long remaining, DataHandler h) throws IOException {
FileStoreOutputStream out = initLarge(h);
boolean compress = h.getLobCompressionAlgorithm(Value.CLOB) != null;
try {
......@@ -219,9 +218,6 @@ public class ValueLob extends Value {
} finally {
out.close();
}
} catch (IOException e) {
throw DbException.convertIOException(e, null);
}
}
private static String getFileNamePrefix(String path, int objectId) {
......@@ -400,8 +396,7 @@ public class ValueLob extends Value {
return out;
}
private void createFromStream(byte[] buff, int len, InputStream in, long remaining, DataHandler h) {
try {
private void createFromStream(byte[] buff, int len, InputStream in, long remaining, DataHandler h) throws IOException {
FileStoreOutputStream out = initLarge(h);
boolean compress = h.getLobCompressionAlgorithm(Value.BLOB) != null;
try {
......@@ -421,9 +416,6 @@ public class ValueLob extends Value {
} finally {
out.close();
}
} catch (IOException e) {
throw DbException.convertIOException(e, null);
}
}
/**
......@@ -692,6 +684,7 @@ public class ValueLob extends Value {
* @param h the data handler
*/
public void convertToFileIfRequired(DataHandler h) {
try {
if (small != null && small.length > h.getMaxLengthInplaceLob()) {
boolean compress = h.getLobCompressionAlgorithm(type) != null;
int len = getBufferSize(h, compress, Long.MAX_VALUE);
......@@ -706,6 +699,9 @@ public class ValueLob extends Value {
DbException.throwInternalError();
}
}
} catch (IOException e) {
throw DbException.convertIOException(e, null);
}
}
/**
......
......@@ -456,8 +456,7 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
}
}
private void createTempFromReader(char[] buff, int len, Reader in, long remaining, DataHandler h) {
try {
private void createTempFromReader(char[] buff, int len, Reader in, long remaining, DataHandler h) throws IOException {
FileStoreOutputStream out = initTemp(h);
try {
while (true) {
......@@ -477,13 +476,9 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
} finally {
out.close();
}
} catch (IOException e) {
throw DbException.convertIOException(e, null);
}
}
private void createTempFromStream(byte[] buff, int len, InputStream in, long remaining, DataHandler h) {
try {
private void createTempFromStream(byte[] buff, int len, InputStream in, long remaining, DataHandler h) throws IOException {
FileStoreOutputStream out = initTemp(h);
boolean compress = h.getLobCompressionAlgorithm(Value.BLOB) != null;
try {
......@@ -503,25 +498,18 @@ public class ValueLobDb extends Value implements Value.ValueClob, Value.ValueBlo
} finally {
out.close();
}
} catch (IOException e) {
throw DbException.convertIOException(e, null);
}
}
private FileStoreOutputStream initTemp(DataHandler h) {
private FileStoreOutputStream initTemp(DataHandler h) throws IOException {
this.precision = 0;
this.handler = h;
this.lobStorage = h.getLobStorage();
this.small = null;
try {
String path = h.getDatabasePath();
if (path.length() == 0) {
path = SysProperties.PREFIX_TEMP_FILE;
}
fileName = FileUtils.createTempFile(path, Constants.SUFFIX_TEMP_FILE, true, true);
} catch (IOException e) {
throw DbException.convertIOException(e, null);
}
tempFile = h.openFile(fileName, "rw", false);
tempFile.autoDelete();
FileStoreOutputStream out = new FileStoreOutputStream(tempFile, null, null);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论