|
84 | 84 | * </p> |
85 | 85 | * <pre>{@code |
86 | 86 | * // Deserializing with a size limit successfully |
87 | | - * try (ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); |
88 | | - * ValidatingObjectInputStream vois = ValidatingObjectInputStream.builder() |
89 | | - * .accept(HashMap.class, Number.class, Integer.class) |
90 | | - * .setInputStream(BoundedInputStream.builder() |
91 | | - * .setMaxCount(10_000) |
92 | | - * .setOnMaxCount((remains, count) -> { |
93 | | - * throw new IllegalArgumentException("Input exceeds limit."); |
94 | | - * }) |
95 | | - * .setInputStream(bais) |
96 | | - * .get()) |
97 | | - * .get()) { |
98 | | - * // String.class is automatically accepted |
99 | | - * final HashMap<String, Integer> map2 = (HashMap<String, Integer>) vois.readObject(); |
100 | | - * assertEquals(map1, map2); |
101 | | - * } |
102 | | - * // Deserializing with a size limit reaching the limit |
103 | | - * try (ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); |
104 | | - * ValidatingObjectInputStream vois = ValidatingObjectInputStream.builder() |
105 | | - * .accept(HashMap.class, Number.class, Integer.class) |
106 | | - * .setInputStream(BoundedInputStream.builder() |
107 | | - * .setMaxCount(10) |
108 | | - * .setOnMaxCount((remains, count) -> { |
109 | | - * throw new IllegalArgumentException("Input exceeds limit."); |
110 | | - * }) |
111 | | - * .setInputStream(bais) |
112 | | - * .get()) |
113 | | - * .get()) { |
114 | | - * // String.class is automatically accepted |
115 | | - * final IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> vois.readObject()); |
116 | | - * assertEquals("Input exceeds limit.", e.getMessage()); |
117 | | - * } |
| 87 | + * try (ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); |
| 88 | + * ValidatingObjectInputStream vois = ValidatingObjectInputStream.builder() |
| 89 | + * .accept(HashMap.class, Number.class, Integer.class) |
| 90 | + * .setInputStream(BoundedInputStream.builder() |
| 91 | + * .setMaxCount(10_000) |
| 92 | + * .setOnMaxCount((remains, count) -> { |
| 93 | + * throw new IllegalArgumentException("Input exceeds limit."); |
| 94 | + * }) |
| 95 | + * .setInputStream(bais) |
| 96 | + * .get()) |
| 97 | + * .get()) { |
| 98 | + * // String.class is automatically accepted |
| 99 | + * final HashMap<String, Integer> map2 = (HashMap<String, Integer>) vois.readObject(); |
| 100 | + * assertEquals(map1, map2); |
| 101 | + * } |
| 102 | + * // Deserializing with a size limit reaching the limit |
| 103 | + * try (ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); |
| 104 | + * ValidatingObjectInputStream vois = ValidatingObjectInputStream.builder() |
| 105 | + * .accept(HashMap.class, Number.class, Integer.class) |
| 106 | + * .setInputStream(BoundedInputStream.builder() |
| 107 | + * .setMaxCount(10) |
| 108 | + * .setOnMaxCount((remains, count) -> { |
| 109 | + * throw new IllegalArgumentException("Input exceeds limit."); |
| 110 | + * }) |
| 111 | + * .setInputStream(bais) |
| 112 | + * .get()) |
| 113 | + * .get()) { |
| 114 | + * // String.class is automatically accepted |
| 115 | + * final IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> vois.readObject()); |
| 116 | + * assertEquals("Input exceeds limit.", e.getMessage()); |
| 117 | + * } |
118 | 118 | * }</pre> |
119 | 119 | * @since 2.5 |
120 | 120 | */ |
|
0 commit comments