taoensso/nippy

should `extend-freeze` affect `freezable?`

mk opened this issue · 3 comments

mk commented

First of all, thanks a lot for nippy, we're happily using it in Clerk.

I've been a bit surprised that nippy/freezable? is not affected by nippy/extend-freeze:

;; run with `clj -Sdeps '{:deps {com.taoensso/nippy {:mvn/version "3.3.0"}}}}'`
(ns scratch-nippy
  (:require [taoensso.nippy :as nippy]))

(nippy/extend-freeze java.awt.image.BufferedImage :java.awt.image.BufferedImage [x out] (javax.imageio.ImageIO/write x "png" (javax.imageio.ImageIO/createImageOutputStream out)))

(def img
  (javax.imageio.ImageIO/read (java.net.URL. "https://nextjournal.com/data/QmSJ6eu6kUFeWrqXyYaiWRgJxAVQt2ivaoNWc1dtTEADCf?filename=thermo.png&content-type=image/png")))
;; => #'scratch-nippy/img

(type img)
;; => java.awt.image.BufferedImage

(satisfies? nippy/IFreezable1 img)
;; => true

(nippy/freezable? img)
;; => nil

(nippy/freeze img)
;; => #object["[B" 0x3fae6f5e "[B@3fae6f5e"]

Are you open to a PR changing this or is this intentional?

mk commented

After reading the changelog of the unreleased 3.4.0-beta1, I've been able to confirm that this has been fixed with fb6f75e.

Happy to hear that the upcoming beta seems to meet your needs! Thanks for updating 👍

Cheers :-)