1818
1919package org .phoebus .applications .saveandrestore .ui ;
2020
21- import com .fasterxml .jackson .annotation .JsonInclude ;
22- import com .fasterxml .jackson .databind .DeserializationFeature ;
23- import com .fasterxml .jackson .databind .ObjectMapper ;
24- import com .fasterxml .jackson .datatype .jsr310 .JavaTimeModule ;
2521import org .epics .vtype .VType ;
2622import org .phoebus .applications .saveandrestore .client .SaveAndRestoreClient ;
2723import org .phoebus .applications .saveandrestore .client .SaveAndRestoreClientImpl ;
@@ -68,15 +64,10 @@ public class SaveAndRestoreService {
6864 private static SaveAndRestoreService instance ;
6965
7066 private final SaveAndRestoreClient saveAndRestoreClient ;
71- private final ObjectMapper objectMapper ;
7267
7368 private SaveAndRestoreService () {
7469 saveAndRestoreClient = new SaveAndRestoreClientImpl ();
7570 executor = new ThreadPoolExecutor (1 , 1 , 0L , TimeUnit .SECONDS , new LinkedBlockingQueue <>());
76- objectMapper = new ObjectMapper ();
77- objectMapper .configure (DeserializationFeature .FAIL_ON_UNKNOWN_PROPERTIES , false );
78- objectMapper .registerModule (new JavaTimeModule ());
79- objectMapper .setSerializationInclusion (JsonInclude .Include .NON_NULL );
8071 }
8172
8273 public static SaveAndRestoreService getInstance () {
@@ -396,7 +387,7 @@ public List<SnapshotItem> takeSnapshotFromArchiver(String configurationNodeId, I
396387 snapshotItem .setConfigPv (configPv );
397388 snapshotItem .setValue (readFromArchiver (configPv .getPvName (), _time ));
398389 if (configPv .getReadbackPvName () != null ) {
399- snapshotItem .setValue (readFromArchiver (configPv .getReadbackPvName (), _time ));
390+ snapshotItem .setReadbackValue (readFromArchiver (configPv .getReadbackPvName (), _time ));
400391 }
401392 snapshotItems .add (snapshotItem );
402393 });
@@ -418,13 +409,18 @@ private VType readFromArchiver(String pvName, Instant time) {
418409 }
419410 // Prepend "archiver://"
420411 pvName = "archive://" + pvName + "(" + TimestampFormats .SECONDS_FORMAT .format (time ) + ")" ;
412+ PV pv = null ;
413+ VType pvValue = null ;
421414 try {
422- PV pv = PVPool .getPV (pvName );
423- VType pvValue = pv .read ();
424- PVPool .releasePV (pv );
425- return pvValue == null ? VDisconnectedData .INSTANCE : pvValue ;
415+ pv = PVPool .getPV (pvName );
416+ pvValue = pv .read ();
426417 } catch (Exception e ) {
427- return VDisconnectedData .INSTANCE ;
418+ Logger .getLogger (SaveAndRestoreService .class .getName ()).log (Level .WARNING , "Failed to read " + pvName , e );
419+ } finally {
420+ if (pv != null ) {
421+ PVPool .releasePV (pv );
422+ }
428423 }
424+ return pvValue == null ? VDisconnectedData .INSTANCE : pvValue ;
429425 }
430426}
0 commit comments