Fop
  1. Fop
  2. FOP-1478

Hyphenation file not found when HyphenationBaseURL is set on FopFactory

    Details

    • Type: Bug Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: 0.94
    • Fix Version/s: None
    • Component/s: general
    • Labels:
      None
    • Environment:
      Operating System: other
      Platform: Other
    • External issue ID:
      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.

        Activity

        Hide
        Andreas L. Delmelle added a comment -

        Sorry for the late reply. There does indeed seem to be a slight error in there.

        This would more correctly reflect the intention, I believe:


        if (in == null) {
        if (source.getSystemId() != null)

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

        else

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

        }

        Can you confirm that this works without having to register a custom resolver? If so, I'll apply it to the trunk.

        Show
        Andreas L. Delmelle added a comment - Sorry for the late reply. There does indeed seem to be a slight error in there. This would more correctly reflect the intention, I believe: — if (in == null) { if (source.getSystemId() != null) { in = new java.net.URL(source.getSystemId()).openStream(); } else { throw new UnsupportedOperationException("Cannot load hyphenation pattern file" + " with the supplied Source object: " + source); } } — Can you confirm that this works without having to register a custom resolver? If so, I'll apply it to the trunk.
        Hide
        Andreas L. Delmelle added a comment -

        Changes (finally) applied to FOP Trunk.

        see: http://svn.apache.org/viewvc?rev=651853&view=rev

        Show
        Andreas L. Delmelle added a comment - Changes (finally) applied to FOP Trunk. see: http://svn.apache.org/viewvc?rev=651853&view=rev
        Hide
        Glenn Adams added a comment -

        batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed

        Show
        Glenn Adams added a comment - batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed

          People

          • Assignee:
            fop-dev
            Reporter:
            David Whitlock
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development