Free cookie consent management tool by TermsFeed Policy Generator

Ticket #2520: persistenceutil_attic12.patch

File persistenceutil_attic12.patch, 2.6 KB (added by abeham, 5 years ago)

Patch that alters retry with old persistence, to be applied when HEAL.Attic 1.2 is available.

  • HeuristicLab.Clients.Hive/3.3/HeuristicLab.Clients.Hive-3.3.csproj

     
    106106    <Prefer32Bit>false</Prefer32Bit>
    107107  </PropertyGroup>
    108108  <ItemGroup>
     109    <Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
     110      <SpecificVersion>False</SpecificVersion>
     111      <HintPath>..\..\bin\Google.Protobuf.dll</HintPath>
     112      <Private>False</Private>
     113    </Reference>
    109114    <Reference Include="System" />
    110115    <Reference Include="System.Configuration" />
    111116    <Reference Include="System.Core" />
  • HeuristicLab.Clients.Hive/3.3/Plugin.cs.frame

     
    4040  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
    4141  [PluginDependency("HeuristicLab.Optimization", "3.3")]
    4242  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     43  [PluginDependency("HeuristicLab.Protobuf", "3.6.1")]
    4344  public class HeuristicLabClientsHivePlugin : PluginBase {
    4445  }
    4546}
  • HeuristicLab.Clients.Hive/3.3/Util/PersistenceUtil.cs

     
    2222using System;
    2323using System.Collections.Generic;
    2424using System.IO;
     25using Google.Protobuf;
    2526using HEAL.Attic;
    2627using HeuristicLab.Persistence.Default.Xml;
    2728
     
    4344      var ser = new ProtoBufSerializer();
    4445      try {
    4546        return (T)ser.Deserialize(sjob);
    46       } catch (Exception) {
    47         // retry with old persistence
    48         using (MemoryStream memStream = new MemoryStream(sjob)) {
    49           return XmlParser.Deserialize<T>(memStream);
    50         }
     47      } catch (PersistenceException e) {
     48        if (e.InnerException is InvalidProtocolBufferException
     49          || e.InnerException is InvalidDataException) {
     50          // retry with old persistence
     51          using (MemoryStream memStream = new MemoryStream(sjob)) {
     52            return XmlParser.Deserialize<T>(memStream);
     53          }
     54        } else throw;
    5155      }
    5256    }
    5357  }