Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is not possible to override the default java.util.Map handler #31

Open
whilo opened this issue Nov 11, 2019 · 4 comments
Open

It is not possible to override the default java.util.Map handler #31

whilo opened this issue Nov 11, 2019 · 4 comments

Comments

@whilo
Copy link

whilo commented Nov 11, 2019

In Clojure code:

(get
 (TransitFactory/writeHandlerMap {java.util.Map "foo bar"})
 java.util.Map)

yields the default map handler unchanged instead of an exception (which happens for java.util.List). This behavior worked with transit-clj 0.8.285. I have been using this for https://github.com/replikativ/incognito/ to serialize all unknown record types as special maps including tag information. Unfortunately the default-handler does not cover this case, because it is only triggered if the thing is unknown, while records are treated as maps by default.

@puredanger
Copy link
Contributor

Could you use the clojure.lang.IRecord marker type to catch these?

@whilo
Copy link
Author

whilo commented Nov 11, 2019

I get a java.lang.RuntimeException: java.lang.RuntimeException: More thane one match for class ... from the checkBaseInterfaces method in WriteHandlerMap in this case.

@whilo
Copy link
Author

whilo commented Nov 12, 2019

The full stacktrace is:

  WriteHandlerMap.java:  226  com.cognitect.transit.impl.WriteHandlerMap/checkBaseInterfaces
  WriteHandlerMap.java:  195  com.cognitect.transit.impl.WriteHandlerMap/getHandler
  AbstractEmitter.java:  199  com.cognitect.transit.impl.AbstractEmitter/marshalTop
      JsonEmitter.java:   41  com.cognitect.transit.impl.JsonEmitter/emit
    WriterFactory.java:   62  com.cognitect.transit.impl.WriterFactory$1/write
           transit.clj:  171  cognitect.transit/write
           transit.clj:  168  cognitect.transit/write
                  REPL:   31  incognito.transit-test/fn/fn
                  REPL:   20  incognito.transit-test/fn
                  REPL:   13  incognito.transit-test/fn
              test.clj:  203  cider.nrepl.middleware.test/test-var/fn
              test.clj:  203  cider.nrepl.middleware.test/test-var
              test.clj:  195  cider.nrepl.middleware.test/test-var
              test.clj:  218  cider.nrepl.middleware.test/test-vars/fn/fn
              test.clj:  687  clojure.test/default-fixture
              test.clj:  683  clojure.test/default-fixture
              test.clj:  218  cider.nrepl.middleware.test/test-vars/fn
              test.clj:  687  clojure.test/default-fixture
              test.clj:  683  clojure.test/default-fixture
              test.clj:  215  cider.nrepl.middleware.test/test-vars
              test.clj:  209  cider.nrepl.middleware.test/test-vars
              test.clj:  231  cider.nrepl.middleware.test/test-ns
              test.clj:  222  cider.nrepl.middleware.test/test-ns
              test.clj:  242  cider.nrepl.middleware.test/test-var-query
              test.clj:  235  cider.nrepl.middleware.test/test-var-query
              test.clj:  280  cider.nrepl.middleware.test/handle-test-var-query-op/fn/fn
              AFn.java:  152  clojure.lang.AFn/applyToHelper
              AFn.java:  144  clojure.lang.AFn/applyTo
              core.clj:  665  clojure.core/apply
              core.clj: 1973  clojure.core/with-bindings*
              core.clj: 1973  clojure.core/with-bindings*
           RestFn.java:  425  clojure.lang.RestFn/invoke
              test.clj:  272  cider.nrepl.middleware.test/handle-test-var-query-op/fn
              AFn.java:   22  clojure.lang.AFn/run
           session.clj:  171  nrepl.middleware.session/session-exec/main-loop/fn
           session.clj:  170  nrepl.middleware.session/session-exec/main-loop
              AFn.java:   22  clojure.lang.AFn/run
           Thread.java:  830  java.lang.Thread/run

@whilo
Copy link
Author

whilo commented Nov 12, 2019

Looking at the commit log the MapHandler has changed at some point, caching was also introduced in the meantime. I can try to track down why it is shadowed, if this is helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants