mirror of https://github.com/apache/poi.git
fix up use of ExceptionUtil in main poi-scratchpad module
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1907652 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3a70d5e002
commit
3968e289e4
|
@ -22,6 +22,7 @@ import java.util.ArrayList;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.poi.hdgf.chunks.ChunkFactory.CommandDefinition;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
import static org.apache.logging.log4j.util.Unbox.box;
|
||||
|
@ -245,6 +246,9 @@ public final class Chunk {
|
|||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
LOG.atError().withThrowable(e).log("Unexpected error processing command, ignoring and continuing. Command: {}", command);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.poi.hdgf.chunks.Chunk;
|
|||
import org.apache.poi.hdgf.chunks.ChunkFactory;
|
||||
import org.apache.poi.hdgf.chunks.ChunkHeader;
|
||||
import org.apache.poi.hdgf.pointers.Pointer;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
|
||||
import static org.apache.logging.log4j.util.Unbox.box;
|
||||
|
||||
|
@ -72,9 +73,10 @@ public final class ChunkStream extends Stream {
|
|||
pos = contents.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
LOG.atError().withThrowable(e).log("Failed to create chunk at {}, ignoring rest of data.", box(pos));
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.apache.poi.hwmf.record.HwmfColorRef;
|
|||
import org.apache.poi.hwmf.record.HwmfMisc;
|
||||
import org.apache.poi.hwmf.record.HwmfObjectTableEntry;
|
||||
import org.apache.poi.hwmf.record.HwmfPenStyle;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.Internal;
|
||||
|
||||
public class HemfGraphics extends HwmfGraphics {
|
||||
|
@ -145,6 +146,9 @@ public class HemfGraphics extends HwmfGraphics {
|
|||
try {
|
||||
pathConsumer.accept(path);
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
// workaround if a path has been started and no MoveTo command
|
||||
// has been specified before the first lineTo/splineTo
|
||||
final Point2D loc = prop.getLocation();
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.apache.poi.sl.draw.ImageRenderer;
|
|||
import org.apache.poi.sl.usermodel.PictureData.PictureType;
|
||||
import org.apache.poi.util.BitField;
|
||||
import org.apache.poi.util.BitFieldFactory;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.GenericRecordJsonWriter;
|
||||
import org.apache.poi.util.GenericRecordUtil;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
|
@ -442,7 +443,10 @@ public class HemfPlusImage {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
}
|
||||
return new Rectangle2D.Double(1,1,1,1);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.apache.poi.ddf.EscherContainerRecord;
|
|||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.sl.image.ImageHeaderPICT;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.Removal;
|
||||
|
@ -104,6 +105,9 @@ public final class PICT extends Metafile {
|
|||
Arrays.fill(chunk, (byte) 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
int lastLen = chunk.length - 1;
|
||||
while (lastLen >= 0 && chunk[lastLen] == 0) {
|
||||
lastLen--;
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Map;
|
|||
import java.util.function.Supplier;
|
||||
|
||||
import org.apache.poi.hslf.model.textproperties.IndentProp;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.GenericRecordUtil;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
@ -97,7 +98,10 @@ public final class MasterTextPropAtom extends RecordAtom {
|
|||
|
||||
try {
|
||||
read();
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
LOG.atError().withThrowable(e).log("Failed to parse MasterTextPropAtom");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.apache.poi.hslf.exceptions.HSLFException;
|
|||
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
|
||||
import org.apache.poi.hslf.model.textproperties.TextPropCollection.TextPropType;
|
||||
import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.GenericRecordUtil;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
@ -76,7 +77,10 @@ public final class TxMasterStyleAtom extends RecordAtom {
|
|||
//read available styles
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
LOG.atWarn().withThrowable(e).log("Exception when reading available styles");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.poi.poifs.crypt.Decryptor;
|
|||
import org.apache.poi.poifs.crypt.EncryptionInfo;
|
||||
import org.apache.poi.poifs.crypt.Encryptor;
|
||||
import org.apache.poi.util.BitField;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
@ -170,6 +171,9 @@ public class HSLFSlideShowEncrypted implements Closeable {
|
|||
}
|
||||
cyos.initCipherForBlock(persistId, false);
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
throw new EncryptedPowerPointFileException(e);
|
||||
}
|
||||
return cyos;
|
||||
|
@ -199,6 +203,9 @@ public class HSLFSlideShowEncrypted implements Closeable {
|
|||
readFully(ccis, docstream, offset+8, rlen);
|
||||
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
throw new EncryptedPowerPointFileException(e);
|
||||
}
|
||||
}
|
||||
|
@ -283,6 +290,9 @@ public class HSLFSlideShowEncrypted implements Closeable {
|
|||
int blipLen = endOffset - offset;
|
||||
decryptPicBytes(pictstream, offset, blipLen);
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
throw new CorruptPowerPointFileException(e);
|
||||
}
|
||||
}
|
||||
|
@ -362,6 +372,9 @@ public class HSLFSlideShowEncrypted implements Closeable {
|
|||
ccos.write(pictstream, offset, blipLen);
|
||||
ccos.flush();
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
throw new EncryptedPowerPointFileException(e);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(ccos);
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.apache.poi.hwmf.record.HwmfRecordType;
|
|||
import org.apache.poi.hwmf.record.HwmfWindowing.WmfSetWindowExt;
|
||||
import org.apache.poi.hwmf.record.HwmfWindowing.WmfSetWindowOrg;
|
||||
import org.apache.poi.util.Dimension2DDouble;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.LittleEndianInputStream;
|
||||
import org.apache.poi.util.LocaleUtil;
|
||||
|
@ -106,6 +107,9 @@ public class HwmfPicture implements Iterable<HwmfRecord>, GenericRecord {
|
|||
recordSize = (int)recordSizeLong;
|
||||
recordFunction = leis.readShort();
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
LOG.atError().log("unexpected eof - wmf file was truncated");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
|
|||
import org.apache.poi.poifs.filesystem.Entry;
|
||||
import org.apache.poi.poifs.filesystem.EntryUtils;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LittleEndianByteArrayOutputStream;
|
||||
|
@ -298,7 +299,9 @@ public final class HWPFDocument extends HWPFDocumentCore {
|
|||
try {
|
||||
preserveBinTables = Boolean.parseBoolean(System.getProperty(PROPERTY_PRESERVE_BIN_TABLES));
|
||||
} catch (Exception exc) {
|
||||
// ignore;
|
||||
if (ExceptionUtil.isFatal(exc)) {
|
||||
ExceptionUtil.rethrow(exc);
|
||||
}
|
||||
}
|
||||
|
||||
if (!preserveBinTables) {
|
||||
|
@ -314,7 +317,9 @@ public final class HWPFDocument extends HWPFDocumentCore {
|
|||
try {
|
||||
preserveTextTable = Boolean.parseBoolean(System.getProperty(PROPERTY_PRESERVE_TEXT_TABLE));
|
||||
} catch (Exception exc) {
|
||||
// ignore;
|
||||
if (ExceptionUtil.isFatal(exc)) {
|
||||
ExceptionUtil.rethrow(exc);
|
||||
}
|
||||
}
|
||||
if (!preserveTextTable) {
|
||||
_cft = new ComplexFileTable();
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.apache.poi.hwpf.usermodel.TableCell;
|
|||
import org.apache.poi.hwpf.usermodel.TableRow;
|
||||
import org.apache.poi.poifs.filesystem.Entry;
|
||||
import org.apache.poi.util.Beta;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LocaleUtil;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
|
@ -627,6 +628,9 @@ public abstract class AbstractWordConverter {
|
|||
processDocumentInformation(summaryInformation);
|
||||
}
|
||||
} catch (Exception exc) {
|
||||
if (ExceptionUtil.isFatal(exc)) {
|
||||
ExceptionUtil.rethrow(exc);
|
||||
}
|
||||
LOG.atWarn().withThrowable(exc).log("Unable to process document summary information");
|
||||
}
|
||||
|
||||
|
@ -892,6 +896,9 @@ public abstract class AbstractWordConverter {
|
|||
try {
|
||||
return processOle2(doc, block, entry);
|
||||
} catch (Exception exc) {
|
||||
if (ExceptionUtil.isFatal(exc)) {
|
||||
ExceptionUtil.rethrow(exc);
|
||||
}
|
||||
LOG.atWarn().withThrowable(exc).log("Unable to convert internal OLE2 object '{}'", box(characterRun.getPicOffset()));
|
||||
return false;
|
||||
}
|
||||
|
@ -947,6 +954,9 @@ public abstract class AbstractWordConverter {
|
|||
processParagraph(wordDocument, flow, currentTableLevel, paragraph, label);
|
||||
processed = true;
|
||||
} catch (Exception exc) {
|
||||
if (ExceptionUtil.isFatal(exc)) {
|
||||
ExceptionUtil.rethrow(exc);
|
||||
}
|
||||
LOG.atWarn().withThrowable(exc).log("Can't process paragraph as list entry, will be processed without list information");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.poi.hwpf.converter.WordToTextConverter;
|
|||
import org.apache.poi.hwpf.usermodel.Range;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
|
||||
/**
|
||||
* Class to extract the text from old (Word 6 / Word 95) Word Documents.
|
||||
|
@ -90,6 +91,9 @@ public final class Word6Extractor implements POIOLE2TextExtractor {
|
|||
|
||||
ret = WordExtractor.getParagraphText(r);
|
||||
} catch (Exception e) {
|
||||
if (ExceptionUtil.isFatal(e)) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
// Something's up with turning the text pieces into paragraphs
|
||||
// Fall back to ripping out the text pieces
|
||||
ret = new String[doc.getTextTable().getTextPieces().size()];
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.apache.poi.hwpf.HWPFDocument;
|
|||
import org.apache.poi.hwpf.usermodel.CharacterRun;
|
||||
import org.apache.poi.hwpf.usermodel.Picture;
|
||||
import org.apache.poi.hwpf.usermodel.Range;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
|
@ -179,6 +180,9 @@ public final class PicturesTable {
|
|||
pictures.add(new Picture(blip));
|
||||
}
|
||||
} catch (Exception exc) {
|
||||
if (ExceptionUtil.isFatal(exc)) {
|
||||
ExceptionUtil.rethrow(exc);
|
||||
}
|
||||
LOG.atWarn().withThrowable(exc).log("Unable to load picture from BLIP record at offset #{}", box(bse.getOffset()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.poi.hwpf.sprm;
|
|||
import java.util.Arrays;
|
||||
|
||||
import org.apache.poi.common.Duplicatable;
|
||||
import org.apache.poi.util.ExceptionUtil;
|
||||
import org.apache.poi.util.IOUtils;
|
||||
import org.apache.poi.util.Internal;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
@ -208,6 +209,9 @@ public final class SprmBuffer implements Duplicatable {
|
|||
try {
|
||||
stringBuilder.append(iterator.next());
|
||||
} catch (Exception exc) {
|
||||
if (ExceptionUtil.isFatal(exc)) {
|
||||
ExceptionUtil.rethrow(exc);
|
||||
}
|
||||
stringBuilder.append("error");
|
||||
}
|
||||
stringBuilder.append("; ");
|
||||
|
|
Loading…
Reference in New Issue