Attempts to patch ZipOutputStream to prevent some tools from exploiting ZIP writing mechanism. @param zip Stream to patch.
(ZipOutputStream zip)
| 327 | * Stream to patch. |
| 328 | */ |
| 329 | public static void patchZipOutput(ZipOutputStream zip) { |
| 330 | try { |
| 331 | Field field = ZipOutputStream.class.getDeclaredField("names"); |
| 332 | field.setAccessible(true); |
| 333 | field.set(zip, new DiscardingSet()); |
| 334 | } catch (NoSuchFieldException | IllegalAccessException ex) { |
| 335 | Log.error(ex, "Could not replace ZIP names"); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * A set that discards it's elements upon adding. |
no test coverage detected