]> source.dussan.org Git - poi.git/commitdiff
fixed NPE in HyperlinkRecord.toString()
authorJosh Micich <josh@apache.org>
Wed, 26 Nov 2008 22:00:29 +0000 (22:00 +0000)
committerJosh Micich <josh@apache.org>
Wed, 26 Nov 2008 22:00:29 +0000 (22:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@720997 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java

index 38f9855068ee6d0b510b84b8b90094b398584e3c..46c84b5e22f7e21fc60e4bd367feca7b2435a151 100644 (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) {
index 60cccf9a48351c6f7975dacd701cacbcee62a19a..7bb05f4f1225f654ab6ca53274d68dec8b366b07 100644 (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() {