Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-1478

Hyphenation file not found when HyphenationBaseURL is set on FopFactory

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Fixed
    • 0.94
    • None
    • unqualified
    • None
    • Operating System: other
      Platform: Other
    • 44203

    Description

      I configured my FopFactory to locate Hyphenation files in a directory on my
      local disk by invoking setHyphenationBaseURL() on my FopFactory with the
      ExternalForm of a "file:" URL. However, the "Couldn't find hyphenation pattern
      en" ERROR message is still being logged.

      I did some debugging and I believe that there is a logic error in the
      two-argument getUserHyphenationTree() method in Hyphenator.java. The
      UnsupportedOperationException on line 261 is thrown even when the Source has a
      valid InputStream (that is, when the value of "in" assigned on line 256 is not
      null). The exception percolates up the call stack and the ERROR message is issued.

      250 String name = key + ".hyp";
      251 Source source = resolver.resolve(name);
      252 if (source != null) {
      253 try {
      254 InputStream in = null;
      255 if (source instanceof StreamSource)

      { 256 in = ((StreamSource) source).getInputStream(); 257 }

      258 if (in == null && source.getSystemId() != null)

      { 259 in = new java.net.URL(source.getSystemId()).openStream(); 260 }

      else

      { 261 throw new UnsupportedOperationException("Cannot load hyphenation pattern file" 262 + " with the supplied Source object: " + source); 263 }

      264 in = new BufferedInputStream(in);
      265 try

      { 266 hTree = readHyphenationTree(in); 267 }

      finally

      { 268 IOUtils.closeQuietly(in); 269 }

      270 return hTree;

      I can work around this behavior by registering my own HyphenationTreeResolver
      which returns a Source with a null stream and a non-null system id.

      Attachments

        Activity

          People

            fop-dev@xmlgraphics.apache.org fop-dev
            dwhitlock@tripwire.com David Whitlock
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: