Skip to content

Commit

Permalink
Fix for Java 13 compatiblity clj-commons#23. Added type hints to reso…
Browse files Browse the repository at this point in the history
…lve breaking code.
  • Loading branch information
markbastian committed Apr 7, 2020
1 parent 83452cb commit 7f362ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ pom.xml.asc
/.nrepl-port
.DS_Store
/doc
push
push
*.iml
.idea/
19 changes: 10 additions & 9 deletions src/durable_queue.clj
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@
(with-buffer [buf slab]
(reset! status s)
(.put buf (p/+ offset 1)
(case s
:incomplete 0
:in-progress 1
:complete 2))
(byte
(case s
:incomplete 0
:in-progress 1
:complete 2)))
(invalidate slab (p/+ offset 1) 1)
nil)))

Expand All @@ -190,9 +191,9 @@
(fn []
(with-buffer [buf slab]
(let [^ByteBuffer buf (-> buf
(.position offset)
(.position ^Long offset)
^ByteBuffer
(.limit (+ offset len))
(.limit ^Long (+ offset len))
.slice)
checksum' (.getLong buf 2)
ary (bs/to-byte-array (.position buf header-size))]
Expand Down Expand Up @@ -303,17 +304,17 @@
(let [ary (nippy/freeze descriptor)
cnt (count ary)
pos @position
^ByteBuffer buf (.position buf pos)]
^ByteBuffer buf (.position buf ^Long pos)]

(when (> (.remaining buf) (+ (count ary) header-size))
;; write to the buffer
(doto buf
(.position pos)
(.position ^Long pos)
(.put (byte 1)) ;; exists
(.put (byte 0)) ;; incomplete
(.putLong (checksum cnt ary))
(.putInt cnt)
(.put ary)
(.put ^bytes ary)
(.put (byte 0))) ;; next doesn't exist

(swap! position + header-size cnt)
Expand Down

0 comments on commit 7f362ab

Please sign in to comment.