- try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(file))) {
- return in.readObject();
- } catch (ClassNotFoundException e) {
- throw new IOException("Error loading snapshot file " + file, e);
- } catch (IOException e) {
- LOG.debug("Error loading snapshot file {}", file, e);
-
- return tryDeserializeAkkaSnapshot(file);
- }
+ return JavaSerializer.currentSystem().withValue((ExtendedActorSystem) context().system(),
+ (Callable<Object>) () -> {
+ try (ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)))) {
+ return in.readObject();
+ } catch (ClassNotFoundException e) {
+ throw new IOException("Error loading snapshot file " + file, e);
+ } catch (IOException e) {
+ LOG.debug("Error loading snapshot file {}", file, e);
+ return tryDeserializeAkkaSnapshot(file);
+ }
+ });