java.util.Prefs throwing BackingStoreException - Why?

后端 未结 3 2059
抹茶落季
抹茶落季 2021-02-04 02:36

I have a system that caches the tiny/simple results of an on-startup SOAP call

I need instances to be able to reload their cache on startup (in case the SOAP service is

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-04 02:51

    Instead of using Preferences, just use any serializable Map and make a very simple cache class which serializes and deserializes it to a randomly-generated temporary filename (the filename being generated on first initialisation). Since it is only a cache, you can just catch any exceptions and reset the cache back to its initial state when an exception happens, so it will re-fetch from the original data source (the SOAP service in your case). So there's no need to worry about serialVersionUID or any of that compatibility stuff, if you don't want to.

提交回复
热议问题