Commit b9a35a59 authored by Steven Allen's avatar Steven Allen

revert: don't allow marshal to fail

This is a _bug_, not an error.
parent 63d3899e
......@@ -24,6 +24,7 @@ import (
"encoding/binary"
"encoding/json"
"errors"
"log"
"math"
"math/bits"
"sync"
......@@ -248,17 +249,24 @@ func (bl *Bloom) marshal() bloomJSONImExport {
// JSONMarshal
// returns JSON-object (type bloomJSONImExport) as []byte
func (bl *Bloom) JSONMarshal() ([]byte, error) {
func (bl *Bloom) JSONMarshal() []byte {
data, err := json.Marshal(bl.marshal())
return data, err
if err != nil {
log.Fatal("json.Marshal failed: ", err)
}
return data
}
// JSONMarshalTS is a thread-safe version of JSONMarshal
func (bl *Bloom) JSONMarshalTS() ([]byte, error) {
func (bl *Bloom) JSONMarshalTS() []byte {
bl.Mtx.RLock()
export := bl.marshal()
bl.Mtx.RUnlock()
return json.Marshal(export)
data, err := json.Marshal(export)
if err != nil {
log.Fatal("json.Marshal failed: ", err)
}
return data
}
// JSONUnmarshal
......
......@@ -69,13 +69,13 @@ func TestM_JSON(t *testing.T) {
}
}
Json, err := bf.JSONMarshal()
json := bf.JSONMarshal()
if err != nil {
t.Fatal(err)
}
// create new bloomfilter from bloomfilter's JSON representation
bf2, err := JSONUnmarshal(Json)
bf2, err := JSONUnmarshal(json)
if err != nil {
t.Fatal(err)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment