fixed NPE in HyperlinkRecord.toString()

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@720997 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2008-11-26 22:00:29 +00:00
parent 4ca09b3a7b
commit e95e166390
2 changed files with 6 additions and 1 deletions

View File

@ -628,7 +628,7 @@ public final class HyperlinkRecord extends StandardRecord {
if ((_linkOpts & HLINK_TARGET_FRAME) != 0) {
buffer.append(" .targetFrame= ").append(getTargetFrame()).append("\n");
}
if((_linkOpts & HLINK_URL) != 0) {
if((_linkOpts & HLINK_URL) != 0 && _moniker != null) {
buffer.append(" .moniker = ").append(_moniker.formatAsString()).append("\n");
}
if ((_linkOpts & HLINK_PLACE) != 0) {

View File

@ -435,6 +435,11 @@ public final class TestHyperlinkRecord extends TestCase {
HyperlinkRecord hr = new HyperlinkRecord(in);
byte[] ser = hr.serialize();
TestcaseRecordInputStream.confirmRecordEncoding(HyperlinkRecord.sid, dataUNC, ser);
try {
hr.toString();
} catch (NullPointerException e) {
throw new AssertionFailedError("Identified bug with option URL and UNC set at same time");
}
}
public void testGUID() {