hankcs / AhoCorasickDoubleArrayTrie

An extremely fast implementation of Aho Corasick algorithm based on Double Array Trie.
http://www.hankcs.com/program/algorithm/aho-corasick-double-array-trie.html
950 stars 290 forks source link

Serialized/Unserialized issue #22

Closed chiyuan1126 closed 5 years ago

chiyuan1126 commented 5 years ago

Really appreciate for sharing such a nice project!

I locally serialized the object of AhoCorasickDoubleArrayTrie, but it had a problem when it automatically deployed with git + maven + webhook.

My project is running on a server which is able to sync the latest code with my git repo, compile and deploy on the server.

Since I am not able to set a static serialVersionUID of AhoCorasickDoubleArrayTrie in the maven project, it caused the issue of "com.hankcs.algorithm.AhoCorasickDoubleArrayTrie; local class incompatible: stream classdesc serialVersionUID = -6758999135472224142, local class serialVersionUID = -2711673058600411070".

I can imagine that one possible solution could be that I pack everything in a war file and deploy it with tomcat or doing the serialized process on the server. But the problem is I don't have the control of the server. What I could do is only to update my source code in the git repo.

Do you have any suggestions for that scenario ? Thanks a lot your help!

(one more naive and stupid question, is it possible for you to set a static serialVersionUID in your maven so that when people are doing the same scenario as mine they won't have this issue? it seems no harm ? Please feel free to push back)

chiyuan1126 commented 5 years ago

Now I am just using the source code instead of the maven to make it work.

hankcs commented 5 years ago

I don't like Java serialization. I prefer to use hand-crafted save/load, then write some codes to save values in the same stream.

chiyuan1126 commented 5 years ago

I see. Thanks for your reply!