yeller / clojure-miniprofiler

a simple but effective profiler for clojure web applications
Eclipse Public License 1.0
115 stars 9 forks source link

JSON profiling dies on BufferedInputStream #8

Open piranha opened 8 years ago

piranha commented 8 years ago

My API returns a response where :body is a BufferedInputStream, and because of that miniprofiler dies with a stacktrace like that:

java.lang.ClassCastException: java.io.BufferedInputStream cannot be cast to java.lang.String
    at cheshire.core$parse_string.invokeStatic(core.clj:206)
    at cheshire.core$parse_string.invoke(core.clj:191)
    at cheshire.core$parse_string.invokeStatic(core.clj:201)
    at cheshire.core$parse_string.invoke(core.clj:191)
    at clojure_miniprofiler$build_miniprofiler_response_json$fn__72991.invoke(clojure_miniprofiler.clj:198)

I'm not sure what's the best way to proceed, should there be some if about parsing streams?

tcrayford commented 8 years ago

Seems potentially nast yeah. clojure-miniprofiler can't do too much here, because it relies on munging the response. I don't have any good ideas on potential solutions - reading a (potentially infinite) buffer is kinda gnarly.

piranha commented 8 years ago

Well, if it says it's application/json, it can't be too infinite, can it? Also, if it's infinite, just exclude the request in :profile-request?. Because in other case you can't profile responses at all!