Clojure-Contrib

clojure.contrib.io does not support appending anymore

Details

  • Type: Defect Defect
  • Status: In Progress In Progress
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Reproduce the bug with:

(require 'clojure.contrib.io)
(clojure.contrib.io/append-writer "/xyz.txt")
</code></pre>
which will throw an Exception ���Cannot change an open stream to append mode���.

This is caused because of a flaw in the call chain.
*clojure.contrib.io/writer* for Strings calls again *writer* for whatever *clojure.contrib.io/output-stream*
returns. We call *append-writer* which then calls *writer* on the String which in turn then calls:
<pre><code>
output-stream for ^String which calls
    output-stream for ^URL which calls
        output-stream for ^File which binds *append* to false and calls
            output-stream for ^OutputStream which
            returns a BufferedOutputStream instance which then jumps back to the
        ^File handler, which removes its binding for *append*!! and returns the BOS to the
    ^URL handler which returns the BOS to the
^String handler

At this point the outer binding (for append) is set to true again, and assert-not-appending fails.

Activity

Alex Miller made changes -
Field Original Value New Value
Approval Test [ 10013 ]

People

  • Assignee:
    bpsm
    Reporter:
    Anonymous
Vote (0)
Watch (0)

Dates

  • Created:
    Updated: