From c2ea8993ee5f43ed69711ec84547ba35db098245 Mon Sep 17 00:00:00 2001 From: Artsiom Tsybulko Date: Thu, 23 Jul 2026 22:14:09 +0300 Subject: [PATCH] 60448 - fix LenientTypeAdapterFactory --- client/generator-templates/lenient/JSON.mustache | 15 +++++++++------ .../regula/documentreader/webclient/JSON.java | 16 +++++++++++----- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/client/generator-templates/lenient/JSON.mustache b/client/generator-templates/lenient/JSON.mustache index e630cf29..7dc328a8 100644 --- a/client/generator-templates/lenient/JSON.mustache +++ b/client/generator-templates/lenient/JSON.mustache @@ -81,15 +81,18 @@ public class JSON { try { return delegate.read(in); } catch (Exception e) { - System.err.println("Warning: failed to parse field of type " - + type + ", reason: " + e.getMessage()); - in.skipValue(); + System.err.println("Warning: failed to parse field of type " + type.getRawType().getSimpleName() + + ", reason: " + e.getMessage()); + try { + in.skipValue(); + } catch (Exception ignored) { + } - if (type.getRawType() == ResultItem.class) { + if (ResultItem.class.isAssignableFrom(type.getRawType())) { try { - return (T) ResultItem.class.getDeclaredConstructor().newInstance(); + return (T) type.getRawType().getDeclaredConstructor().newInstance(); } catch (Exception ex) { - throw new IOException("Failed to create default ResultItem", ex); + return null; } } diff --git a/client/src/main/generated/com/regula/documentreader/webclient/JSON.java b/client/src/main/generated/com/regula/documentreader/webclient/JSON.java index bd7efee9..0b9d4712 100755 --- a/client/src/main/generated/com/regula/documentreader/webclient/JSON.java +++ b/client/src/main/generated/com/regula/documentreader/webclient/JSON.java @@ -75,14 +75,20 @@ public T read(JsonReader in) throws IOException { return delegate.read(in); } catch (Exception e) { System.err.println( - "Warning: failed to parse field of type " + type + ", reason: " + e.getMessage()); - in.skipValue(); + "Warning: failed to parse field of type " + + type.getRawType().getSimpleName() + + ", reason: " + + e.getMessage()); + try { + in.skipValue(); + } catch (Exception ignored) { + } - if (type.getRawType() == ResultItem.class) { + if (ResultItem.class.isAssignableFrom(type.getRawType())) { try { - return (T) ResultItem.class.getDeclaredConstructor().newInstance(); + return (T) type.getRawType().getDeclaredConstructor().newInstance(); } catch (Exception ex) { - throw new IOException("Failed to create default ResultItem", ex); + return null; } }